window setup and render, the basic and how to learn them?

Started by
12 comments, last by snowfell 15 years, 9 months ago
I have a major question here guys and I really need help with it before I can move on. I have a basic C++ understanding and I just bought a opengl book. The problem is that I am having a huge issue understanding what the heck to do. I have spent some time with GLUT so I understand pretty much everything besides window setup. The book I own is Beginning OpenGL Game Programming by Dave Astle and Kevin Hawkins. It was highly recommended to me so I got it. The problem is it seems really complicated. As a noob to opengl is this normal? I was wondering if I could get some tips or something to help me get on the right track. The problem I see with this book is that they only describe 1 out of 12 codes and except you to know the rest. If their is anything I should know or learn please give me a heads up. Thanks [Edited by - snowfell on June 23, 2008 3:50:38 PM]
Advertisement
When I originally got into OpenGL it took me a while, but what really got me through is the amount of resources online which talk about how to use it. Below are a few resources I used to get me going.

http://nehe.gamedev.net/
http://www.lighthouse3d.com
The forums on this website. :P

Since your just getting into everything GLUT is the best start for getting your environment set up, it's simple in syntax and there are plenty of examples online about how to use it.

I hope this helps.
- Kiro
Yeah this is normal.
Learning OpenGL is not a walk in the park.
If you learned a simpler 2D API like Allegro or SDL it'd make a lot more sense and click alot faster since you would already have the basic game loop and timing down,etc and only the 3D stuff would be new.

[size="2"]Don't talk about writing games, don't write design docs, don't spend your time on web boards. Sit in your house write 20 games when you complete them you will either want to do it the rest of your life or not * Andre Lamothe
well I am glad I am not the only one. But guys what are the bare bone things that keep opengl running. Like if a very basic opengl app was split down into pieces, what would they be. Like how do u split up everything into window creation, rendering, timing, and everything else. Let just say I am mostly confused on what is needed to run a opengl app like this.
The next book you should buy is The Red Book, otherwise known as the OpenGL Programming Guide, The Official Guide to Learning OpenGL, Version <latest>.

It contains all the opengl calls and good descriptions of them. There are good examples, starting from "draw a triangle" and continuing. My copy is dog-eared and ragged, with written remarks in the columns and scotch-tape tabs, etc., etc.

It's the "Bible" of OpenGL.

GLUT helps to keep your attention focused on the basics without worrying about how to get a window built, how to get keyboard input, etc.

Once you get some of the basics and have confidence you know how to draw some basic shapes, learn how to create your own window and use the window procedure for input.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Quote:Original post by snowfell
well I am glad I am not the only one. But guys what are the bare bone things that keep opengl running. Like if a very basic opengl app was split down into pieces, what would they be. Like how do u split up everything into window creation, rendering, timing, and everything else. Let just say I am mostly confused on what is needed to run a opengl app like this.


There are any different ways to break up these aspects of an OpenGL application. Below is some pseudo code that can serve as an example of one way it can be done for a simple application.

int main(int argc, char* argv[]){    //Init GLUT    //Open a GLUT window    //Register you event callbacks with GLUT    //Init anything specific to your game    //Init the game timer with GLUT    //Enter into the GLUT loop    return 0;}void timerHandle(void){   //Do the per frame game logic, update enemies, check game conditions, ect   //Draw the game   //Register the timer again}void keyHandle(char key){  //Check what key this is, then react in the needed way}void closeWindowHandle(){  //Clean up anything specific to your game  //Exit the application  exit(0);}


When the applications starts you set up all the things you need, like a window, your key events, the game timer, ect. Then when you enter into the GLUT main loop your handler functions will be called when the events happen and you react to them as needed.

- Kiro
Ok I completely read through the chapter on window rendering. I understand what is happening during each step but have no idea of what the structure looks like or how to uses what I learned there in my own program. The way the source code is written it very narrow minded and makes it difficult to take things (ideas and such things, not literally taking things) from it. I have a notebook and I filled about 4 pages just from skimming over that chapter.

What I figured out (correct me if I am wrong) about OpenGL structure is that in most cases it is broken down into:
-a function for pixel format
-window procedure
-window main
-enabling OpenGL
-disabling OpenGL

Library's for most OpenGL applications are:
-windows.h (or whatever other platform you use)
-gl.h
-glu.h (not required)

While reading I learned a bit about WGLs but I don't see how they fit into a program. I mean I know that they are used to setup OpenGL on windows with commands like wglCreateContext() but I don't see what to do with it. I know a little bit about rendering context and device context but yet again don't know how to use them in a program.

My question is, now that I have these very bare bone things sorted out what would be the next wise step to adding some function to a very basic OpenGL program.
If you're using windows, read through:

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=01

as mentioned by KiroNeem.

It has a complete setup and explains each step.

As an aside, windows.h, gl.h and glu.h are header files, not libraries. The header files tell the compiler how to format the function calls.

The compiler itself knows nothing about libraries.

The linker takes the compiled code and provides the proper calls to the libraries, which must also be specified in your project properties.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

I'm in the situation as same as you. I read some windows program's source, read some book about windows programming, and I try to write a lot of windows code to understand the windows program how to work, hope this can help you.
So would a quick study of win32 help? All I no is someone told me that win32 was unimportant for opengl. If looking at that may help resolve confusion I guess I will give it a try. Are their any good win32 tutorials or links out there?

This topic is closed to new replies.

Advertisement