Matt
Matt

Reputation: 145

Opengl - GLfloat not being recognized

Having some trouble with this class declaration, Im trying to create nodes for an openGL implementation of Dijktra's shortest path algorithm. the getX(), getY(), getZ() methods cause an error:

error: ISO C++ forbids declaration of ‘getX’ with no type

Im compiling with g++ on ubuntu linux. Command: g++ -lglut -lGLU -lGL projecttest.c

#include <cstdarg>
#include <cstdio>
#include <GL/glut.h>
#include <GL/glu.h>
#include <cstdlib> 
#include <iostream>
#define kWindowWidth 800
#define kWindowHeight 600 
#define NUM_NODES 3

using namespace std;

class Node {
    private: 
        GLfloat x, y, z;
        int numLinks;
        Node *links[];
    public: 
        Node(GLfloat x, GLfloat y, ...);
        ~Node();
        GLfloat getX();
        GLfloat getY();
        GLfloat getZ() {return 0.0f;}
} Node;

Node nodes_g[NUM_NODES];

I think the problem is in the preprocessor macros. Im new to openGL and somewhat new to c++ so any advice is good, but what I really want to know is why im getting the error.

Upvotes: 3

Views: 7386

Answers (2)

fintelia
fintelia

Reputation: 1211

If you have

#include <GL/glut.h>

Then you should not need GL/gl.h or GL/glu.h, although you may have to put cstdlib before GL/glut.h

Upvotes: 0

Ben Voigt
Ben Voigt

Reputation: 283863

You need

#include <GL/gl.h>

before including headers for OpenGL extensions.

Upvotes: 8

Related Questions