Hi all,
I've download the Nehe Opengl tutorial examples for PureBasic (
ftp://ftp-developpez.com/purebasic/sources/fichiers/3d/opengl/nehe-tutoriels.zip) for testing first (I gonna learn soon) and got and error for the examples 7 up to 12 with the FreeMemory in this procedure (it is nearly the same in each example):
Procedure.l LoadGLTextures() ;Load Bitmaps And Convert To Textures
Protected Status.l=#False ;Status Indicator
Protected Dim *TextureImage.AUX_RGBImageRec(1) ;Create Storage Space For The Texture
;Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
*TextureImage(0)=LoadBMP("Data/Crate.bmp")
If *TextureImage(0)
Status=#True ;Set The Status To TRUE
glGenTextures_(3,@texture(0)) ;Create Three Textures
;Create Nearest Filtered Texture
glBindTexture_(#GL_TEXTURE_2D,texture(0))
glTexParameteri_(#GL_TEXTURE_2D,#GL_TEXTURE_MAG_FILTER,#GL_NEAREST)
glTexParameteri_(#GL_TEXTURE_2D,#GL_TEXTURE_MIN_FILTER,#GL_NEAREST)
glTexImage2D_(#GL_TEXTURE_2D,0,3,*TextureImage(0)\sizeX,*TextureImage(0)\sizeY,0,#GL_RGB,#GL_UNSIGNED_BYTE,*TextureImage(0)\Data)
;Create Linear Filtered Texture
glBindTexture_(#GL_TEXTURE_2D,texture(1))
glTexParameteri_(#GL_TEXTURE_2D,#GL_TEXTURE_MAG_FILTER,#GL_LINEAR)
glTexParameteri_(#GL_TEXTURE_2D,#GL_TEXTURE_MIN_FILTER,#GL_LINEAR)
glTexImage2D_(#GL_TEXTURE_2D,0,3,*TextureImage(0)\sizeX,*TextureImage(0)\sizeY,0,#GL_RGB,#GL_UNSIGNED_BYTE,*TextureImage(0)\Data)
;Create MipMapped Texture
glBindTexture_(#GL_TEXTURE_2D,texture(2))
glTexParameteri_(#GL_TEXTURE_2D,#GL_TEXTURE_MAG_FILTER,#GL_LINEAR)
glTexParameteri_(#GL_TEXTURE_2D,#GL_TEXTURE_MIN_FILTER,#GL_LINEAR_MIPMAP_NEAREST)
gluBuild2DMipmaps_(#GL_TEXTURE_2D,3,*TextureImage(0)\sizeX,*TextureImage(0)\sizeY,#GL_RGB,#GL_UNSIGNED_BYTE,*TextureImage(0)\Data)
EndIf
If *TextureImage(0) ;If Texture Exists
If *TextureImage(0)\Data ;If Texture Image Exists
FreeMemory(*TextureImage(0)\Data) ;Free The Texture Image Memory
EndIf
FreeMemory(*TextureImage(0)) ;Free The Image Structure
EndIf
ProcedureReturn Status ;Return The Status
EndProcedure
The compiler gave the error:
The specified "MemoryId" is not valid for the two FreeMemory at the end.
If I comment the lines, everything runs fine. But as I'm a serious programmer

, if I create a memory struct, you should free it after

Someone got an idea?