Jump to content
  • Advertisement
Sign in to follow this  
3dnoob

OGL nOOb questions.

This topic is 4989 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
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 ) ;

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

Share this post


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

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!