static void display(void) { demos[demoIndex].drawFunc(); if(!paused || step){ cpVect newPoint = cpvlerp(mouseBody->p, ChipmunkDemoMouse, 0.25f); mouseBody->v = cpvmult(cpvsub(newPoint, mouseBody->p), 60.0f); mouseBody->p = newPoint; demos[demoIndex].updateFunc(ticks); ticks++; step = cpFalse; } if(drawBBs) cpSpaceEachShape(space, drawShapeBB, NULL); drawInstructions(); drawInfo(); drawString(-300, -200, ChipmunkDemoMessageString); glutSwapBuffers(); glClear(GL_COLOR_BUFFER_BIT); }
void GLWidget::paintEvent(QPaintEvent *event) { makeCurrent(); //! [4] glMatrixMode(GL_MODELVIEW); glPushMatrix(); //! [4] //! [6] qglClearColor(qtPurple.dark()); glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_MULTISAMPLE); static GLfloat lightPosition[4] = { 0.5, 5.0, 7.0, 1.0 }; glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); qreal pixelRatio = devicePixelRatio(); setupViewport(width() * pixelRatio, height() * pixelRatio); //! [6] //! [7] glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(0.0, 0.0, -10.0); glRotatef(xRot / 16.0, 1.0, 0.0, 0.0); glRotatef(yRot / 16.0, 0.0, 1.0, 0.0); glRotatef(zRot / 16.0, 0.0, 0.0, 1.0); logo->draw(); //! [7] //! [8] glShadeModel(GL_FLAT); glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); glMatrixMode(GL_MODELVIEW); glPopMatrix(); //! [8] //! [10] QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); foreach (Bubble *bubble, bubbles) { if (bubble->rect().intersects(event->rect())) bubble->drawBubble(&painter); } drawInstructions(&painter); painter.end(); }
static void display(void) { glClear(GL_COLOR_BUFFER_BIT); drawSpace(space, currDemo->drawOptions ? currDemo->drawOptions : &options); drawInstructions(); drawInfo(); drawString(-300, -210, messageString); glutSwapBuffers(); ticks++; cpVect newPoint = cpvlerp(mousePoint_last, mousePoint, 0.25f); mouseBody->p = newPoint; mouseBody->v = cpvmult(cpvsub(newPoint, mousePoint_last), 60.0f); mousePoint_last = newPoint; currDemo->updateFunc(ticks); }
static void display(void) { PrintStringBuffer[0] = 0; PrintStringCursor = PrintStringBuffer; glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glScalef(scale, scale, 1.0); glTranslatef(translate_x, translate_y, 0.0); demos[demoIndex].drawFunc(); if(!paused || step){ cpVect newPoint = cpvlerp(mouseBody->p, ChipmunkDemoMouse, 0.25f); mouseBody->v = cpvmult(cpvsub(newPoint, mouseBody->p), 60.0f); mouseBody->p = newPoint; demos[demoIndex].updateFunc(ticks); ticks++; ChipmunkDemoTime = ticks/60.0; step = cpFalse; } if(drawBBs) cpSpaceEachShape(space, drawShapeBB, NULL); glMatrixMode(GL_MODELVIEW); glPushMatrix(); { // Draw the text at fixed positions, // but save the drawing matrix for the mouse picking glLoadIdentity(); drawInstructions(); drawInfo(); drawString(-300, -200, ChipmunkDemoMessageString); } glPopMatrix(); glutSwapBuffers(); glClear(GL_COLOR_BUFFER_BIT); }
void GLWidget::paintEvent(QPaintEvent *event) { makeCurrent(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glClearColor( 0.0, 0.0, 0.0, 0.0 ); glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glEnable(GL_MULTISAMPLE); static GLfloat lightPosition[4] = { 0.0, 0.0, 0.0, 0.0 }; glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); setupViewport(width(), height()); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslated(xTrans, yTrans, -10.0); glRotated(xRot / 16.0, 1.0, 0.0, 0.0); glRotated(yRot / 16.0, 0.0, 1.0, 0.0); glRotated(zRot / 16.0, 0.0, 0.0, 1.0); glScalef(scale, scale, scale); //appelle la liste d objet //a chaque refresh on affiche le nouveau volume Primitive->draw_xyz_repere(); Primitive->drawingVolume(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); drawInstructions(&painter); painter.end(); }
void checkGameState() { renderFrame(); renderNextBlockFrame(); switch (gameState) { case 0: // Game play printCanvasBlocks(); drawNextBlock(); renderBlock(); break; case 1: // Game pause drawPauseScreen(); break; case 2: // Game over drawGameOverScreen(); break; } drawInstructions(); drawScoreboard(); }