Setup!

Member
Posts: 102
Joined: 2005.01
Post: #1
can someone explain what this sequince fo commands acually does?

all i know is nehe uses it and it works...

Code:
- (BOOL) initGL
{
   glShadeModel( GL_SMOOTH );
   glClearColor( 0.0f, 0.0f, 0.0f, 0.5f );
   glClearDepth( 1.0f );                  
   glEnable( GL_DEPTH_TEST );      
   glDepthFunc( GL_LEQUAL );          
   glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
  
   return TRUE;
}


and whats a depth test?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
you don't need the glShadeModel call, it does nothing.
you probably don't want the glClearColor call, the default is more useful than what you're setting it to
you don't need the glClearDepth call, it does nothing
you don't need the glHint(GL_PERSPECTIVE_CORRECTION_HINT, ...) call, it does nothing

glEnable(GL_DEPTH_TEST) turns on depth testing, so you can draw 3d objects in any order and they will obscure each other correctly based on distance from the camera
glDepthTest(GL_LEQUAL) says that pixels closer to the camera (Less) or an equal distance to the camera should be in front of existing pixels.
Quote this message in a reply
Member
Posts: 102
Joined: 2005.01
Post: #3
and this enables texture stuff?
glEnable( GL_TEXTURE_2D );
Quote this message in a reply
Moderator
Posts: 613
Joined: 2004.09
Post: #4
Coin Wrote:and this enables texture stuff?
glEnable( GL_TEXTURE_2D );


Its pretty much just telling OpenGL that you are enabling textures and you will be using 2d textures, not 3d textures. 2d textures is what you will want to use most the time especially when first learning OpenGL.
Quote this message in a reply
Member
Posts: 102
Joined: 2005.01
Post: #5
Must...Have...Last....Word..... Thanks.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #6
Not to step on your last word, but sounds to me like you could use the Red Book
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #7
OneSadCookie Wrote:you don't need the glShadeModel call, it does nothing.
To be pedantic, "it does nothing" isn't accurate. It sets the shading model to SMOOTH, just like it says. It so happens that SMOOTH is the default value, so the first time you do this, there is no effect.

But, maybe your app later changes the shading model to FLAT. Then if you call initGL again to re-initialize the state, this does something.

Coin Wrote:and this enables texture stuff?
glEnable( GL_TEXTURE_2D );
This enables application of the currently bound 2D texture during rasterization. There is a good deal of other state that affects this, so you really need to read the manual to understand what's going on.
Quote this message in a reply
Member
Posts: 102
Joined: 2005.01
Post: #8
TomorrowPlusX Wrote:Not to step on your last word, but sounds to me like you could use the Red Book

will this do?
http://www.dei.isep.ipp.pt/cg/ftpdei/cgra/RedBook/
Quote this message in a reply
manatee
Unregistered
 
Post: #9
This looks to be the first edition from OGL 1 published in 1994.

The current printed is much more recent, I think 4th edition, covering additions since 1994, which I would think to be somewhat essential as there have been some changes since 1 to 1.4 ...

What it will do, like any doc, is explain to you systematically the elements of its target content. There is also a Blue Book available which is the corresponding reference manual.

Look through http://www.opengl.org/documentation/index.html

in other words, this is the FM.

manatee
Quote this message in a reply
Moderator
Posts: 522
Joined: 2002.04
Post: #10
For using the Blue Book, there are a couple of things that work well in addition to having a paper copy or pdf. Simply googling for the function, i.e. "glShadeModel" will turn up some reference pages. Alternatively, you could go into the Terminal application and type "man glShadeModel". Or, you could choose the menu item "Open man page..." from the Help menu of Xcode, and type in glShadeModel.

Most of these are faster than futzing with a PDF or a printed copy.

I'd really suggest going through _some_ edition of the Red book, though. At least the beginning parts.

-Jon
Quote this message in a reply
Member
Posts: 102
Joined: 2005.01
Post: #11
ive been using here for reference

http://www.mevis.de/~uwe/opengl/opengl.html
Quote this message in a reply
Moderator
Posts: 613
Joined: 2004.09
Post: #12
Thats a good reference but you really need to read something about fitting it all together. Try NeHe's guides if you cant afford the redbook, but if you have the money i REALLY recommend reading the redbook, its a great source of knowledge.
Quote this message in a reply
Member
Posts: 102
Joined: 2005.01
Post: #13
Ive been using NeHi's tutorials. They always die when i try to go full screen.... makes me sad
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #14
And if you just search the forum you'll find the fix for that.
Quote this message in a reply
Member
Posts: 129
Joined: 2005.02
Post: #15
And why hasn't nehe changed this. Has no one said anything?
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  bug in OpenGL setup for NSOpenGL subclass (I think) backslash 2 3,808 Jul 18, 2007 01:10 PM
Last Post: backslash
  xCode/SDL Setup hammonjj 2 4,834 Mar 2, 2007 06:37 AM
Last Post: hammonjj
  Fullscreen/Window Setup/toggle skyhawk 10 4,972 Oct 13, 2006 04:05 PM
Last Post: skyhawk
  Testing GL Setup Code (Help Wanted) Matrix 8 4,020 Sep 11, 2006 04:06 PM
Last Post: sjstux
  SDL 2D OpenGL setup unknown 13 7,288 Jul 16, 2005 09:07 PM
Last Post: unknown