🔒 Locked
Problems with textures
Advertisement
Original Post
Just BMP format, I''ve adapted the Lesson 6 Tutorial to my needs.
Now I know I''ll be told my way of loading my textures using IF isn''t effective, it''s because I''m testing and will be adding some level loading stuff in the near future. I''ve had this problem before so that''s why I''m trying different ways of loading textures.
void CreateTexture ( void )
{
char filename[MAX_PATH];
AUX_RGBImageRec *Image;
int i;
glGenTextures(2, &Texture[0]); // Create The Texture
for (i=0; i<2; i++)
{
if (i == 0)
strcpy (filename,"bg.bmp");
if (i == 1)
strcpy (filename,"install.bmp");
Image = auxDIBImageLoad(filename);
glBindTexture(GL_TEXTURE_2D, Texture[i]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, Image->sizeX, Image->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, Image->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
}
if (Image)
{
if (Image->data)
free(Image->data);
free(Image);
}
}
int InitGL(GLvoid) // All Setup For OpenGL Goes Here
{
CreateTexture ();
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glClearColor(0.0f, 0.0f, 0.5f, 0.5f); // Black Background
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glEnable(GL_TEXTURE_2D);
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
return TRUE; // Initialization Went OK
}
int DrawGLScene(GLvoid) // Here''s Where We Do All The Drawing
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity(); // Reset The Current Modelview Matrix
glTranslatef (0.0f, 0.0f, -57.0f);
glBindTexture (GL_TEXTURE_2D, Texture[0]);
glBegin (GL_QUADS);
glTexCoord2f(0,1);glVertex2f (-32.0f, 24.0f);
glTexCoord2f(1,1);glVertex2f ( 32.0f, 24.0f);
glTexCoord2f(1,0);glVertex2f ( 32.0f,-24.0f);
glTexCoord2f(0,0);glVertex2f (-32.0f,-24.0f);
glEnd();
glLoadIdentity();
glTranslatef (0.0f, 0.0f, -5.0f);
glRotatef (rot, 0.0f, 1.0f, 0.0f);
glBindTexture (GL_TEXTURE_2D, Texture[1]);
glBegin (GL_QUADS);
glTexCoord2f(0,1);glVertex2f (-1.0f, 0.5f);
glTexCoord2f(1,1);glVertex2f ( 1.0f, 0.5f);
glTexCoord2f(1,0);glVertex2f ( 1.0f,-0.5f);
glTexCoord2f(0,0);glVertex2f (-1.0f,-0.5f);
glEnd();
rot += 2;
return TRUE;
}
Now I know I''ll be told my way of loading my textures using IF isn''t effective, it''s because I''m testing and will be adding some level loading stuff in the near future. I''ve had this problem before so that''s why I''m trying different ways of loading textures.
Are the textures power of 2?
Are they the proper format?
I don''t use auxDIBImageLoad(filename), instead, I use my custom made function, but, I think, I did try to use it once for an 8 bpp BMP,and it didn''t work.
Try changing the color depth of your BMP, to 24bpp. Also, make sure they are powers of 2.
Are they the proper format?
I don''t use auxDIBImageLoad(filename), instead, I use my custom made function, but, I think, I did try to use it once for an 8 bpp BMP,and it didn''t work.
Try changing the color depth of your BMP, to 24bpp. Also, make sure they are powers of 2.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement