hey there…
it’s with glVertex3fv…
as you see there are point class and main… and in main i’m trying to draw a simple polygon…
now when i call glVretex3fv( anyPoint.getcoord() ) the polygon deforms ( stretched from the right too much and takes a triangular shape on the left side )…
but replacing glVertex3fv with glVertex3f works fine… like glVertex3f( anypoint.getX(), anypoint.getY(), anypoint.getZ() )…
this problem happened only with me ( the same code works correctly on other computers ) so may be you won’t be able to see what’s really going on…
here’s the code …
point.h
#pragma once
class Point
{
private:
float x, y, z;
public:
void initialize (float x, float y, float z);
Point(float x, float y, float z);
Point(void);
~Point(void);
void setX(float x) { this->x = x; }
void setY(float y) { this->y = y; }
void setZ(float z) { this->z = z; }
void setCoord(float x, float y,float z) { this->x = x; this->y = y; this->z = z; }
void setCoord(float coord[] ) { this->x = coord[0]; this->y = coord[1]; this->z = coord[2]; }
float getX() { return this->x; }
float getY() { return this->y; }
float getZ() { return this->z; }
float* getCoord() { float coord [] = {this->x, this->y, this->z}; return (coord);}
};
point.cpp
#include "Point.h"
void Point::initialize (float x, float y, float z)
{
this->x = x;
this->y = y;
this->z = z;
}
Point::Point(float x, float y, float z)
{
this->initialize (x, y, z);
}
Point::Point(void)
{
this->initialize (0, 0, 0);
}
Point::~Point(void)
{
}
main.cpp
#include <GL/glut.h>
#include "point.h"
Point bl(-1,-1,-1);
Point br(1,-1,-1);
Point tr(1,1,-1);
Point tl(-1,1,-1);
void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glClearDepth (1);
glEnable (GL_DEPTH_TEST);
glShadeModel(GL_FLAT);
}
void display(void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0,0,-2);
glBegin(GL_QUADS);
glVertex3fv( bl.getCoord() );
glVertex3fv( br.getCoord() );
glVertex3fv( tr.getCoord() );
glVertex3fv( tl.getCoord() );
glEnd();
glFlush();
glutSwapBuffers();
}
void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective (60, (float)w/(float)h, 1, 100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0,1,0,0,0,0,0,1,0);
}
void main(int argc, char** argv)
{
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize (1200, 700);
glutInitWindowPosition (50, 50);
glutCreateWindow (argv[0]);
init ();
glutDisplayFunc (display);
glutReshapeFunc (reshape);
glutMainLoop();
}
i’m using visual studio 2008 …but i don’t know how to discover the OpenGl version i’m working with…