OGL nOOb questions.

Started by
4 comments, last by Khaosifix 19 years, 4 months ago
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?
Advertisement
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 ) ;
---http://www.michaelbolton.comI constantly dream about Michael Bolton.
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.
start a small program and TRY. that's the best method to find out if you are right or wrong. it's also the method from which you'll learn the most.
Now get down on your hands and knees and start repeating "Open Source Good, M$ Evil", smacking your head against the pavement after each repetition. Once you have completed your training you may change your first name to GNU/, to show that you are free from the slavery of the closed source world. -Michalson
Just to ask. Can I assume that the init() function is starting the scene with default options? Could I merge the Init function with the display?
::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.
---http://www.michaelbolton.comI constantly dream about Michael Bolton.

This topic is closed to new replies.

Advertisement