Skip to main content
GameDev.net gamedev.net

PRO Tired of ads? Read GameDev.net ad-free and help keep the community independent with GameDev Pro — $3/month.

Math, states, primitives, Photoworks, and XML

Math, states, primitives, Photoworks, and XML

rmckee78
The ballad of a n00b · · 4 min read
1,023 3
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.

Discussion

Loading comments...