开发者

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: IS开发者_StackOverflowO 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.


You need

#include <GL/gl.h>

before including headers for OpenGL extensions.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜