PDA

View Full Version : Can't build red book source code ?!



gilley
11-04-2015, 04:54 PM
Are red book source codes legit and checked ?

Becouse I get a lot of errors when I try to compile them and codes from other souces mostly work.

GClements
11-04-2015, 08:41 PM
What errors?

The red book example code found here (https://www.opengl.org/archives/resources/code/samples/redbook.zip) compiles fine (some of the GLU examples generate warnings due to incorrect types for callback pointer, but that's all).

gilley
11-05-2015, 12:56 AM
Maybe I didn't install it correctly after all. When I download source code from link you gave me and type in terminal:


gcc aaindex.c -o test -lglut -lGLU -lGL


i get this


freeglut (./test): ERROR: Internal error <FBConfig with necessary capabilities not found> in function fgOpenWindow


but this source code for example works well



#include "GL/freeglut.h"
#include "GL/gl.h"
#include <iostream>
/* display function - code from:

This is the actual usage of the OpenGL library.
The following code is the same for any platform */
void renderFunction()
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
glBegin(GL_POLYGON);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd();
glFlush();
}

/* Main method - main entry point of application
the freeglut library does the window creation work for us,
regardless of the platform. */
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE);
glutInitWindowSize(500,500);
glutInitWindowPosition(100,100);
glutCreateWindow("OpenGL - First window demo");
glutDisplayFunc(renderFunction);
glutMainLoop();
return 0;
}

btw not sure if it is important, my os is linux mint 17.2

GClements
11-05-2015, 05:21 AM
Maybe I didn't install it correctly after all. When I download source code from link you gave me and type in terminal:


gcc aaindex.c -o test -lglut -lGLU -lGL


i get this



freeglut (./test): ERROR: Internal error <FBConfig with necessary capabilities not found> in function fgOpenWindow

I'd be very surprised if you can get that error just from compiling it.

But I wouldn't be at all surprised if you got that from running that particular program on any system which was made within the last twenty years. The aaindex demo requires an indexed-colour mode (i.e. 256 colours, with a palette):


glutInitDisplayMode (GLUT_SINGLE | GLUT_INDEX);

and those aren't exactly common nowadays. Even if the hardware and X server supports such a mode, it won't be the default, and I wouldn't necessarily expect it to support OpenGL in that mode.

I'd expect the same issue for fogindex.c, which also uses indexed-colour. There may be a couple of other programs using features which aren't likely to be supported by the default configuration of a modern system. But most of them should work fine. It's perhaps a bit unfortunate that one of two programs with that issue happens to be the first one alphabetically.

gilley
11-05-2015, 03:58 PM
First I would like to thank you for taking some of your time to reply to this.

I tried to compile second one and it works fine.

I still have one more question, which edition of red book is this ? The one I have has triangless.cpp for the first example, and I can't find that source code in here. I am asking becouse I would like to learn from the same book these source codes came from so I can have better experience.


Once again thank you.

GClements
11-05-2015, 08:05 PM
which edition of red book is this ?

That version is from here (https://www.opengl.org/archives/resources/code/samples/redbook/), which says


Code Samples released by SGI with the OpenGL 1.1 distribution in 1997.

So I'd assume that corresponds to the first edition, which can be found online here (http://www.glprogramming.com/red/).

This site (http://www.opengl-redbook.com/) has a link to "most of" the code for the 8th edition, which covers OpenGL 4.3.

So much changed between OpenGL 1.1 and 4.3 that they have almost nothing in common.