glTexSubImage2D

BlitzMax Forums/OpenGL Module/glTexSubImage2D

Bremer(Posted 2005) [#1]
If I load two pixmaps. Make one of them into a texture. Then wants to update that one with the other pixmap, how would that work?

I have tried this approach, which doesn't work. The texture just gets updated with some garbage pixels:

tmp1 = LoadPixmap( "test1.png" )
tmp2 = LoadPixmap( "test2.png" )
tex1 = bglTexFromPixmap( tmp1 )
glBindTexture GL_TEXTURE_2D,tex1
glTexSubImage2D( GL_TEXTURE_2D, 0, xOffset, yOffset, width, height , GL_RGBA, GL_UNSIGNED_BYTE, tmp2.pixels )


Anyone got working examples of doing this?


ImaginaryHuman(Posted 2005) [#2]
I'm not sure if the handle that is returned from bglTexFromPixmap is the actual internal memory space used to store the data passed to OpenGL. It may be a blitz-generated value such as just an index number.

I would say, instead of using bgltexfrompixmap, just upload the first texture yourself, then you can be sure that you're passing the same tex1 variable as the handle. Then do the subimage2d to update it.

If you are getting garbage pixels it may be that you don't have some of the other parameters defined properly. You need to set up whether there is wrapping taking place, a skip value, how many bytes per pixel, etc. I'm not sure if it's glTexParamter() or what. I'd say you haven't set up enough settings.


Bremer(Posted 2005) [#3]
I will have a read in my openGL super bible once more to see if I can figure out what I might am missing as far as other gl commands that I might need to set.

How would you upload the texture yourself ? It doesn't look to me like Bmax have built in functions to do so, other than bglTexFromPixmap. Would it involve writing my own file loading code?