Register | Login | |||||
Main
| Memberlist
| Active users
| Calendar
| Chat
| Online users Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album |
| |
0 users currently in Programming. |
Acmlm's Board - I3 Archive - Programming - GRAAAH OpenGL 2D texturing problem | New poll | | |
Add to favorites | Next newer thread | Next older thread |
User | Post | ||
Disch Red Cheep-cheep Since: 12-10-05 Last post: 6712 days Last view: 6712 days |
| ||
I'm going bonkers. I've looked at my previous OpenGL test programs (which all worked fine) to make sure I'm not missing a step here... but still, it's just not working. So I come here, in hopes that someone can tell me what I'm missing.
The scenario: I'm working on a game engine... and right now I'm trying to get a test map displayed on screen. It's tile based, and each tile is a 2D quad. The tiles are all arranged into two GLfloat buffers on map load -- one to hold the verteces, and the other for the texture coords. The method: Rather than using display lists, I'm going with the gl____Pointer + glDrawArrays method. So actully drawing the map looks like the following:
The problem: The map is drawing. However the texture is not. Instead of getting a nice tiled map image, I'm getting a big white square for the map -- as if texturing were disabled (quads are being rendered -- they're just not textured). I'm figuring there must be some step I'm skipping on setup. Here's the texture related calls I'm doing (in the order I do them): on startup: glEnable(GL_TEXTURE_2D); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); on texture load: glGenTextures glBindTexture glTexImage2D on draw: glBindTexture on shutdown: glDeleteTextures It feels like I've been banging my head against the wall. I honestly don't have a clue why it isn't working. I've checked the buffer I'm passing to glTexImage2D and it seems to have the right image (or at least... the image contains no white pixels). glGetError reports no error after texture load. At this point I'm seeking any idea on what the problem could be. I don't care how ridiculous. This is driving me nuts. Thanks in advance. |
|||
Guy Perfect Since: 11-18-05 Last post: 6434 days Last view: 6432 days |
| ||
Looks like all the GL calls are happening in the correct order... But for each of the things you mentioned after "on startup," you didn't show the exact syntax of what you were using. Do that, and a problem may be discoverable.
A way to verify if the texturing works is to input a simple shape by hand and set the texture coordinates by hand. If THAT works, then there's something in the way you're calling the vertex arrays that's not working correctly. Also, as a rule of thumb, two triangles can be rendered faster than one quad. I recommend using GL_TRIANGLE_STRIP instead of GL_QUADS for your glBegin and glDrawArrays statements. |
|||
Disch Red Cheep-cheep Since: 12-10-05 Last post: 6712 days Last view: 6712 days |
| ||
I actually just now solved the problem with help from people on IRC.
Apparently GL was using the wrong mipmap level image of the texture for rendering. So I replaced glTexImage2D with gluBuild2DMipmaps and all is well. Originally posted by BGNG Yes... but triangle strips don't work well with 2D tiled maps since 2 of the 3 verteces of any triangle beyond the first are shared with the previous triangle. IE two tiles next to each other on the map will have to have graphics that are adjacent to each other on the texture. Thanks for the reply ^^ |
Add to favorites | Next newer thread | Next older thread |
Acmlm's Board - I3 Archive - Programming - GRAAAH OpenGL 2D texturing problem | | |