static void display (void) { GLfloat infinite_light[] = { 1.0, 1.0, 1.0, 0.0 }; GLfloat local_light[] = { 1.0, 1.0, 1.0, 1.0 }; glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix (); glTranslatef (-1.5, 0.0, 0.0); glLightfv (GL_LIGHT0, GL_POSITION, infinite_light); drawPlane (); glPopMatrix (); glPushMatrix (); glTranslatef (1.5, 0.0, 0.0); glLightfv (GL_LIGHT0, GL_POSITION, local_light); drawPlane (); glPopMatrix (); glFlush (); }
void View::paintGL() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); m_camera->loadModelViewMatrix(); drawScene(); if( m_visualHints & VH_ShowAxis ) drawAxis(); if( m_visualHints & VH_ShowPlane ) drawPlane(); }
void WaterSurface::drawForLOD() { glDisable(GL_TEXTURE_2D); glPushMatrix(); glScalef(500.f, 1.f, 500.f); glDisable(GL_CULL_FACE); glColor3f(0.f, 0.f, 1.f); drawPlane(); glEnable(GL_CULL_FACE); glPopMatrix(); glEnable(GL_TEXTURE_2D); }
void* threadHandler(void *threadArgs) { while (true) { // harusnya ini kondisi tertembak coor_y = drawPlane(coor_y,isRight); if(coor_y > (750-size_y*5)-10 && isRight) { isRight = false; } else if(coor_y < 10 && !isRight) { isRight = true; } } return NULL; }
void displayFunction(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); setupCamera(5, 10, 30, 0, 0, 0, 0, 1, 0); glColor3f(0.5, 0.5, 0.5); drawPlane(50.0, 50.0, 20, 20); glColor3f(0.0, 0.0, 0.5); glPushMatrix(); glTranslatef(0,5,0); drawPlane(30.0, 30.0, 100, 100); glPopMatrix(); // check DT (in microsecond) from StopWatch and store it to "deltaTime" (in seconds) deltaTime = myWatch.checkAndComputeDT() / 1000000.0; currentTime = myWatch.getTotalElapsedTime() / 1000000.0; Simulator->actions(deltaTime, currentTime); glutSwapBuffers(); }
// Invoke the drawing of the flight path for flights loaded // and determine the currently being viewed flight void MapWidget::drawMapVis() { // Zero out old paths and plane cause they have been removed from the view if(_plane) delete _plane; _plane = 0; _paths.clear(); // Draw flight paths here int i = 0; for(;i < _loadedFlightsData.size(); i++) { drawFlightPath(_flights[i], i); } // Draw active plane here drawPlane(_activeFlight, _activeFlightIdx); }
/* Fonction qui affiche les objets 3D : plan et/ou (sweep/revolution objet, teapot) Appelee chaque fois que la fenetre du viewer doit etre rafraiche. */ void displayViewerWindow() { /* ** AJOUTER CODE ICI ** ** Cette fonction est appelee a chaque fois que le contexte OpenGL est a rafraichir ** ** -Effacer l'ancien contenu (glClear) ** -Activer la pile GL_PROJECTION et preciser les parametres de projection (gluPerspective + gCam) ** -Activer la pile GL_MODELVIEW et positionner la camera (setCamera) ** -Afficher les lumieres (setLighting + drawLights) ** -Afficher le sol (avec setMaterial + drawPlane()) ** -Afficher l'objet (avec setMaterial +drawObject()) ** */ /* Effacer l'ancien contenu */ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* Configurer une camera (projection perspective) */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(gCam.fovy, gCam.ratio, gCam.znear, gCam.zfar); /* Positionner la camera */ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); setCamera(); /* Afficher les lumieres */ drawLights(); /* Afficher le plan avec le gMaterials[0] */ setMaterial(gMaterials[0]); drawPlane(objectResolution, drawNormals); /* Afficher l'objet avec le gMaterials[1] */ setMaterial(gMaterials[1]); drawObject(); glutSwapBuffers(); }
void myDisplay() { glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); myCam.setGLCamera(); //gluLookAt(0.0, 2.5, 5.0, 0,0,0, 0,1,0); LightPosition(); glDisable(GL_LIGHTING); glLineWidth(1); drawPlane(); glLineWidth(5); drawAxes(); glEnable(GL_LIGHTING); glutSolidTeapot(0.5); glutSwapBuffers(); }
// display. Sets lighting conditions, camera positions... void display(void) { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glLightfv(GL_LIGHT0, GL_POSITION, light_pos); glLightfv(GL_LIGHT0, GL_AMBIENT, amb0 ); glLightfv(GL_LIGHT0, GL_DIFFUSE, diff0); glLightfv(GL_LIGHT0, GL_SPECULAR, spec0); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, m_amb); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, m_diff); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, m_spec); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, m_shiney); glLoadIdentity(); gluLookAt(camera.getX(), camera.getY(), camera.getZ(), 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); drawPlane(); render(); }
void display(void) { glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); glRotatef(spin, 0, 1, 0); aimLights(); setLights(); glPushMatrix(); glRotatef(-90.0, 1, 0, 0); glScalef(1.9, 1.9, 1.0); glTranslatef(-0.5, -0.5, 0.0); drawPlane(16, 16); glPopMatrix(); drawLights(); glPopMatrix(); glutSwapBuffers(); }
void display(void) { glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); glEnable(GL_LIGHTING); initLights(); setLights(); glPushMatrix(); glRotatef(-90.0, 1, 0, 0); glTranslatef(-1, -1, 0.0); drawPlane(200, 200); // xy plane glPopMatrix(); //drawLights(); glPopMatrix(); glutSwapBuffers(); }
int main() { init(); clearscreen(); while(1){ key = kbhit(); if (!key){ coor_y = drawPlane(coor_y,isRight); if(coor_y > (750-size_y*5)-10 && isRight) { isRight = false; } else if(coor_y < 10 && !isRight) { isRight = true; } } else { shoot(); key = 0; getchar(); } } munmap(fbp, screensize); close(fbfd); return 0; }
void BodyBase::draw(BodyState bodyState, bool bFromUpper, float ang) { if (bodyState.state == BodyState::NONE) return; ofPushMatrix(); if (bFromUpper) { ofTranslate(bodyState.curPos - anchor); ofRotateZ((bFromUpper) ? 180 + ang : 0 + ang); } else { ofTranslate(bodyState.curPos); ofRotateZ(ang); ofTranslate(-anchor); } seqTweak.begin(); seqTweak.setUniformTexture("tex0", tweaker.getTexture(), 0); seqTweak.setUniformTexture("blendTex", Globals::bodyBlendTexs.at(bodyState.blendIdx), 1); drawPlane(tweaker.getWidth(), tweaker.getHeight()); seqTweak.end(); ofPopMatrix(); }
void render(const LCamera cam, const LLight lit, FrameBuffer * colorBuff, RENDER_MODE renderingMode, int modelIndex) { colorBuff->clear(); OBJ = MODELS[modelIndex%MODELS.size()]; modelIndex; //model index //integer //-2, -1, 0, 1, 2....initial value:0 vec3 pos,target,up; cam.getVectors(pos, target, up); //cout << pos.n[0] << " " << pos.n[1] << " " << pos.n[2] << endl; // how to use: just like the input of gluLookAt // camera position ( pos.n[0], pos.n[1], pos.n[2] ) initial value: (0,250,0) // camera target (target.n[0], target.n[1],target.n[2] ) initial value: (0,249,0) // camera upVector ( up.n[0], up.n[1], up.n[2] ) initial value: (1,0,0) vec3 lightS; lightS = lit.getPos(); // how to use: it's just a position coordinate // light position ( lightS.n[0], lightS.n[1], lightS.n[2] ) initial value: (100,100,0) //to assign pixel color //cout << colorBuff->getHeight() << " " << colorBuff->getWidth() << endl; //how to use: here is an example /*Color cc; for(int i=0;i<colorBuff->getWidth();i++){ for(int j=0;j<colorBuff->getHeight();j++){ cc.r = rand()%256; cc.g = rand()%256; cc.b = rand()%256; cc.r = 255*i/colorBuff->getWidth(); cc.g = 255*i/colorBuff->getWidth(); cc.b = 255*i/colorBuff->getWidth(); colorBuff->setColor(i,j,cc); } }*/ renderingMode; //how to use: here is an example if(renderingMode==WIRE){ //the rendering mode is WIRE drawLine(colorBuff); } if(renderingMode==SOLID){ //the rendering mode is SOLID drawPlane(colorBuff); } //how to use: here is an example //traverse the triangle of the model (and render them urself) /*for(int i=0;i<(int)OBJ->numtriangles;i++){ //the index of each vertices int indv1 = OBJ->triangles[i].vindices[0]; int indv2 = OBJ->triangles[i].vindices[1]; int indv3 = OBJ->triangles[i].vindices[2]; //the index of each color (same as the index of vertex int indc1 = indv1; int indc2 = indv2; int indc3 = indv3; //the index of each normals int indn1 = OBJ->triangles[i].nindices[0]; int indn2 = OBJ->triangles[i].nindices[1]; int indn3 = OBJ->triangles[i].nindices[2]; //the index of the face normal of the triangle i int indfn = OBJ->triangles[i].findex; //the index of each texture coordinates int indt1 = OBJ->triangles[i].tindices[0]; int indt2 = OBJ->triangles[i].tindices[1]; int indt3 = OBJ->triangles[i].tindices[2]; //for each channel (x,y,z) for(int j=0;j<3;j++){ //vertex data cout << j << ": "; cout << OBJ->vertices[indv1*3+j] << " "; cout << OBJ->vertices[indv2*3+j] << " "; cout << OBJ->vertices[indv3*3+j] << endl; OBJ->vertices[indv1*3+j]; OBJ->vertices[indv2*3+j]; OBJ->vertices[indv3*3+j]; //color data OBJ->colors[indc1*3+j]; OBJ->colors[indc2*3+j]; OBJ->colors[indc3*3+j]; //normal data OBJ->normals[indn1*3+j]; OBJ->normals[indn2*3+j]; OBJ->normals[indn3*3+j]; //face normal data OBJ->facetnorms[indfn*3+j]; } system("pause"); //for each channel of texture coordinates for(int j=0;j<2;j++){ OBJ->texcoords[indt1*2+j]; OBJ->texcoords[indt2*2+j]; OBJ->texcoords[indt3*2+j]; } //render this triangle //bla bla bla bla bla bla bla bla bla bla bla bla.... }*/ //system("pause"); }
void Map_Render_Debug::Render() { float tempMatrix[16]; //Generate camera matrix Camera.generateMatrix(); //Set projection matrix glMatrixMode(GL_PROJECTION); glLoadIdentity(); Matrix.toOGLMatrix(tempMatrix,Camera.projMatrix); glLoadMatrixf(tempMatrix); //Set view matrix glMatrixMode(GL_MODELVIEW); glLoadIdentity(); Matrix.toOGLMatrix(tempMatrix,Camera.viewMatrix); glLoadMatrixf(tempMatrix); bool sameVBO = true; if (floor(Camera.Position.x) != floor(vboPosition.x)) sameVBO = false; if (floor(Camera.Position.y) != floor(vboPosition.y)) sameVBO = false; if (floor(Camera.Position.z) != floor(vboPosition.z)) sameVBO = false; vboPosition = Camera.Position; float DY = max(0,Camera.Position.z * tan(Camera.FOV * PI / 180.0f)); float DX = max(0,DY * (1.0f*Screen.Width / Screen.Height)); if ((nextAnimationTime > 0.0f) && (Timer.Time() > nextAnimationTime)) { //Cause animation sameVBO = false; nextAnimationTime = 0.0f; } if (sameVBO == false) { //int i = 1; VBOEntry.Clear(); for (int i = 0; i < 7; i++) { drawPlane((int)(Camera.Position.x-DX), (int)(Camera.Position.y-DY), (int)(Camera.Position.x+DX), (int)(Camera.Position.y+DY),i); } } else { //Wake up maps in cache if (Timer.Time() - lastWakeupTime > 10.0f) { for (int i = 0; i < 16; i++) wakeupPlane((int)(Camera.Position.x-DX), (int)(Camera.Position.y-DY), (int)(Camera.Position.x+DX), (int)(Camera.Position.y+DY),i); lastWakeupTime = Timer.Time(); } } //SETUP DOF //glBlendFunc(GL_SRC_ALPHA,GL_DST_COLOR); //glBlendColor(0.0f,0.0f,0.5f,0.5f); //glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE); //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); //Draw level using VBOs GraphicsID graphicsID = BAD_ID; for (uint i = 0; i < VBOEntry.Count; i++) { TexID texID = VBOEntry[i]->SpriteBase; if (texID == BAD_ID) { logError("Trying to draw level without sprite set loaded"); continue; } GraphicsID newGraphicsID = Graphics.GetGraphicsEntryByID(texID); if (newGraphicsID != graphicsID) { OGLTexture textureOGLID = Graphics.GetOGLTextureByID(texID); glBindTexture(GL_TEXTURE_2D, textureOGLID); graphicsID = newGraphicsID; } VBOEntry[i]->VBO.SendToGPU(); //Draw normal //glColor4f(1.0f, 1.0f, 1.0f, 1.0f); VBOEntry[i]->VBO.Draw(); //Draw DOF //float drange = 0.1f; //float dstep = 0.02f; //DOF /*glColor4f(1.0f, 1.0f, 1.0f, 1.0f / (2.0f * drange / dstep)); for (float disp = -drange; disp <= drange; disp += dstep) { float viewMatrix[16]; Matrix.buildLookAtMatrix(Camera.Position.x+disp, Camera.Position.y, Camera.Position.z, Camera.Position.x, Camera.Position.y, Camera.Position.z - 3.0f, 0.0f, -1.0f, 0.0f, viewMatrix); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); Matrix.toOGLMatrix(tempMatrix,viewMatrix); glLoadMatrixf(tempMatrix); glClear(GL_DEPTH_BUFFER_BIT); VBOEntry[i]->VBO.Draw(); } for (float disp = -drange; disp <= drange; disp += dstep) { float viewMatrix[16]; Matrix.buildLookAtMatrix(Camera.Position.x, Camera.Position.y+disp, Camera.Position.z, Camera.Position.x, Camera.Position.y, Camera.Position.z - 3.0f, 0.0f, -1.0f, 0.0f, viewMatrix); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); Matrix.toOGLMatrix(tempMatrix,viewMatrix); glLoadMatrixf(tempMatrix); glClear(GL_DEPTH_BUFFER_BIT); VBOEntry[i]->VBO.Draw(); }*/ } //glColor4f(1.0f, 1.0f, 1.0f, 1.0f); //Draw level (debug) //OGLTexture textureOGLID = Graphics.GetOGLTextureByID(0); //glBindTexture(GL_TEXTURE_2D, textureOGLID); //glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); //glBlendFunc(GL_SRC_COLOR,GL_DST_COLOR); //VBO.Draw(); }
void renderScene(void) { mainPlane.manageHealth(); //GLfloat lightpos[] = {-x,-z,-y}; //glTranslatef(lightpos[0], lightpos[1], lightpos[2]); glColor3f(1, 1, 1); //glutSolidSphere(30, 20, 20); //glTranslatef(-lightpos[0], -lightpos[1], -lightpos[2]); //glLightfv(GL_LIGHT0, GL_POSITION, lightpos); if (deltaMove) moveMeFlat(deltaMove); if (deltaAngle) { angle += deltaAngle; orientMe(angle); //rotateMe(angle); } if (rotationAngleDelta) { rotationAngle+=rotationAngleDelta; rotationAngleDelta=0; rotateMe(rotationAngle); } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Draw ground glPushMatrix(); //glLoadIdentity(); //glTranslatef(x, y, z); //glRotatef(rotationAngle+90, 0, 1, 0); explosives.drawExplosions(); //glTranslatef(-x, -y, -z); glPopMatrix(); float minX=200000,maxX=0,minY=20000,maxY=0; glBegin(GL_QUADS); for (int i = 20; i <tiles.size()-20; i++) { for (int j = 20; j <tiles.size()-20; j++) { if(tiles[i][j].xMax>maxX) maxX = tiles[i][j].xMax; if(tiles[i][j].yMax>maxY) maxY = tiles[i][j].yMax; if(tiles[i][j].x<minX) minX = tiles[i][j].x; if(tiles[i][j].y<minY) minY = tiles[i][j].y; if (tiles[i][j].z>-.7) { tiles[i][j].drawTile(); } } } drawWater(maxX*40,maxY*40,minX*40,minY*40); glEnd(); drawTrees(); drawBuildings(); advanceLevel(); drawPlane(); //drawSilos(); drawCarrierGroup(); calculateFPS(); glutSwapBuffers(); //std::cout<<"hello"; indexer++; if (loadBuildings) { loadBuildings = 0; cDetector.buildings = &buildings; } cDetector.detectCollisions(); //glLoadIdentity(); }
void display(void) { static unsigned N; static double t0; double t1, elapsedTime; float fps; char cfps[256]; glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); /* left viewport */ glViewport(0, 0, WIDTH/2, HEIGHT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60, 1.0, 16.0, 512.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(160.0, 64.0, 160.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glPushMatrix(); glRotatef(angle, 0.0, 1.0, 0.0); drawPlane(); drawJulia(); glPopMatrix(); /* right viewport */ glViewport(WIDTH/2, 0, WIDTH/2, HEIGHT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-256.0, 256.0, -256.0, 256.0, 0.0, 512.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(160.0, 64.0, 160.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glPushMatrix(); glRotatef(angle, 0.0, 1.0, 0.0); drawPlane(); drawJulia(); glPopMatrix(); /* calculate and show FPS */ N++; t1 = currentSeconds(); elapsedTime = t1 - t0; if (elapsedTime > FPS_TIME_WINDOW) { fps = (float) N / elapsedTime; N = 0; t0 = t1; sprintf(cfps, "Julia Fractal GL (%d x %d): %3.1f fps", WIDTH, HEIGHT, fps); printf("%s\n", cfps); glutSetWindowTitle(cfps); } glutPostRedisplay(); glutSwapBuffers(); }
void render() { static Timer t; if(!gMyPhysX.isPaused()) { for (NxU32 i = 0; i < gKinematicActors.size(); i++) { NxActor* actor = gKinematicActors[i].actor; NxVec3 pos = actor->getGlobalPosition(); pos += gKinematicActors[i].vel * 1.f/60.f; actor->moveGlobalPosition(pos); } } gMyPhysX.simulate(t.elapsed_time()); t.reset(); // Clear buffers glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glColor4f(0.5,0.9,0.5,1.0); DrawSkyBox(SKYEXTENTS); drawPlane(SKYEXTENTS); // Keep physics & graphics in sync for (NxU32 pass = 0; pass < 2; pass++) { int nbActors = gMyPhysX.getScene()->getNbActors(); NxActor** actors = gMyPhysX.getScene()->getActors(); actors += nbActors; while(nbActors--) { NxActor* actor = *--actors; float size; bool isTrigger = false; bool isKinematic = actor->isDynamic() && actor->readBodyFlag(NX_BF_KINEMATIC); NxVec3 color; NxF32 alpha = 1; if (actor->isDynamic()) { if (actor->readBodyFlag(NX_BF_KINEMATIC)) { color.set(1,0,0); } else { color.set(0,1,0); } } else { color.set(0.2f,0.2f,0.2f); } if (*(int *)(&actor->userData) < 0) { NxI32 triggerNumber = -(*(NxI32 *)(&actor->userData)); NxI32 triggerIndex = triggerNumber - 1; // This is our trigger isTrigger = true; size = 10.0f; color.z = gNbTouchedBodies[triggerIndex] > 0.5f ? 1.0f:0.0f; alpha = 0.5f; if (pass == 0) continue; } else { // This is a normal object size = float(*(int *)(&actor->userData)); if (pass == 1) continue; } float glmat[16]; glPushMatrix(); actor->getGlobalPose().getColumnMajor44(glmat); glMultMatrixf(glmat); glColor4f(color.x, color.y, color.z, 1.0f); glutSolidCube(size*2.0f); glPopMatrix(); // Handle shadows if( !isTrigger) { glPushMatrix(); const static float ShadowMat[]={ 1,0,0,0, 0,0,0,0, 0,0,1,0, 0,0,0,1 }; glMultMatrixf(ShadowMat); glMultMatrixf(glmat); glDisable(GL_LIGHTING); glColor4f(0.1f, 0.2f, 0.3f, 1.0f); glutSolidCube(size*2.0f); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glEnable(GL_LIGHTING); glPopMatrix(); } } } }