Jump to content
  • Advertisement
Sign in to follow this  
Shadowwoelf

extra space

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

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.
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
}


Anything I did wrong?

Share this post


Link to post
Share on other sites
Advertisement
Hmm looks correct, I didn't see any problems there.

Does the texture have some transparent areas at the sides? [wink]..

Share this post


Link to post
Share on other sites
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.

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!