Jump to content
  • Advertisement
Sign in to follow this  
snowfell

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

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

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]

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

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!