Skip to main content
gamedev.net
🔒 Locked

Back Buffer

Started by jonbell 3 replies 650+ views
Original Post
jonbell
jonbell
How do i get direct access to the back buffer when using OGL? Also (unrelated to the above) how can I draw a quad to the screen using just screen x,y co-ord''s? I actually have my own 2d fonts that i can texture to a quad and want to use them to display text on screen. Taaaaa
RizMan
RizMan
Don''t know about your Back Buffer question.

About displaying text on the screen, check out NeHe''s tutorials. He has a few about fonts.
_walrus
_walrus
Opengl Defaults so that the back buffer is drawn into. you can use glDrawBuffer(mode) to set the buffer you want to draw into. I''m pretty sure that you can''t directy write to the back buffer (i.e. grab the memory location of the buffer and write to it) I think somebody as asking this a few weeks ago and the reply said that gl can''t assume the location of the framebuffer or else it would have to violate the platform independence of Opengl. As for the quads and render using screen coordinates you should be able to use and orothgraphic projection as opposed to a perspective projection. you can then specify all your coorindates in screen cooridnates.


void GlPushOrthographicProjection(float xValue, float yValue)
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0.0, (GLfloat) xValue, 0.0, (GLfloat) yValue);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
}

void GlPopOrthographicProjection()
{
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}


void DrawText()
{
GlPushOrthographicProjection(640, 480); //setup for 2d rendering
drawText("Hello There", 10,10); //draw text at position 10, 10 of the screen
drawRect(10,10, 30,30); //lower left and uper right position of rect
GlPopOrthographicProjection();
}

RizMan
RizMan
That''s more or less how it is done in NeHe''s tutorials. I was just too lazy to write it
_walrus
_walrus
"That''s more or less how it is done in NeHe''s tutorials. I was just too lazy to write it "

Sorry I didn''t even realized u had posted, it was a few minutes from the time i hit the reply button to the time i sent the message, so i didn''t see your post up there. I''ll have to type faster next time

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.