int main(int argc, char *argv[]) { double x,y; int i; int xyz=0; startgraphics(); randinit(); D2=4*R*R; for (i=0; n<N; i++) { tryInsert(); perturb(); if (counter>5500) { drawObjects(); check4event(); counter=0; printf("."); } } while(1) { drawObjects(); check4event(); sleep(1); } }
void FinalGame::draw(double delta) { static Window win; glClearColor(0.0f,0.0f,0.0f,1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if(!multiView) { glViewport(0,0,win.getWidth(),win.getHeight()); drawObjects(); fb->Bind(); glClearColor(0.0f,0.0f,0.0f,1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glUniform1i(8,1); drawObjects(); picking(); glUniform1i(8,0); fb->Unbind(); } else drawMultiCam(); win.SwapBuffers(); }
void renderScene(void) { update(); //First step: Render from the light POV to a FBO, story depth values only glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fboId); //Rendering offscreen //Using the fixed pipeline to render to the depthbuffer glUseProgramObjectARB(0); // In the case we render the shadowmap to a higher resolution, the viewport must be modified accordingly. glViewport(0,0,RENDER_WIDTH * SHADOW_MAP_RATIO,RENDER_HEIGHT* SHADOW_MAP_RATIO); // Clear previous frame values glClear( GL_DEPTH_BUFFER_BIT); //Disable color rendering, we only want to write to the Z-Buffer glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); setupMatrices(p_light[0],p_light[1],p_light[2],l_light[0],l_light[1],l_light[2]); // Culling switching, rendering only backface, this is done to avoid self-shadowing glCullFace(GL_FRONT); drawObjects(); //Save modelview/projection matrice into texture7, also add a biais setTextureMatrix(); // Now rendering from the camera POV, using the FBO to generate shadows glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0); glViewport(0,0,RENDER_WIDTH,RENDER_HEIGHT); //Enabling color write (previously disabled for light POV z-buffer rendering) glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // Clear previous frame values glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Using the shadow shader glUseProgramObjectARB(shadowShaderId); glUniform1iARB(shadowMapUniform,7); glActiveTextureARB(GL_TEXTURE7); glBindTexture(GL_TEXTURE_2D,depthTextureId); setupMatrices(p_camera[0],p_camera[1],p_camera[2],l_camera[0],l_camera[1],l_camera[2]); glCullFace(GL_BACK); drawObjects(); glutSwapBuffers(); }
void GLWidget :: paintGL() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); if (perspective) { if (width > height) { glFrustum(-0.0008f*width/height, 0.0008f*width/height, -0.0008f, 0.001f, 0.001f, 1000.0f); } else { glFrustum(-0.0008f, 0.0008f, -0.0008f*height/width, 0.0008f*height/width, 0.001f, 10000.0f); } } else { if (width > height) { glOrtho(-10.0f*width/height, 10.0f*width/height, -10.0f, 10.0f, 0.001f, 1000.0f); } else { glOrtho(-10.0f, 10.0f, -10.0f*height/width, 10.0f*height/width, 0.001f, 1000.0f); } } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); if (viewCamera) glLoadMatrixd(camera->getMatrix()); else glLoadMatrixd(editor->getMatrix()); glRotatef(angle_x, 0.0f, 1.0f, 0.0f); glRotatef(angle_y, 1.0f, 0.0f, 0.0f); if (renderMode == GL_SELECT) { startPick(); drawObjects(); finishPick(); renderMode = GL_RENDER; updateGL(); } else drawObjects(); }
//--------------------------------------------------------------------------- void __fastcall TMainForm::SourceLightColorPickerClick(TObject *Sender) { if(PickColor->Execute()) { FillCanvasWithColor(SourceLightColorPicker->Canvas, PickColor->Color); drawObjects(Graph->Canvas, true); } }
//--------------------------------------------------------------------------- void __fastcall TMainForm::DrawBtnClick(TObject *Sender) { // delete objects["flippedmodel"]; // objects["flippedmodel"] = new GraphicObject (*objects["model"]); // // GraphicObject *flippedmodel = objects["flippedmodel"]; // // flippedmodel->hidden = ReflectionSurfaceSelect->ItemIndex == 0; // // if (!flippedmodel->hidden) { // Matrix *flip; // // switch (ReflectionSurfaceSelect->ItemIndex) { // case 1 : // flip = GetReflectionMatrix(AxisX, AxisY); // break; // // case 2 : // flip = GetReflectionMatrix(AxisY, AxisZ); // break; // // case 3 : // flip = GetReflectionMatrix(AxisX, AxisZ); // break; // } // // flippedmodel->applyTransform(flip); // delete flip; // } // // objects["flippedmodel"] = flippedmodel; drawObjects(Graph->Canvas, true); }
//--------------------------------------------------------------------------- void __fastcall TMainForm::BezierHidePolysClick(TObject *Sender) { if(surface) { surface->gridHidden = BezierHidePolys->Checked; drawObjects (Graph->Canvas, true); } }
//--------------------------------------------------------------------------- void __fastcall TMainForm::AmbientLightColorPickerClick(TObject *Sender) { if(shouldUseAmbientLightModel && PickColor->Execute()) { FillCanvasWithColor(AmbientLightColorPicker->Canvas, PickColor->Color); drawObjects(Graph->Canvas, true); } }
void XMLScene::display() { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); axis.draw(); activeCamera->applyView(); for(unsigned int i=0;i<sceneLights.size();i++) { if(activeLights[i]==1) { sceneLights[i]->enable(); sceneLights[i]->draw(); } else sceneLights[i]->disable(); sceneLights[i]->update(); } axis.draw(); selectDrawMode(); drawObjects(); glutSwapBuffers(); }
void Scene::noShadows() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); projection->execute(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); view->execute(); for(std::vector<Light*>::iterator l = lights.begin(); l != lights.end(); ++l) (*l)->execute(); // glDisable(GL_LIGHTING); // glColor3f(1, 1, 1); drawObjects(); //float* pos = lights[0]->getPosition(); float rgba[4] = {1,1,1,1}; glPointSize(10); glMaterialfv(GL_FRONT, GL_DIFFUSE, rgba); glBegin(GL_POINTS); glVertex3f(-5, 5, 5); glEnd(); glFlush(); glutSwapBuffers(); }
void display (void) { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* draw surfaces as either smooth or flat shaded */ if (smoothShading == 1) glShadeModel(GL_SMOOTH); else glShadeModel(GL_FLAT); /* draw polygons as either solid or outlines */ if (lineDrawing == 1) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); else glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); /* give all objects the same shininess value */ glMaterialf(GL_FRONT, GL_SHININESS, 30.0); /* set starting location of objects */ glPushMatrix (); glRotatef(180.0, 1.0, 0.0, 0.0); glRotatef(180.0, 0.0, 1.0, 0.0); glRotatef(180.0, 0.0, 0.0, 1.0); glTranslatef(0.0, 0.0, -15.0); /* Draw the objects to the screen */ drawObjects(numberLevels, 0, 0, 0); glPopMatrix (); glFlush (); }
void CPlayGameVorticon::drawAllElements() { // Animate the tiles of the map m_Map.animateAllTiles(); // Blit the background g_pVideoDriver->blitScrollSurface(); // Draw all objects to the screen drawObjects(); // Draw masked tiles here! m_Map.drawForegroundTiles(); if(mp_option[OPT_HUD].value && !mp_Finale && !m_paused && !mp_Menu && !mp_HighScores) { // Draw the HUD mp_HUD->render(); } // Render the dialogs which are seen when the game is paused if( m_paused || !m_MessageBoxes.empty() || !mp_Menu ) { // Finally draw Dialogs like status screen, game paused, etc. processPauseDialogs(); } }
/* display function - GLUT display callback function * clears the screen, sets the camera position, draws the ground plane and movable box */ void display(void) { //float origin[] = {0,0,0,1}; float m_amb[] = {0.33, 0.22, 0.03, 1.0}; float m_dif[] = {1, 0, 0, 1.0}; float m_spec[] = {0.99, 0.91, 0.81, 1.0}; float shiny = 60; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(camPos[0], camPos[1], camPos[2], 0,0,0, 0,1,0); glColor3f(1,1,1); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, m_amb); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, m_dif); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, m_spec); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shiny); drawParticles(); drawObjects(); drawMenu(); glutSwapBuffers(); }
void GLRenderer::renderFrame() { #ifndef IOS if (GL_FALSE == eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext) || EGL_SUCCESS != eglGetError()) { return; } #endif glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); drawBackground(); glDisable(GL_BLEND); glEnable(GL_DEPTH_TEST); glClear(GL_DEPTH_BUFFER_BIT); drawObjects(); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glClear(GL_DEPTH_BUFFER_BIT); drawForeground(); #ifndef IOS eglSwapBuffers(m_eglDisplay, m_eglSurface); #endif #if defined( DISPLAY_FPS ) && defined( SHP ) _displayFPS(); #endif }
// draw callback // Purposes: // - Load the navigation matrix to reflect frame's navigation // - Use OpenGL to generate computer graphics. void draw(arMasterSlaveFramework& framework) { // Load the navigation matrix. framework.loadNavMatrix(); // Generate graphics. if(selectionMode == 2) { renderPrimitive(-2.5f); // draws square with quadrants drawObjects(-2.5f); // draw the mini versions } vector<arInteractable*>::iterator i; for(i=objects.begin(); i != objects.end(); ++i) { Object* oby = ((Object*)(*i)); oby->draw(); } // Draw the effectors. rightHand.draw(); leftHand.draw(); }
void mouse(int button, int state, int x, int y) { GLuint selectBuf[SIZE]; GLint hits; GLint viewport[4]; if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) { glGetIntegerv (GL_VIEWPORT, viewport); glSelectBuffer (SIZE, selectBuf); glRenderMode(GL_SELECT); glInitNames(); glPushName(0); glMatrixMode (GL_PROJECTION); glPushMatrix (); glLoadIdentity (); /* create 5x5 pixel picking region near cursor location */ gluPickMatrix ((GLdouble) x, (GLdouble) (viewport[3] - y), 5.0, 5.0, viewport); gluOrtho2D (-2.0, 2.0, -2.0, 2.0); drawObjects(GL_SELECT); glMatrixMode (GL_PROJECTION); glPopMatrix (); glFlush (); hits = glRenderMode (GL_RENDER); processHits (hits, selectBuf); glutPostRedisplay(); } }
void OpenGlWidget::paintGL() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); drawObjects(); }
void TuioDemo::run() { running=true; while (running) { drawObjects(); processEvents(); SDL_Delay(10); } }
void FXAA::draw(void) { nv::matrix4f rotation; nv::matrix4f model; nv::matrix4f mvp; float color0[4]={0.5,0.5,0.8,1.0}; float color1[4]={0.5,0.9,0.5,1.0}; m_transformer->setRotationVel(nv::vec3f(0.0f, m_autoSpin ? (NV_PI*0.05f) : 0.0f, 0.0f)); glBindFramebuffer(GL_FRAMEBUFFER, m_sourceFrameBuffer); glClearColor(1.0f, 1.0f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLineWidth(m_lineWidth); //draw lined sphere nv::matrix4f vp = m_projection_matrix * m_transformer->getModelViewMat(); nv::rotationX(rotation, float(0.2)); mvp = m_projection_matrix * m_transformer->getModelViewMat() * rotation; drawSphere(&mvp); //draw rings model.make_identity(); model.set_scale(0.04); nv::rotationX(rotation, float(0.1)); mvp = m_projection_matrix * m_transformer->getModelViewMat() * rotation* model; drawObjects(&mvp, color0, 0); model.make_identity(); model.set_scale(0.04); nv::rotationX(rotation, float(NV_PI/2+0.1)); mvp = m_projection_matrix * m_transformer->getModelViewMat() * rotation * model; drawObjects(&mvp, color0, 0); //draw triangle model.make_identity(); model.set_scale(0.03); model.set_translate(nv::vec3f(0.0f, -0.3f, 0.0f)); mvp = m_projection_matrix * m_transformer->getModelViewMat() * model; drawObjects(&mvp, color1, 1); glBindFramebuffer(GL_FRAMEBUFFER, 0); FXAABlit(m_FXAALevel); return; }
void display(void) { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); drawObjects(); glutSwapBuffers(); }
void XMLScene::display() { static int i=0; glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); //axis.draw(); /* glMatrixMode(GL_PROJECTION); glLoadIdentity(); int viewport[]={0,0,0,0}; glGetIntegerv(GL_VIEWPORT,viewport); glViewport(0,0,viewport[2],viewport[3]); //file->sceneCameras[camera].second->updateProjectionMatrix(viewport[2],viewport[3]); file->sceneCameras[camera].second->applyView(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); */ //activeCamera->setZ(-20); activeCamera->applyView(); printScoreBoard(); //draw lights selectDrawMode(); for(unsigned int i=0;i<file->sceneLights.size();i++) { if(activeLights[i]==1) { file->sceneLights[i]->enable(); file->sceneLights[i]->draw(); } else file->sceneLights[i]->disable(); file->sceneLights[i]->update(); } //end of draw lights glPushMatrix(); drawObjects(); glPopMatrix(); data->getBoard()->draw(); //if theme is changed if(lastOption!=option) { data->getBoard()->setPieceOption(option); changeTheme(); lastOption=option; } i++; glutSwapBuffers(); }
void Render::draw(Level* level, Node<Obj> *objects) { // TODO Render Backdrop drawBackdrop(); drawLevel(level); drawObjects(objects); }
/** Author: Joel Denke, Marcus Isaksson Description: Draw all graphics */ void drawGraphics() { int i; startDraw(); drawBackground(SCREEN_WIDTH,SCREEN_HEIGHT); drawObjects(&gameWorld, NO_OBJECTS, oColor); drawPlayers(gameWorld.players, no_players, pColor); endDraw(); }
void drawObjects(int level, int numits, int curlevel, int curit) { //if we leave the bounds of the "tree" start recursing back if(curlevel >= level || curit >= shapes[curlevel]->iterations) return; /* use offsets for subsequent iterations */ if(curit > 0) { glTranslatef(shapes[curlevel]->xoff,shapes[curlevel]->yoff, shapes[curlevel]->zoff); glRotatef(shapes[curlevel]->xroff, 1 , 0, 0); glRotatef(shapes[curlevel]->yroff, 0 , 1, 0); glRotatef(shapes[curlevel]->zroff, 0 , 0, 1); glScalef(shapes[curlevel]->xsoff ,shapes[curlevel]->ysoff, shapes[curlevel]->zsoff); } else /*otherwise use initial values */ { glTranslatef(shapes[curlevel]->inx, shapes[curlevel]->iny, shapes[curlevel]->inz); glRotatef(shapes[curlevel]->inxr, 1 , 0, 0); glRotatef(shapes[curlevel]->inyr, 0 , 1, 0); glRotatef(shapes[curlevel]->inzr, 0 , 0, 1); glScalef(shapes[curlevel]->inxs ,shapes[curlevel]->inys, shapes[curlevel]->inzs); } /* draw the current shape the to the current location as defined in the matrix */ drawShape(shapes[curlevel]); //go down a level drawObjects(level, numits, curlevel+1, 0); //go right an iteration drawObjects(level, numits, curlevel, curit+1); }
void CPetRoomsGlyph::drawAt(CScreenManager *screenManager, const Point &pt, bool isHighlighted_) { // Clear background Rect rect(pt.x, pt.y, pt.x + 52, pt.y + 52); screenManager->fillRect(SURFACE_BACKBUFFER, &rect, 0, 0, 0); CRoomFlags roomFlags(_roomFlags); uint elevBits = roomFlags.getElevatorBits(); uint classBits = roomFlags.getPassengerClassBits(); uint floorBits = roomFlags.getFloorBits(); uint roomBits = roomFlags.getRoomBits(); // Save a copy of object pointers that may be modified CGameObject *obj0 = _object0; CGameObject *obj1 = _object1; CGameObject *obj4 = _object4; CGameObject *obj5 = _object5; if (_field38 == 1 || isHighlighted_) { _object0 = _object2; _object1 = _object3; _object4 = _object6; _object5 = _object7; } // Draw the images Point destPt = pt; drawObjects(classBits + elevBits * 4, destPt, screenManager); destPt.y += 10; drawObjects((floorBits >> 4) & 15, destPt, screenManager); destPt.y += 10; drawObjects(floorBits & 15, destPt, screenManager); destPt.y += 10; drawObjects(roomBits >> 3, destPt, screenManager); destPt.y += 7; drawObjects(((roomBits & 7) << 1) + (roomFlags.getBit0() ? 1 : 0), destPt, screenManager); // Restore original object pointers _object0 = obj0; _object1 = obj1; _object4 = obj4; _object5 = obj5; }
void WorldUIView::draw() { if(isVisible()){ drawBg(); drawSurface(); drawObjects(); drawBorder(); drawParams(); UIView::draw(); } }
void XMLScene::display() { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); activeCamera->applyView(); //axis.draw(); /*glMatrixMode(GL_PROJECTION); glLoadIdentity(); sceneCameras[camera].second->applyView(); glMatrixMode(GL_MODELVIEW); glLoadIdentity();*/ //draw lights selectDrawMode(); unsigned int initial=files[option]->sceneLights[0]->getLightId(); unsigned int finalId=files[option]->sceneLights[files[option]->sceneLights.size()-1]->getLightId(); for(unsigned int i=initial;i<finalId;i++) { if(activeLights[i]==1) { files[option]->sceneLights[i]->enable(); files[option]->sceneLights[i]->draw(); } else files[option]->sceneLights[i]->disable(); files[option]->sceneLights[i]->update(); } //end of draw lights glPushMatrix(); drawObjects(); glPopMatrix(); pieces->draw(); board->draw(); //if theme is changed if(lastOption!=option) { pieces->setOption(option); changeTheme(); pieces->setOption(option); changeTheme(); lastOption=option; } glutSwapBuffers(); }
void FinalGame::drawMultiCam() { static Window win; glViewport(0,win.getHeight()/2,win.getWidth()/2,win.getHeight()/2); multicams[0]->Update(); drawObjects(); glViewport(win.getWidth()/2,win.getHeight()/2,win.getWidth()/2,win.getHeight()/2); multicams[1]->Update(); drawObjects(); glViewport(0,0,win.getWidth()/2,win.getHeight()/2); multicams[2]->Update(); drawObjects(); glViewport(win.getWidth()/2,0,win.getWidth()/2,win.getHeight()/2); multicams[3]->Update(); drawObjects(); }
//--------------------------------------------------------------------------- void __fastcall TMainForm::GraphMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { if (isRotating) { angleX = (double)(Y - yc) / 180.0 * M_PI; angleY = (double)(X - xc) / 180.0 * M_PI; xc = X; yc = Y; drawObjects (Graph->Canvas, true); } }
//--------------------------------------------------------------------------- void __fastcall TMainForm::GenerateBezierClick(TObject *Sender) { delete surface; angleX = 0; angleY = 0; surface = new BezierSurface(BezierRowsField->Text.ToInt(), BezierColsField->Text.ToInt(), BezierDetalizationField->Text.ToInt(), BezierHidePolys->Checked, DrawStyleRadioGroup->ItemIndex == STYLE_FILL); drawObjects(Graph->Canvas, true); }