Jump to content
  • Advertisement
Sign in to follow this  
Esmo2000

OpenGL texture won't render

This topic is 4832 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi All: I'm working in openGl ES and i have just been having a wail of a time trying to get this piece of code to work. Basically, i have a dome and it should be rendering with a texture, but instead it seems to be using some sort of color pointer that has been used previously. The reason that I guess that is because when I draw some axes on the screen which use a color pointer it appears, but if I do not draw them then it does not appear at all. I don't know why this would be because I disable all of the client states when I leave the function, but possibly someone here could help me with just that ^^ A few things are different in opengl es and thus the link to the api is here: http://www.khronos.org/opengles/documentation/opengles1_0/html/index.html My code is at and the functions are pasted in the order they are seen... http://muer.njoerdba.com/paste/view.aspx?id=773f7691-e4f9-4bb6-86d2-515d64e95ccc if anyone could help i would appreciate it a TON!

Share this post


Link to post
Share on other sites
Advertisement
Thanks for giving me the link after you posted it [razz] Anyway, I've been trying to figure out where he went wrong...

EDIT: lolol. I missed his code link. I guess I'm unable to see unlinkified links these days.

Here's his texture loading code:
    //  Go into texture mode
glEnable(GL_TEXTURE_2D);

// Generate the texture information
glGenTextures(1, &pMe->skydome->textures);

// Bind the texture to our skydome texture
glBindTexture(GL_TEXTURE_2D, &pMe->skydome->textures);
glActiveTexture(&pMe->skydome->textures);

// Todo: Dynamically generate bottom and such at runtime, change this back to indexed color
// Feed in the texture data (note, must be 64x64 and a power of 2???! http://www.khronos.org/opengles/documentation/opengles1_0/html/glTexImage2D.html & book pg 156
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
pMe->skydome->backgroundImage->info.cx, pMe->skydome->backgroundImage->info.cy,
0, GL_RGB, GL_UNSIGNED_BYTE, pMe->skydome->backgroundImage->data);
}



And the render call
//    Renders the skydome
void renderSkyDome(skydome* skydome){

// Enable texturing
glEnable(GL_TEXTURE_2D);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

// Bind the texture to our skydome texture
glBindTexture(GL_TEXTURE_2D, skydome->textures);

// Enable pointers to vertices and texture data
glVertexPointer (3, GL_FIXED, sizeof(GLfixed)*5, skydome->skydomeVertices); // *5 because there are two interleaved texcoords
glTexCoordPointer(2, GL_FIXED, sizeof(GLfixed)*5, &skydome->skydomeVertices[3]);

glDrawArrays (GL_TRIANGLE_STRIP, 0, skydome->numOfVertices);

// Enable color arrays again
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable(GL_TEXTURE_2D);
}


And the output:



Anyway, so the texture appears to be loading right, the texture coordinate generation appears to be correct. Changing the texture to a solid color didn't change the color from blue, which means the texture either isn't loaded, or isn't being set properly. I don't have enough knowledge about ES to figure it out :P

Thanks guys.

Share this post


Link to post
Share on other sites
I don't know ES, but looking at your code there are two things that look suspicious:
glGenTextures(1, &pMe->skydome->textures);
// Bind the texture to our skydome texture
glBindTexture(GL_TEXTURE_2D, &pMe->skydome->textures);
Under normal OpenGL this would be:
glGenTextures(1, &pMe->skydome->textures);
// Bind the texture to our skydome texture
glBindTexture(GL_TEXTURE_2D, pMe->skydome->textures);
Note, no & on the glBindTexture call. I would expect the same to be true in ES.
glActiveTexture(&pMe->skydome->textures);
I believe this should specify a texture unit, not a texture object, i.e. the argument should be GL_TEXTUREi.

Enigma

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!