Error in GLUT Examples

Hey there,

I just tried out some of the GLUT Examples and everything works fine except of the .OBJ Loader.

When I compile them on my Linux Mint Debian Edition
I get an error. Does anyone know what I’m doing wrong?
I installed freeglut3 and freeglut3-dev and removed #include <windows.h>

Here is the link to the file: OpenGL GLUT OBJ Loader

$> g++ -Wall -lGL -l GLU -lglut -O loadertest2.c

loadertest2.c:55: error: extra qualification ‘Model_OBJ::’ on member ‘calculateNormal’
loadertest2.c:56: error: extra qualification ‘Model_OBJ::’ on member ‘Load’
loadertest2.c:57: error: extra qualification ‘Model_OBJ::’ on member ‘Draw’
loadertest2.c:58: error: extra qualification ‘Model_OBJ::’ on member ‘Release’
loadertest2.c: In member function ‘float* Model_OBJ::calculateNormal(float*, float*, float*)’:
loadertest2.c:99: warning: address of local variable ‘norm’ returned
loadertest2.c: In function ‘int main(int, char**)’:
loadertest2.c:292: warning: deprecated conversion from string constant to ‘char*’
loadertest2.c:306: warning: deprecated conversion from string constant to ‘char*’

Help would be great guys.
Cheers the Captain

Change this:

class Model_OBJ
{
  public: 
	Model_OBJ();			
    float* Model_OBJ::calculateNormal(float* coord1,float* coord2,float* coord3 );
    int Model_OBJ::Load(char *filename);	// Loads the model
	void Model_OBJ::Draw();					// Draws the model on the screen
	void Model_OBJ::Release();				// Release the model
 
	float* normals;							// Stores the normals
    float* Faces_Triangles;					// Stores the triangles
	float* vertexBuffer;					// Stores the points which make the object
	long TotalConnectedPoints;				// Stores the total number of connected verteces
	long TotalConnectedTriangles;			// Stores the total number of connected triangles
 
};

Into this:

class Model_OBJ
{
  public: 
	Model_OBJ();			
    float* calculateNormal(float* coord1,float* coord2,float* coord3 );
    int Load(char *filename);	// Loads the model
	void Draw();					// Draws the model on the screen
	void Release();				// Release the model
 
	float* normals;							// Stores the normals
    float* Faces_Triangles;					// Stores the triangles
	float* vertexBuffer;					// Stores the points which make the object
	long TotalConnectedPoints;				// Stores the total number of connected verteces
	long TotalConnectedTriangles;			// Stores the total number of connected triangles
 
};

And it should work. The problem is that the code uses syntax that is not allowed in C++, but was accepted in earlier versions of GCC. Also, the normal calculation function seems to return a pointer to a local variable, which results in undefined behaviour. An easy fix would be to replace in the calculateNormal function float norm[3]; with float *norm = new float[3]; and then make sure to delete[] all the pointers returned by the function.

Why do you refer to those examples as “the” GLUT examples? Do these demos have any kind of official status? The code seems outdated and in many cases limited, both in functionality and also to C++/MS Windows (real OpenGL examples go beyond that). Several demos need external files (models, textures) that are not included.

As far as I can see this is a small package of examples that should have no status as “the” examples but are rather a first version that could use some more work (fixing limitations, porting to several languages, adding data files, removing OS specific stuff, converting to non-deprecated code). I like all OpenGL examples but these are not the best I’ve seen.