recommended opengl book

I was reading the Red Book and I am very dissappointed in it.

It has countless syntax errors, suggests wrong numbers (coordinates), wrong functions used in the wrong situation (in my previous post the code didnt work because they said to use glFrustum, I replaced that with glOrtho and then I got my 3d cueb back, although no scaling…

Therefore I am searching for a better OpenGL book without syntax errors, good examples (full examples)
that also treats everything (including display lists)

NeHe’s and GameTutorial.com’s tutorials are good, but I prefer to learn opengl in its entirety forst wit ha good book.

Many thanks in advance, any help is welcome :slight_smile:

What version of the red book do you have? Perhaps you would be kind enough to post some of the code from the book that was in error. I have version 1.1 (its in complete tatters from use), and I wouldn’t trade it for all the tea in China.
I can’t think of a better OpenGL reference than the red/blue duo.

I too got the 1.1

chapter 2:
coordinates to draw a 3d cube:

static GLfloat intertwined[] =
      {1.0, 0.2, 1.0, 100.0, 100.0, 0.0,
       1.0, 0.2, 0.2, 0.0, 200.0, 0.0,
       1.0, 1.0, 0.2, 100.0, 300.0, 0.0,
       0.2, 1.0, 0.2, 200.0, 300.0, 0.0,
       0.2, 1.0, 1.0, 300.0, 200.0, 0.0,
       0.2, 0.2, 1.0, 200.0, 100.0, 0.0};

this gives me a weird construct

I had to alter it to this:

static GLfloat intertwined[] =
      {0.3, 0.2, 0.1, 80.0, 320.0, 0.0,
       1.0, 0.2, 1.0, 180.0, 320.0, 0.0,
       1.0, 0.2, 0.2, 180.0, 430.0, 0.0,
       1.0, 1.0, 0.2, 80.0, 430.0, 0.0,
       0.2, 1.0, 0.2, 100.0, 300.0, 0.0,
       0.2, 1.0, 1.0, 200.0, 300.0, 0.0,
       0.2, 0.2, 1.0, 200.0, 400.0, 0.0,
       0.45, 0.02, 0.65, 100.0, 400.0, 0.0 
       };

chapter 2:

Example 2-16 : Single Subdivision 

void drawtriangle(float *v1, float *v2, float *v3) 
{ 
   glBegin(GL_TRIANGLES); 
      glNormal3fv(v1); vlVertex3fv(v1);    
      glNormal3fv(v2); vlVertex3fv(v2);    
      glNormal3fv(v3); vlVertex3fv(v3);    
   glEnd(); 

vl must be gl

chapter 3:

Example 3-1 : Transformed Cube: cube.c 

#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>

void init(void) 
{
   glClearColor (0.0, 0.0, 0.0, 0.0);
   glShadeModel (GL_FLAT);
}

void display(void)
{
   glClear (GL_COLOR_BUFFER_BIT);
   glColor3f (1.0, 1.0, 1.0);
   glLoadIdentity ();             /* clear the matrix */
           /* viewing transformation  */
   gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
   glScalef (1.0, 2.0, 1.0);      /* modeling transformation */ 
   glutWireCube (1.0);
   glFlush ();
}

void reshape (int w, int h)
{
   glViewport (0, 0, (GLsizei) w, (GLsizei) h); 
   glMatrixMode (GL_PROJECTION);
   glLoadIdentity ();
   glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0);
   glMatrixMode (GL_MODELVIEW);
}

int main(int argc, char** argv)
{
   glutInit(&argc, argv);
   glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
   glutInitWindowSize (500, 500); 
   glutInitWindowPosition (100, 100);
   glutCreateWindow (argv[0]);
   init ();
   glutDisplayFunc(display); 
   glutReshapeFunc(reshape);
   glutMainLoop();
   return 0;
}

I used parts of this code because I dont use glut but SDL and replaced the wiredCube with the correct code for drawing a 3d cube I posted above.
result: black screen.

when I commented gluLookAt, glScalef and replaced glFrustum with glOrtho, I finaly got my cube back, of course without scaling

chapter 2: draw an icosahedron (or whatever that was)

I had a proepr working window, all my other objects where properly drawn, so I inserted the following code:

#define X .525731112119133606
#define Z .850650808352039932

static GLfloat vdata[12][3] = {   
   {-X, 0.0, Z}, {X, 0.0, Z}, {-X, 0.0, -Z}, {X, 0.0, -Z},   
   {0.0, Z, X}, {0.0, Z, -X}, {0.0, -Z, X}, {0.0, -Z, -X},   
   {Z, X, 0.0}, {-Z, X, 0.0}, {Z, -X, 0.0}, {-Z, -X, 0.0}
};
static GLuint tindices[20][3] = {
   {0,4,1}, {0,9,4}, {9,5,4}, {4,5,8}, {4,8,1},   
   {8,10,1}, {8,3,10}, {5,3,8}, {5,2,3}, {2,7,3},   
   {7,10,3}, {7,6,10}, {7,11,6}, {11,0,6}, {0,1,6},
   {6,1,10}, {9,0,11}, {9,11,2}, {9,2,5}, {7,2,11} };
int i;

glBegin(GL_TRIANGLES);   
for (i = 0; i < 20; i++) {   
   /* color information here */
   glVertex3fv(&vdata[tindices[i][0]][0]);
   glVertex3fv(&vdata[tindices[i][1]][0]);
   glVertex3fv(&vdata[tindices[i][2]][0]);
}
glEnd(); 

result:
everything was drawn except this new object.
Plus I donw see how something can appear on my screen if one of the x coordinates is -X and the lower left corner of the screen = (0,0)

Okay, in the first example I can see nothing wrong with the intertwined array, it’s simply a 6 sided poly in the xy plane, mixing colors and positions. Second example is a typo, and many books are replete with these to be sure. And as for the third, I just built the cube demo you posted and it works as expected.

I don’t know what to tell you. If you are looking for a book with no typos in it, and lots of heavy weight application code, you will have empty book shelves. :slight_smile:

Hi, i believe the red and blue book combo to be the best, i think most developers would agree. there are other books out there that i have also got and used, but as a programming reference i recommend only these two books, others have a habit of being a bit too specific!

Hey… where can i buy those books? red and blue dont really help i dont think. can i plase get a name and author? thanks

OpenGL Superbible, Richard S. Wright and Michael Sweet, a reference mostly and a bit more
BOOK AT AMAZON

Interactive computer graphics, a top down approach
BOOK AT AMAZON

I also use shaders a lot, so the other texts i use are around these areas and general 3d graphics books not specific to GL