<br />
#include "stdafx.h"<br />
#include "OpenGl.h"<br />
#include "creatfoufou.h"<br />
#include "foufou.h"<br />
<br />
#include <math.h><br />
<br />
#ifdef _DEBUG<br />
#undef THIS_FILE<br />
static char THIS_FILE[]=__FILE__;<br />
#define new DEBUG_NEW<br />
#endif<br />
<br />
<br />
creatfoufou::creatfoufou()<br />
{<br />
<br />
}<br />
<br />
creatfoufou::~creatfoufou()<br />
{<br />
<br />
}<br />
<br />
void creatfoufou::creatfou(int amount)<br />
{<br />
foufou *newfoufouPtr;<br />
int randomX,randomY,randomZ;<br />
int speed,steer;<br />
<br />
for(int index=0;index<amount;index++)<br />
{<br />
newfoufouPtr = new foufou();<br />
fou_caracter.push_back( newfoufouPtr );<br />
randomX = ( ( 1 + rand( ) % 900 ) - 450 );<br />
randomY = ( ( 1 + rand( ) % 100 ) - 50 );<br />
randomZ = ( ( 1 + rand( ) % 900 ) - 450 );<br />
<br />
setposition(randomX,randomY,randomZ);<br />
<br />
<br />
<br />
}<br />
}<br />
<br />
void creatfoufou::setposition(int newX, int newY, int newZ)<br />
{<br />
-->the mistak RePaint(randomX,randomY,randomZ);<br />
}<br />
and here when i declared
<br />
#include "stdafx.h"<br />
#include "OpenGl.h"<br />
#include "foufou.h"<br />
#include <gl/glut.h><br />
<br />
#ifdef _DEBUG<br />
#undef THIS_FILE<br />
static char THIS_FILE[]=__FILE__;<br />
#define new DEBUG_NEW<br />
#endif<br />
<br />
<br />
foufou::foufou()<br />
{<br />
<br />
}<br />
<br />
foufou::~foufou()<br />
{<br />
<br />
}<br />
<br />
<br />
<br />
GLfloat Material_Ambiante[]={0.5,0.5, 0.5, 1 };<br />
GLfloat Material_Difuse[]={0.5, 0.5, 0.5, 1};<br />
GLfloat Material_Specular[]={0.5, 0.5, 0.5, 1};<br />
<br />
<br />
<br />
<br />
GLfloat Light_Ambiante[]={0.2, 0.2, 0.2, 0.1};<br />
GLfloat Light_Difuse[]={0.5, 0.5, 0.5, 1.0 };<br />
GLfloat Light_Specular[]={1.0, 1.0, 1.1, 1.0 };<br />
GLfloat Light_Position[]={10, 12, 10, 1.0 };<br />
<br />
<br />
<br />
GLfloat Light_Direction[]={0.0,-1.0, 0.0, 1.0};<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
void foufou::Initial()<br />
{<br />
<br />
glMaterialfv( GL_FRONT, GL_AMBIENT, Material_Ambiante);<br />
glMaterialfv( GL_FRONT, GL_DIFFUSE, Material_Difuse);<br />
glMaterialfv( GL_FRONT, GL_SPECULAR,Material_Specular);<br />
glMaterialf( GL_FRONT, GL_SHININESS, 20);<br />
<br />
glLightfv( GL_LIGHT0, GL_AMBIENT,Light_Ambiante );<br />
glLightfv( GL_LIGHT0, GL_DIFFUSE, Light_Difuse );<br />
glLightfv( GL_LIGHT0, GL_SPECULAR, Light_Specular);<br />
glLightfv( GL_LIGHT0, GL_POSITION, Light_Position );<br />
<br />
<br />
<br />
<br />
glEnable( GL_LIGHTING );<br />
<br />
<br />
glEnable( GL_LIGHT0 );<br />
<br />
<br />
<br />
glEnable( GL_DEPTH_TEST );<br />
<br />
};<br />
<br />
void foufou::RePaint(int xpos,int ypos,int zpos)<br />
{<br />
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);<br />
<br />
<br />
glMatrixMode (GL_PROJECTION);<br />
glLoadIdentity ();<br />
<br />
<br />
<br />
gluPerspective (90, 1, 5, 50);<br />
gluLookAt (2,2, -15, -4,0.0, 1, 0.0, 1.0, 0.0 );<br />
<br />
<br />
glPushMatrix();<br />
<br />
<br />
<br />
glColorMaterial( GL_FRONT, GL_AMBIENT );<br />
glColor4f(0.5, 0.5, 0.6, 1.0 );<br />
glColorMaterial( GL_FRONT, GL_DIFFUSE );<br />
glColor4f( 0.5, 0.2, 0.8, 1.0 );<br />
glColorMaterial( GL_FRONT, GL_SPECULAR );<br />
glColor4f( 0.9, 0.8, 1.0, 1.0 );<br />
<br />
<br />
<br />
glTranslated(-xpos, ypos, zpos );<br />
glutSolidSphere(0.9,30,40);<br />
glDisable( GL_LIGHTING );<br />
<br />
glPopMatrix();<br />
<br />
<br />
<br />
<br />
<br />
SwapBuffers(wglGetCurrentDC());<br />
<br />
};<br />
|