Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Math, states, primitives, Photoworks, and XML

Sign in to follow this  


The weekend was pretty busy but I did manage to get some work in on programming. I moved through chapter 3 of OpenGL Game Programming. This chapter covers some of the mathematics of 3D game programming. It was all pretty standard: vectors, cross product, dot product and matrix transformations. There is so much information available on this that I am not going back through it all here. While I do not know much about 3D programming yet, I assume that this stuff is fundamental. If you are working on learning 3D programming I would make sure that you really understood this before moving on. I have a feeling that 3D programming will require a deeper understanding of math then what is presented in the book, but it at least gives you a primer and an idea what to look for. Don't just read the chapter, draw some shapes on graph paper and rotate, translate, scale etc. them by hand. I cannot imagine being an engineer with out a strong intuitive understanding of calculus, and I imagine that the same holds true for 3D programming and matrix operations.

Chapter 4 covers the OpenGL state machine and graphics primitives. I really think that I am hitting the portion of this book where there just is no best order to explain stuff. Some times a topic involves enough different things that you have to understand a little about one thing so you can learn about a second subject which allows you to be taught more about the first subject. That seems to be the situation in Chapter 4.

Basically the state machine has hundreds of settings that affect how OpenGL renders. The chapter goes over how to query the state machine about the current value of many of these settings.

This is done with a set of functions (all return type void) that accept the name of the setting (type GLenum) and a pointer to an array to hold the information. The different functions just cover different data types (Bool, double, float, and int) that can be held in the array.

There is another query function glIsEnabled() that allows you to see if a flag is set or not on some of the settings.

The chapter doesn't go into much more detail than this on the state machine. I assume this is so we are familiar with it as more information is presented.

Drawing OpenGL primitives follows a fairly simple procedure:

Pass the primitive type to glBegin() (its a void return type)
Set the vertices of the primitive with the glVertex() function (void again)
End the shape with glEnd() (void)

The book does state that there is a limited number of functions that can be used inside the glBegin()/glEnd pair. Using another function will generate an error (I am assuming at compiling, need to test this).

One thing I am trying to look into is what happens if you specify a triangle but only give 2 vertices (or three that are co-linear). Obviously it cannot draw a triangle with this information. However with everything having return type void, how do I handle the error. Perhaps you just have to write error checking code for this one (to make sure they are not co-linear).

The book goes over points, lines, triangles, and quadrilaterals. It also touches on antialiasing, face culling, and edge hiding. I think these were presented more to just define what they are than to actual instruct in their use.

In other programming and 3D related news I have had some stuff come up at work. Just got the PhotoWorks stuff in for SolidWorks. For those of you not familiar with it SolidWorks is a 3D solid modelling design program and PhotoWorks is a fancy renderer for it that lets you apply better textures and lighting to your models. Should be fun to work with. Also it looks like I need to come up with some kind of application to handle a site survey tool we made in house that will (finally) go into use next month. I want to try to integrate the gauge with our total site survey process (can't go into more detail due to legal stuff) in one program. Our systems programmer (very busy lady) suggests that I look into XML to handle the data so some of that might make it into this journal over the next few weeks.

Edit: I went to see Bridge to Terabithia with my wife last night. I loved this book when I was a kid and the movie did a pretty good job with it.
Sign in to follow this  


Recommended Comments

Original post by rmckee78
The book does state that there is a limited number of functions that can be used inside the glBegin()/glEnd pair. Using another function will generate an error (I am assuming at compiling, need to test this).

I'm no OpenGL expert, but it is very doubtful that something like that could be caught as a compiler error, since the compiler cannot have any knowlegde of the foibles of a particular library.

More likely the compiler will cheerfully let you call any gl functions you want between glBegin() and glEnd() and any errors will occur at runtime and need to be explicitly tested for in your code, or avoided in the first place by the programmer.

On another note, you seem to be flying through topics at an extremely impressive rate based on your recent journal posts. Keep it up!

Share this comment

Link to comment
Don't worry too much about glBegin() and glEnd() because you won't be using them anyway if you're keen on getting more than a handful of fps. ;-)

Share this comment

Link to comment
Thanks for the replies.

I must have gone brain dead on the error thing. You are right the compiler would have no idea about OpenGL's rules.

I am hoping to go back and learn a little more about C/C++ Windows programming now. I'd like to learn more about how to build applications with Windows features like scroll bars etc. I did actually mess around with this a few years ago in Python a bit when I was in school for a project but I really don't remember much.

I'm going to go through the (800+ lines) sample code presented at the end of chapter 4. It has some stuff not covered in the book yet so I'll write up on those things. It also seems to have some more error handling in it than the other sample code that will be good to see.

Its good to see that people are checking what a write, really helpful feedback.

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 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!