Sign in to follow this  

Grrr, freakin ortho

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

Hey all. I had a console system for the beginnings of my engine nicely done when I was rendering a Quake 3 Model. However, when it comes to putting my console onto the the BSP Loader, it falls apart and does not display. This happened ages ago when I tried it before. I'm using the BSP Loader tutorial from GameTutorials. I have not changed any of the code bar the CQuake3BSP class name (and that was to stay within the engines naming scheme. Its now CBSPX). Oh and changed Main.CPP/H to Entry.CPP/H to keep it constant for me. My console window uses the ortho view to display stuff. I am wondering what I need to alter in the RenderLevel() function. Currently my Console window does the following to get into Ortho and out: Shifting into Ortho
CConsole::Shift_2D()
{
glMatrixMode(GL_PROJECTION);						

glPushMatrix();		


glLoadIdentity();


glOrtho(Left,Right,Bottom,Top,Near,Far);


glMatrixMode(GL_MODELVIEW);								

glLoadIdentity();
}


Rendering
glEnable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
Shift_2D();

//Load the texture:

glColor3f(1.0, 1.0, 1.0);


glDisable(GL_DEPTH_TEST);

//	Bind the consoles texture to the following verts
glBindTexture(GL_TEXTURE_2D,  l_Texture[0]);


glBegin(GL_QUADS);
	
// Display the top left point of the 2D image
glTexCoord2f(0.0f, 1.0f); glVertex2f(X, Y);

// Display the bottom left point of the 2D image
glTexCoord2f(0.0f, 0.0f); glVertex2f(0, Height);

// Display the bottom right point of the 2D image
glTexCoord2f(1.0f, 0.0f); glVertex2f(Width, Height);

// Display the top right point of the 2D image
glTexCoord2f(1.0f, 1.0f); glVertex2f(Width, 0);

	// Stop drawing 
	glEnd();
[... Other console based code ...]

glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
Shift_3D();
}


Shifting back into 3D
void CConsole::Shift_3D()
{
glMatrixMode( GL_PROJECTION );							

glPopMatrix();											

glMatrixMode( GL_MODELVIEW );		
}


Now, I haven't any idea whats going wrong. When I tried this in my model viewer it works happily, but as I said, when I run it in the BSP loader...it rectals majorly. Also, the same can be said for texture based fonts (Chptr 17, i believe, of Nehe). Anything that uses 2D ortho quads seems to refuse to display Any hints? I have been struggling with this for a while now trying to work out wtf is going wrong. Cheers, any help is much appreciated and explanation is very very much appreciated :)

Share this post


Link to post
Share on other sites
This may be very wrong (I haven't coded OGL stuff in a while), but, don't you need to set the viewport somewhere before drawing your ortho? (Or anything, really.) And, of course, double check that the arguments into the glOrtho are correct.

Share this post


Link to post
Share on other sites
Looks pretty much like my code, except that I also save the ModelView Matrix:

void PreRender()
{
glPushAttrib(GL_ALL_ATTRIB_BITS);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(-0.5f,639.5f,479.5f,-0.5f, 0.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
};

void PostRender()
{
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glPopAttrib();
};



If drawing your console is the last thing you do before flushing or swaping buffers, I doubt it would make any difference, but if it is before that, it might.

Share this post


Link to post
Share on other sites
Something doesn't seem right in the actual rendering of the quad. What are the X,Y values in the first vertex? If they're 0,0 then that should work fine, but anything other than that may not render a quad. You'd have to use X + width, Y + height for the other verts if you don't specifically translate to your X, Y coord.

Another possibility is the values used to set up the ortho projection. The height values may be inverted, which would cause your counterclockwise wound quads to be facing away from you. Just note that an X,Y positive quadrant in OpenGL would put the origin at the bottom left corner not the top left. If you're trying to use a top to bottom text printing scheme, then the coordinate system may be inverted.

Share this post


Link to post
Share on other sites
Quote:
Original post by MotionCoil
Ok, i'm actually cracking up here...
I had culling enabled!

sorted!
thanks for all your time. It was my own stupid fault for not reading through my code properly. For a whole week.


I was just about to point that out to you. Rule #1: Keep your vertices CCW.

Share this post


Link to post
Share on other sites

This topic is 4746 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this