The following are the two functions that BlitzResearch have in their glgraphics module for converting a pixmap to an opengl texture:
Rem
bbdoc: Helper function to calculate nearest valid texture size
about: This functions rounds @width and @height up to the nearest valid texture size
End Rem
Function GLAdjustTexSize( width Var,height Var )
Function Pow2Size( n )
Local t=1
While t<n
t:*2
Wend
Return t
End Function
width=Pow2Size( width )
height=Pow2Size( height )
Repeat
Local t
glTexImage2D GL_PROXY_TEXTURE_2D,0,4,width,height,0,GL_RGBA,GL_UNSIGNED_BYTE,Null
glGetTexLevelParameteriv GL_PROXY_TEXTURE_2D,0,GL_TEXTURE_WIDTH,Varptr t
If t Return
If width=1 And height=1 RuntimeError "Unable to calculate tex size"
If width>1 width:/2
If height>1 height:/2
Forever
End Function
Rem
bbdoc: Helper function to create a texture from a pixmap
returns: Integer GL Texture name
about: @pixmap is resized to a valid texture size before conversion.
end rem
Function GLTexFromPixmap( pixmap:TPixmap,mipmap=True )
If pixmap.format<>PF_RGBA8888 pixmap=pixmap.Convert( PF_RGBA8888 )
Local width=pixmap.width,height=pixmap.height
GLAdjustTexSize width,height
If width<>pixmap.width Or height<>pixmap.height pixmap=ResizePixmap( pixmap,width,height )
Local old_name,old_row_len
glGetIntegerv GL_TEXTURE_BINDING_2D,Varptr old_name
glGetIntegerv GL_UNPACK_ROW_LENGTH,Varptr old_row_len
Local name
glGenTextures 1,Varptr name
glBindtexture GL_TEXTURE_2D,name
Local mip_level
Repeat
glPixelStorei GL_UNPACK_ROW_LENGTH,pixmap.pitch/BytesPerPixel[pixmap.format]
glTexImage2D GL_TEXTURE_2D,mip_level,GL_RGBA8,width,height,0,GL_RGBA,GL_UNSIGNED_BYTE,pixmap.pixels
If Not mipmap Exit
If width=1 And height=1 Exit
If width>1 width:/2
If height>1 height:/2
pixmap=ResizePixmap( pixmap,width,height )
mip_level:+1
Forever
glBindTexture GL_TEXTURE_2D,old_name
glPixelStorei GL_UNPACK_ROW_LENGTH,old_row_len
Return name
End Function
I have no idea why you would want to convert to an opengl texture unless you are not using any of the code from the BRL modules to draw your graphics and are doing a clean opengl implementation. When you load an image with the LoadImage and LoadAnimImage command you should be able to just draw them using the DrawImage command.
If you end a variable name with [] it becomes an array, so you should not have those at the end of your variable if you do not want an array.
If you try and use the "Galaxy" variable directly with "glBindTexture" it will fail because the Galaxy variable points to the image object, not to the pixel data itself. If you want to point to the pixel data then there is a couple of options one of which is using the LockImage() command which returns a pixmap from the image.