glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, BMP.bmWidth, BMP.bmHeight, 0, GL_BGR, GL_UNSIGNED_BYTE, BMP.bmBits);//this line it loads and displays perfectly
//glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 64, 64, GL_BGR, GL_UNSIGNED_BYTE, BMP.bmBits);//this line should in theory work perfect too, but it doesn't work at all
🔒 Locked
gltexsubimage2d() issues
Advertisement
Original Post
I am currently working on my own little 2d engine. the only problem I had was I had only glteximage2d to do all of my sprites, so I couldn't take frames from a sprite sheet. then I discovered gltexsubimage2d. the only problem I have is that the sprite displays as a white square. displaying it like a normal texture works fine, so I'm assuming that the rendering is fine, so here is what I have for the lines of code that seem important: is there something I'm not doing right? or could something else be the problem. thanks to whoever helps, this has been annoying me for nearly a week.
glTexSubImage2D is used to write data into an texture that has already been created, it doesnt create the texture itself
The Redbook actually explains that it quite well. You supply a small set of data that is to go into a smaller area of the original image. It sounds like this isnt actually what you want to do. You want to either, crop the incoming image and write each sprite into its own texture (you have to do that manually) or, load the sprite sheet in as a single texture, and then manipulate your texture coordinates so that you only use a fraction of the texture for each sprite.
What is the actual effect of texsub in DirectX? (I dont know much DX) I may be able to point you to something similar.
But usually to use a sprite sheet you would just used cropped texture coordinates.
But usually to use a sprite sheet you would just used cropped texture coordinates.
okay, PM me to remind me to reply. I need to get back to work, lol.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement