Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Error in GLUT Examples

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2011
    Location
    Germany
    Posts
    4

    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

  2. #2
    Intern Contributor
    Join Date
    Sep 2010
    Posts
    74

    Re: Error in GLUT Examples

    Change this:
    Code :
    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:
    Code :
    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.

  3. #3
    Intern Newbie
    Join Date
    Jan 2010
    Location
    Linköping, Sweden
    Posts
    46

    Re: Error in GLUT Examples

    Quote Originally Posted by Captain Cook
    I just tried out some of the GLUT Examples and everything works fine except of the .OBJ Loader.
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •