Nobody? Please, help me! So I use freeglut. I have this class
class PlayerClass
{
public:
int x, y, z, xzdir = 0, ydir = 0;
PlayerClass(int _x, int _y, int _z)
{
x = _x;
y = _y;
z = _z;
}
void FirstPerson(int _x, int _y)
{
glutWarpPointer(glutGet(GLUT_WINDOW_WIDTH)/2, glutGet(GLUT_WINDOW_HEIGHT)/2);
xzdir += (glutGet(GLUT_WINDOW_WIDTH)/2 - _x)/8;
ydir += (glutGet(GLUT_WINDOW_HEIGHT)/2 - _y)/8;
if(xzdir > 360) xzdir -= 360;
if(xzdir < 0) xzdir += 360;
if(ydir > 90) ydir = 90; else if(ydir < -90) ydir = -90;
Display();
cout << "xzdir: " << xzdir << endl << "ydir: " << ydir << endl;
gluLookAt(x, 1.0f, z,
x + sin(degtorad(xzdir)),
1.0f,
z - cos(degtorad(xzdir)), 0, 1, 0);
cout << x + sin(degtorad(xzdir));
}
void FPRender()
{
gluLookAt(x, y + 32, z,
x + sin(degtorad(xzdir)),
1,
z - cos(degtorad(xzdir)), 0, 1, 0);
cout << x + sin(degtorad(xzdir));
}
};
Here I call it:
#ifndef BASEFUNCT_H_INCLUDED
#define BASEFUNCT_H_INCLUDED
#include <iostream>
#include <windows.h>
#include <stdlib.h>
#include <GL/glew.h>
//#include <GL/eglew.h>
#include <GL/freeglut.h>
void Frame();
PlayerClass Player(-2, 1, 2);
void pyramid()
{
glBegin( GL_TRIANGLES );
glColor3f( 1.0f, 0.0f, 0.0f ); glVertex3f( 0.0f, 1.f, 0.0f );
glColor3f( 0.0f, 1.0f, 0.0f ); glVertex3f( -1.0f, -1.0f, 1.0f );
glColor3f( 0.0f, 0.0f, 1.0f ); glVertex3f( 1.0f, -1.0f, 1.0f);
glColor3f( 1.0f, 0.0f, 0.0f ); glVertex3f( 0.0f, 1.0f, 0.0f);
glColor3f( 0.0f, 1.0f, 0.0f ); glVertex3f( -1.0f, -1.0f, 1.0f);
glColor3f( 0.0f, 0.0f, 1.0f ); glVertex3f( 0.0f, -1.0f, -1.0f);
glColor3f( 1.0f, 0.0f, 0.0f ); glVertex3f( 0.0f, 1.0f, 0.0f);
glColor3f( 0.0f, 1.0f, 0.0f ); glVertex3f( 0.0f, -1.0f, -1.0f);
glColor3f( 0.0f, 0.0f, 1.0f ); glVertex3f( 1.0f, -1.0f, 1.0f);
glColor3f( 1.0f, 0.0f, 0.0f ); glVertex3f( -1.0f, -1.0f, 1.0f);
glColor3f( 0.0f, 1.0f, 0.0f ); glVertex3f( 0.0f, -1.0f, -1.0f);
glColor3f( 0.0f, 0.0f, 1.0f ); glVertex3f( 1.0f, -1.0f, 1.0f);
glEnd();
}
int x1, y1;
void PassiveMouse(int x, int y)
{
x1 = x;
y1 = y;
}
void Display(void)
{
//Clear information from last draw
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
Player.FPRender();
glColor3f(1, 0, 0);
glBegin(GL_QUADS);
glVertex3f(-100.0f, 0.0f, -100.0f);
glVertex3f(-100.0f, 0.0f, 100.0f);
glVertex3f( 100.0f, 0.0f, 100.0f);
glVertex3f( 100.0f, 0.0f, -100.0f);
glEnd();
glutSwapBuffers();
//Player.FPRender();
//glTranslated(Player.x, Player.y, Player.z); //location of the pyramid
//pyramid(); // call out rutine to draw a pyramid
//cout << "Display - working
";
//Sleep(500);
}
void Keyboard(unsigned char key, int x, int y)
{
switch(key)
{
case 27: exit(0); break;
default: break;
}
//Frame();
}
void Frame()
{
Player.FirstPerson(x1, y1);
}
#endif // BASEFUNCT_H_INCLUDED
But if I disable it… it draw the pyramid, but when I activate it, I cant see my drawing. The debug values are perfect…