1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
void DrawGLScene()
{
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); // Clear The Screen And The Depth Buffer
glLoadIdentity(); // Reset The View
glTranslatef(0.0f,0.0f,-6.0f); // Draw the pyramid in the middle of the screen
glRotatef(rtri,0.0f,1.0f,0.0f); // Rotate The Pyramid On The Y axis
glRotatef(rtri,1.0f,0.0f,0.0f); // Rotate The Pyramid On The x axis
// draw a pyramid (in smooth coloring mode)
glBegin(GL_TRIANGLES); // start drawing a pyramid
// front face of pyramid
glColor3f(1.0f,0.0f,0.0f); // Set The Color To Red
glVertex3f(p1->getPos(0),p1->getPos(1) ,p1->getPos(2)); // Top of triangle (front)
glVertex3f(p2->getPos(0),p2->getPos(1),p2->getPos(2)); // left of triangle (front)
glVertex3f(p3->getPos(0),p3->getPos(1),p3->getPos(2)); // right of traingle (front)
// right face of pyramid
glColor3f(0.0f,1.0f,0.0f); // Red
glVertex3f(p1->getPos(0),p1->getPos(1) ,p1->getPos(2)); // Top Of Triangle (Right)
glVertex3f(p3->getPos(0),p3->getPos(1) ,p3->getPos(2)); // Left Of Triangle (Right)
glVertex3f(p4->getPos(0),p4->getPos(1) ,p4->getPos(2)); // Right Of Triangle (Right)
// left face of pyramid.
glColor3f(0.0f,0.0f,1.0f); // Red
glVertex3f(p1->getPos(0),p1->getPos(1) ,p1->getPos(2)); // Top Of Triangle (Left)
glVertex3f(p4->getPos(0),p4->getPos(1) ,p4->getPos(2)); // Left Of Triangle (Left)
glVertex3f(p2->getPos(0),p2->getPos(1) ,p2->getPos(2)); // Right Of Triangle (Left)
// base face of pyramid
glColor3f(0.5f,0.5f,0.5f); // grey
glVertex3f(p2->getPos(0),p2->getPos(1) ,p2->getPos(2));
glVertex3f(p3->getPos(0),p3->getPos(1) ,p3->getPos(2));
glVertex3f(p4->getPos(0),p4->getPos(1) ,p4->getPos(2));
glEnd(); // Done Drawing The Pyramid
if (!p1->check() || !p2->check() || !p3->check() || !p4->check()){
p1->resetForce();
p2->resetForce();
p3->resetForce();
p4->resetForce();
p1->computeForce();
p2->computeForce();
p3->computeForce();
p4->computeForce();
bindToText();
initFBO();
performComputation();
transferFromTexture(data,0);
transferFromTexture(data2,1);
transferFromTexture(force,2);
setParticle();
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT, target, 0, 0);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT1_EXT, target, 0, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
// swap the buffers to display, since float buffering is used.
glutSwapBuffers();
} |
Partager