Jump to content
  • Advertisement
Sign in to follow this  
jbmcgee89@gmail.com

OpenGL Opengl ES TGA Texture problem

This topic is 2571 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

Trying to render 16x16 red texture onto a quad. All i get is a white quad. Using the TGA Load at GPWIkii and Opengl ES 1.x in xcode;



Load Texture
// Initialize OpenGL states
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D); glDisable(GL_DEPTH_TEST);
TGAImg image;
image.Load("box.tga");
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
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, image.GetBPP()/8, image.GetWidth(), image.GetHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, image.GetImg());
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D)





[color="#008b00"][color="#000000"][font="arial, verdana, tahoma, sans-serif"]Render Code[/font]


glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
glViewport(0, 0, backingWidth, backingHeight);

// Clear screen glClear(GL_COLOR_BUFFER_BIT);
GLfloat texCoords[2*4] = { 0,1, 1,1, 0,0, 1,0 };
GLfloat vertices[3*4] =
{
position[0], position[1] + height, position[2],
position[0] + width, position[1] + height, position[2],
position[0], position[1], position[2],
position[0] + width, position[1], position[2],
};

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, texture);
glVertexPointer(3, GL_FLOAT, 0, vertices);
glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);

Share this post


Link to post
Share on other sites
Advertisement
nvm, passing "[color=#1C2837][font=CourierNew, monospace][size=2][color=#000000]image[color=#666600].[color=#660066]GetBPP[color=#666600]()/[color=#006666]8" as a param for GL_Enum type is the problem.[/font]

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!