Sign in to follow this  

OGL nOOb questions.

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

First of all hello. I have just started learning OGL and have some questions thus far. Here it goes: The redbook has a functions init and a display. What are they both do exactly? I mean I understand from what I see that the init initializes the OGL and that display puts models on the screen but in other examples the init and display have the same code again. In other words what EXACTLY should I put in the INIT function and what in the DISPLAY?

Share this post


Link to post
Share on other sites
During the initiation phase of your application should be things like :

glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ) ;
glClearDepth( 100.0f ) ;

glEnable( GL_POLYGON_SMOOTH ) ;
glEnable( GL_DEPTH_TEST ) ;

glDepthFunc( GL_LEQUAL ) ;

And during the display/rendering/output phase of your OpenGL program should be something like :

static GLfloat fColors[][3] = { { 1.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f } } ;
static GLfloat fVertices[][3] = { { -1.0f, 0.0f, 0.0f },
{ 1.0f, 0.0f, 0.0f },
{ 0.0f, 2.0f, 0.0f } } ;
static GLuint uiIndices[3] = { 0, 1, 2 } ;

glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
glLoadIdentity( ) ;

glEnableClientState( GL_COLOR_ARRAY ) ;
glEnableClientState( GL_VERTEX_ARRAY ) ;

glColorPointer( 3, GL_FLOAT, 0, (GLvoid*)&fColors[0] ) ;
glVertexPointer( 3, GL_FLOAT, 0, (GLvoid*)&fVertices[0] ) ;

glDrawElements( GL_TRIANGLES, 3, GL_UNSIGNED_INT, (GLvoid*)&uiIndices[0] ) ;

glDisableClientState( GL_VERTEX_ARRAY ) ;
glDisableClientState( GL_COLOR_ARRAY ) ;

Share this post


Link to post
Share on other sites
Is it possible to state the steps in every function. I mean Init(): Color, Cameras etc, the same for the display. I have an idea how it is but I just want to be sure that it is the correct idea.

Share this post


Link to post
Share on other sites
::sigh::

Initiate() ;

while(1) // Game loop
{

ProcessInput() ;
ProcessAI() ;
DoPhysicsCalculation() ;
Render() ;
}

Now with the above code. Why would you want to 'merge' Initiate() with Render() ? Think about it. You're going to be initiating the data every frame. You don't want that.

Share this post


Link to post
Share on other sites

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