GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window
{
if (height==0) // Prevent A Divide By Zero By
{
height=1; // Making Height Equal One
}
glViewport(0,0,width,height); // Reset The Current Viewport
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
glOrtho(0.0f,width,height,0.0f,-1.0f,1.0f); // Create Ortho 640x480 View (0,0 At Top Left)
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
Width=width;
Height=height;
}
int InitGL(GLvoid) // All Setup For OpenGL Goes Here
{
if (!LoadGLTextures()) // Jump To Texture Loading Routine
{
return FALSE; // If Texture Didn't Load Return FALSE
}
BuildFont(); // Build The Font
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Clear The Background Color To Black
glClearDepth(1.0); // Enables Clearing Of The Depth Buffer
glDepthFunc(GL_LEQUAL); // The Type Of Depth Test To Do
glBlendFunc(GL_SRC_ALPHA,GL_ONE); // Select The Type Of Blending
glShadeModel(GL_SMOOTH); // Enables Smooth Color Shading
glEnable(GL_TEXTURE_2D); // Enable 2D Texture Mapping
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 The Screen And The Depth Buffer
glLoadIdentity(); // Reset The Modelview Matrix
glBindTexture(GL_TEXTURE_2D, texture[1].texID); // ( CHANGE )
glBegin(GL_QUADS); // Start Drawing Quads
glTexCoord2f(0.0f, 0.0f); glVertex2i(0, 0); // Bottom left
glTexCoord2f(0.0f, 1.0f); glVertex2i(0, Height); // Bottom Right
glTexCoord2f(1.0f, 1.0f); glVertex2i(Width, Height); // Top right
glTexCoord2f(1.0f, 0.0f); glVertex2i(Width, 0); // Top left
glEnd();
return TRUE; // Keep Going
}
extra space
I am using a mixture of lessons and I cannot figure out why the quad I'm drawing has extra black space on the sides while the top and bottom reach accordingly to the windows size.
Anything I did wrong?
Hmm looks correct, I didn't see any problems there.
Does the texture have some transparent areas at the sides? [wink]..
Does the texture have some transparent areas at the sides? [wink]..
Member of the NeHe team | PhD Student at Heidelberg Collaboratory for Image Processing | ProCamera Developer
Nope, I resized it then trimmed it down to a 2 pow in photoshop and as far as I can tell it shouldn't be doing that...
I tried your code and it ran fine for me. Do you set Width and Height to the correct values at startup?
Just try to set the coordinates by hand if it still not works, lets say you create a window 800x600 and then set width=800 and height=600. Just to be sure that the variables contain the correct values.
Just try to set the coordinates by hand if it still not works, lets say you create a window 800x600 and then set width=800 and height=600. Just to be sure that the variables contain the correct values.
Member of the NeHe team | PhD Student at Heidelberg Collaboratory for Image Processing | ProCamera Developer
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement