Hey I'm new to the threads, but I thought you guys could help me. I'm trying to build a very basic room in openGL given that I know the 8 points (the corners of the room). I'm a great deal off from being done, but I'm receiving the following error a few time:

error C2664: 'glVertex3f' : cannot convert parameter 1 from 'float (void)' to 'float'
Context does not allow for disambiguation of overloaded function

Here's the code. Thanks!

//Builds a room in openGL from a set of coordinates

#include <GL/gl.h>
#include <GL/glut.h>
#include <iostream.h>
#include <string.h>

class Point {
    GLfloat xcoord, ycoord, zcoord;
    void setVals (float, float, float);
    void buildWall (void);
    float giveX (void);
    float giveY (void);
    float giveZ (void);

class Wall {
    Point pA, pB, pC, pD;
    void setPoints (Point, Point, Point, Point);
    void buildWall (void);

void Point::setVals (float x, float y, float z){
    xcoord = x;
    ycoord = y;
    zcoord = z;

float Point::giveX (void){
    return xcoord;

float Point::giveY (void){
    return ycoord;

float Point::giveZ (void){
    return zcoord;

void Wall::setPoints (Point cornA, Point cornB, 
                      Point cornC, Point cornD){
    pA = cornA;
    pB = cornB;
    pC = cornC;
    pD = cornD;

void Wall::buildWall (void){
    glBegin(GL_QUADS); //begin the shape

    glVertex3f(pA.giveX, pA.giveY, pA.giveZ);
    glVertex3f(pB.giveX, pB.giveY, pB.giveZ); 
    glVertex3f(pC.giveX, pC.giveY, pC.giveZ); 
    glVertex3f(pD.giveX, pD.giveY, pD.giveZ);
    glEnd(); //end the shape

Point corn0;
Point corn1;
Point corn2;
Point corn3;
Point corn4;
Point corn5;
Point corn6;
Point corn7;
Wall wall0;
Wall wall1;
Wall wall2;
Wall wall3;
Wall wall4;

void display (void) {
    glClearColor (0.0,0.0,0.0,1.0);
    glClear (GL_COLOR_BUFFER_BIT);
    gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

    //back wall
    wall1.setPoints(corn0, corn1, corn2, corn3);


//openGL stuff
void reshape (int w, int h) {
    glViewport (0, 0, (GLsizei)w, (GLsizei)h);
    glMatrixMode (GL_PROJECTION);
    glLoadIdentity ();
    gluPerspective (60, (GLfloat)w / (GLfloat)h, 1.0, 100.0);
    glMatrixMode (GL_MODELVIEW);

int main (int argc, char **argv) {
    corn0.setVals (-2.0, 2.0, -2.0);
    corn1.setVals (2.0, 2.0, -2.0);
    corn2.setVals (2.0, -2.0, -2.0);
    corn3.setVals (-2.0, -2.0, -2.0);
    corn4.setVals (-2.0, 2.0, 2.0);
    corn5.setVals (2.0, 2.0, 2.0);
    corn6.setVals (2.0, -2.0, 2.0);
    corn7.setVals (-2.0, -2.0, 2.0);
    glutInit (&argc, argv);

    //builds walls
    glutInitDisplayMode (GLUT_SINGLE);

    glutInitWindowSize (500, 500);
    glutInitWindowPosition (100, 100);
    glutCreateWindow ("A basic OpenGL Window");
    glutDisplayFunc (display);
    glutReshapeFunc (reshape);
    glutMainLoop ();
    return 0;

Recommended Answers

All 4 Replies

This is passing several functions to glVertex3f:

glVertex3f(pA.giveX, pA.giveY, pA.giveZ);

This is calling several functions and passing the return values to glVertex3f:

glVertex3f(pA.giveX(), pA.giveY(), pA.giveZ());

The error is telling you that you are attempting to pass a pointer to a function, and the 1st parameter is supposed to be a float. Maybe you meant to code like this so that it calls giveX() which returns the float.

glVertex3f(pA.giveX(), pA.giveY(), pA.giveZ());

[edit]Sorry Dave -- I didn't see your answer.[/edit]

Excellent! I knew it was something simple like that, but I just kept missing. Problem solved! Thanks guys!

Ahhh, fergitit.... ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.