void hourglass(double x,double y,double z, double radius,double height, double thx,double thz, unsigned int tex, unsigned int wood_tex) { double i; const double pi2 = M_PI * 2; double delta = pi2 / 103; float white[] = {221.0/255.0,213.0/255.0,242.0/255.0,1}; float shinyvec[1]; shinyvec[0] = 16.0; glMaterialfv(GL_FRONT_AND_BACK,GL_SHININESS,shinyvec); glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,white); glPushMatrix(); glTranslated(x,y,z); glRotated(thx,1,0,0); glRotated(thz,0,0,1); glScaled(radius,height,radius); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,wood_tex); // The top lid glColor3f(.055,.055,.055); glBegin(GL_TRIANGLE_FAN); glNormal3f(0,1,0); glTexCoord2f(.5,.5); glVertex3f(0,1.01,0); for (i=0.0;i<=pi2;i+=delta) { double x = 1.5 * cos(i); double z = 1.5 * sin(i); glTexCoord2f(cos(i),sin(i)); glVertex3f(x,1.01,z); } glEnd(); // The bottom lid glColor3f(.055,.055,.055); glBegin(GL_TRIANGLE_FAN); glNormal3f(0,-1,0); glTexCoord2f(.5,.5); glVertex3f(0,-.01,0); for (i=0.0;i<=pi2;i+=delta) { double x = 1.5 * cos(i); double z = 1.5 * sin(i); glTexCoord2f(cos(i),sin(i)); glVertex3f(x,-.01,z); } glEnd(); // Cylinders coming down the sides cylinder(1.3,0,0, 0,0, height*4,.15, 51.5,wood_tex, wood_tex, 0); cylinder(-1.3,0,0, 0,0, height*4,.15, 51.5,wood_tex, wood_tex, 0); for (i=0.0;i<=360;i+=1) { hourglass_side(i,tex); } glPopMatrix(); glDisable(GL_TEXTURE_2D); }
static gboolean expose (GtkWidget *da, GdkEventExpose *event, gpointer user_data) { GdkGLContext *glcontext = gtk_widget_get_gl_context (da); GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (da); // g_print (" :: expose\n"); if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) { g_assert_not_reached (); } /* draw in here */ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //glDepthFunc(GL_GREATER); // The Type Of Depth Testing (Less Or Equal) glEnable(GL_DEPTH_TEST); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, material_diffuse); glPushMatrix(); glRotatef (ang, 1, 0, 1); // glRotatef (ang, 0, 1, 0); // glRotatef (ang, 0, 0, 1); glShadeModel(GL_SMOOTH); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); /* glBegin (GL_LINES); glColor3f (1., 0., 0.); glVertex3f (0., 0., 0.); glVertex3f (1., 0., 0.); glEnd (); glBegin (GL_LINES); glColor3f (0., 1., 0.); glVertex3f (0., 0., 0.); glVertex3f (0., 1., 0.); glEnd (); glBegin (GL_LINES); glColor3f (0., 0., 1.); glVertex3f (0., 0., 0.); glVertex3f (0., 0., 1.); glEnd (); */ FreeREP::Init(); Geom_Vec3 pt1(0,0,0); Geom_Vec3 pt2(0,1,0); Geom_Vec3 pt3(1,1,0); Geom_Vec3 pt4(1,0,0); Geom_Vec3 pt5(0.5,0.5,0); Geom_Vec3 pt6(0.5,.75,0); Geom_Vec3 pt7(.75,.75,0); Topo_Line *l1 = new Topo_Line(pt1,pt2); Topo_Line *l2 = new Topo_Line(pt2,pt3); Topo_Line *l3 = new Topo_Line(pt3,pt4); Topo_Arc *a1 = new Topo_Arc(Geom_Ax2(pt4,Geom_Vec3(0,0,-1),Geom_Vec3(-1,0,0)),1,M_PI/2,0); Topo_Line *l4 = new Topo_Line(pt5,pt6); Topo_Line *l5 = new Topo_Line(pt6,pt7); Topo_Line *l6 = new Topo_Line(pt7,pt5); /* Topo_Edge *e1 = new Topo_Edge(); e1->Add(l1); e1->Add(l2); //e1->Add(l3); e1->Add(a1); e1->Reverse(); Topo_Edge *e2 = new Topo_Edge(); e2->Add(l4); e2->Add(l5); e2->Add(l6); */ /* glBegin(GL_LINE_STRIP); e1->GetVertices(.01,vCall); glEnd(); glBegin(GL_LINE_STRIP); e2->GetVertices(.01,vCall); glEnd(); */ /* Topo_Face *face = new Topo_Face_Planar(Geom_Plane(Geom_Vec3(0,0,0),Geom_Vec3(0,0,-1))); face->Add(e1); face->Add(e2);*/ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glEnable(GL_AUTO_NORMAL); //Draw a coordinate axis on the screen glBegin(GL_LINES); glVertex3d(0,0,0); glVertex3d(0,0,.5); glVertex3d(0,0,0); glVertex3d(0,.5,0); glVertex3d(0,0,0); glVertex3d(.5,0,0); glEnd(); glPushMatrix(); glScaled(.25,.25,.25); glPushMatrix(); glTranslated(-.5,.5,0); t3dDraw3D("Y", 0, 0, 0.05f); glPopMatrix(); glPushMatrix(); glTranslated(.5,-.5,0); glRotated(90,0,0,1); t3dDraw3D("X", 0, 0, 0.05f); glPopMatrix(); glTranslated(-.5,0,0.5); glRotated(90,1,0,0); t3dDraw3D("Z", 0, 0, 0.05f); glPopMatrix(); glBegin(GL_TRIANGLES); //face->Triangulate(.01,vCall); glEnd(); Topo_Face_Spheric *sphere = new Topo_Face_Spheric(Geom_Ax2(Geom_Vec3(0,0,0),Geom_Vec3(0,0,1),Geom_Vec3(1,0,0)),1); glBegin(GL_TRIANGLES); //sphere->Triangulate(.01,vCall); glEnd(); Topo_Face_Toroidal *toroid = new Topo_Face_Toroidal(Geom_Ax2(Geom_Vec3(0,0,0),Geom_Vec3(0,0,1),Geom_Vec3(1,0,0)),.5,.125); glBegin(GL_TRIANGLES); //toroid->Triangulate(.01,vCall); glEnd(); //Topo_Solid *solid = BrepAlgoExtrude(face,Geom_Vec3(0,0,.5)); glBegin(GL_TRIANGLES); //solid->Triangulate(.001,vCall); glEnd(); std::vector<Topo_Shape*> shapes = ReadIGES("Tests/Pawn.igs");// = ReadFREP("Tests/SimpleFaces.FREP"); // shapes.push_back(MakeSphere(Geom_Ax2(Geom_Vec3(0,0,0),Geom_Vec3(0,0,1),Geom_Vec3(1,0,0)),1)); // shapes.push_back(MakeSphere(Geom_Ax2(Geom_Vec3(0,0,0),Geom_Vec3(0,0,1),Geom_Vec3(1,0,0)),0.25)); // shapes.push_back(MakeCone(Geom_Ax2(Geom_Vec3(0,0,0),Geom_Vec3(0,0,1),Geom_Vec3(1,0,0)),.5,1,1)); for(int i=0; i < shapes.size(); i++) { ICanTriangulate *obj = dynamic_cast<ICanTriangulate*>(shapes[i]); if(obj) { #ifdef DRAWFACES glBegin(GL_TRIANGLES); obj->Triangulate(.01,vCall); glEnd(); #endif #ifdef DRAWEDGES Topo_Face *face = dynamic_cast<Topo_Face*>(shapes[i]); if(face) { Topo_Edge* edge = face->GetFirstEdge(); while(edge) { glBegin(GL_LINE_STRIP); edge->GetVertices(.01,dvCall); glEnd(); edge = face->GetNextEdge(); } } Topo_Solid *solid = dynamic_cast<Topo_Solid*>(shapes[i]); if(solid) { face = solid->GetFirstFace(); while(face) { Topo_Edge* edge = face->GetFirstEdge(); while(edge) { glBegin(GL_LINE_STRIP); edge->GetVertices(.01,dvCall); glEnd(); edge = face->GetNextEdge(); } face = solid->GetNextFace(); } } #endif } else { Topo_Edge *edge = dynamic_cast<Topo_Edge*>(shapes[i]); if(edge) { glBegin(GL_LINE_STRIP); edge->GetVertices(.01,dvCall); glEnd(); } Topo_Wire *wire = dynamic_cast<Topo_Wire*>(shapes[i]); if(wire) { glBegin(GL_LINE_STRIP); wire->GetVertices(.01,dvCall); glEnd(); } } } /* Topo_Face *tface = solid->GetFirstFace(); while(tface) { Topo_Edge *tedge = tface->GetFirstEdge(); while(tedge) { glBegin(GL_LINE_STRIP); tedge->GetVertices(.01,vCall); glEnd(); tedge = tface->GetNextEdge(); } tface = solid->GetNextFace(); }*/ glPopMatrix (); if (gdk_gl_drawable_is_double_buffered (gldrawable)) gdk_gl_drawable_swap_buffers (gldrawable); else glFlush (); gdk_gl_drawable_gl_end (gldrawable); return TRUE; }
void LightingScene::display() { // ---- BEGIN Background, camera and axis setup // Clear image and depth buffer everytime we update the scene glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); // Initialize Model-View matrix as identity (no transformation glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Apply transformations corresponding to the camera position relative to the origin CGFscene::activeCamera->applyView(); light0->draw(); light1->draw(); // Draw axis axis.draw(); // ---- END Background, camera and axis setup // ---- BEGIN Primitive drawing section //First Table glPushMatrix(); glTranslated(5,0,8); table->draw(); glPopMatrix(); //Second Table /*glPushMatrix(); glTranslated(12,0,8); table->draw(); glPopMatrix();*/ //Floor glPushMatrix(); glTranslated(7.5,0,7.5); glScaled(15,0.2,15); floorAppearance->apply(); floor->draw(); glPopMatrix(); //PlaneWall glPushMatrix(); glTranslated(7.5,4,0); glRotated(90.0,1,0,0); glScaled(15,0.2,8); materialB->apply(); wall->draw(); glPopMatrix(); //LeftWall glPushMatrix(); glTranslated(0,4,7.5); glRotated(-90.0,0,0,1); glScaled(8,0.2,15); windowAppearance->apply(); wallWindow->draw(); glPopMatrix(); // Board A glPushMatrix(); glTranslated(4,4,0.2); glScaled(BOARD_WIDTH,BOARD_HEIGHT,1); glRotated(90.0,1,0,0); slidesAppearance->apply(); boardA->draw(); glPopMatrix(); //BoardB glPushMatrix(); glTranslated(10.5,4,0.2); glScaled(BOARD_WIDTH,BOARD_HEIGHT,1); glRotated(90.0,1,0,0); boardAppearance->apply(); boardB->draw(); glPopMatrix(); //m= new myCylinder(23,10,true); m2= new myCylinder(12,10,true); //l= new myLamp(12,10,false); /*glPushMatrix(); glTranslated(6,3,12); glScaled(1,6,1); glRotated(90.0,1,0,0); slidesAppearance->apply(); m2->draw(); glPopMatrix(); glPushMatrix(); //glScaled(1,0.5,0.5); glTranslated(7.3,7.5,0.175); glRotated(-90,0,1,0); clock1->draw(); glPopMatrix(); /*glPushMatrix(); //glRotated(-90,0,1,0); aviao->draw(); glPopMatrix();*/ glPushMatrix(); slidesAppearance->apply(); robot->draw(); glPopMatrix(); // We have been drawing in a memory area that is not visible - the back buffer, // while the graphics card is showing the contents of another buffer - the front buffer // glutSwapBuffers() will swap pointers so that the back buffer becomes the front buffer and vice-versa glutSwapBuffers(); }
void SpaceShip::draw(float x, float y, int debug){ _x = x; _y = y; glPushMatrix(); glTranslated(x, y, 0.0f); glScalef(0.8f, 0.8f, 1.0f); glPushMatrix(); glPushMatrix(); // Strobes glPushMatrix(); GLfloat ambient1[] = {0.35,0.35,0.35,0}; GLfloat emission_on[] = {1,1,1,0}; GLfloat emission_off[] = {0.3,0.3,0.3,0}; if (glIsEnabled(GL_LIGHT2)) glMaterialfv(GL_FRONT, GL_EMISSION, emission_on); else if (glIsEnabled(GL_LIGHT0)) glMaterialfv(GL_FRONT, GL_EMISSION, emission_off); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, ambient1); glColor3f(0.35f, 0.35f, 0.35f); glPushMatrix(); glTranslated(-11.5, -1.0, 2); glScaled(1, 1, 2); glutSolidCube(1); glPopMatrix(); // strobe esq glPushMatrix(); glTranslated(11.5, -1.0, 2); glScaled(1, 1, 2); glutSolidCube(1); glPopMatrix(); // strobe dir glPopMatrix(); GLfloat ambient[] = {.25,.25,.25,1}; GLfloat diffuse[] = {.4,.4,.4,1}; GLfloat specular[] = {0.774597,0.774597,0.774597,1.0}; GLfloat emission[] = {0,0,0,0}; GLfloat shininess[] = {128}; glMaterialfv(GL_FRONT, GL_AMBIENT, ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, specular); glMaterialfv(GL_FRONT, GL_EMISSION, emission); glMaterialfv(GL_FRONT, GL_SHININESS, shininess); glColor3f(0.30f, 0.30f, 0.30f); glPushMatrix(); if (debug) // Debug Sphere glutWireSphere(_radius, 13 ,5); glPopMatrix(); glTranslated(0, 0 , -1.5); //Asa esquerda - cima glPushMatrix(); glBegin(GL_TRIANGLE_FAN); glNormal3f(1.0f, 1.0f, 1.0f); glVertex3f(-4,-3,4); glNormal3f(0.0f, 1.0f, 1.0f); glVertex3f(-7.5,-3.5,3.5); glNormal3f(-1.0f, 0.0f, 0.0f); glVertex3f(-11,-4,3); glNormal3f(-1.0f, 1.0f, 0.0f); glVertex3f(-11,-5,3); glNormal3f(-1.0f, 1.0f, 0.0f); glVertex3f(-11,-6,3); glNormal3f(0.0f, -1.0f, 0.0f); glVertex3f(-7.5,-6.5,3.5); glNormal3f(0.0f, -1.0f, 0.0f); glVertex3f(-4,-7,4); glNormal3f(-1.0f, 0.0f, 1.0f); glVertex3f(-4,-6,4); glNormal3f(-1.0f, 0.0f, 1.0f); glVertex3f(-4,-5,4); glNormal3f(-1.0f, 0.0f, 1.0f); glVertex3f(-4,-4,4); glNormal3f(0.0f, 0.0f, 1.0f); glVertex3f(-7.5,-5,3.5); glEnd(); glPopMatrix(); // Asa direita - cima glPushMatrix(); glBegin(GL_TRIANGLE_FAN); glNormal3f(-1.0f, 1.0f, 1.0f); glVertex3f(4,-3,4); glNormal3f(0.0f, 1.0f, 1.0f); glVertex3f(7.5,-3.5,3.5); glNormal3f(1.0f, 0.0f, 0.0f); glVertex3f(11,-4,3); glNormal3f(1.0f, 1.0f, 0.0f); glVertex3f(11,-5,3); glNormal3f(1.0f, 1.0f, 0.0f); glVertex3f(11,-6,3); glNormal3f(0.0f, -1.0f, 0.0f); glVertex3f(7.5,-6.5,3.5); glNormal3f(0.0f, -1.0f, 0.0f); glVertex3f(4,-7,4); glNormal3f(1.0f, 0.0f, 1.0f); glVertex3f(4,-6,4); glNormal3f(1.0f, 0.0f, 1.0f); glVertex3f(4,-5,4); glNormal3f(1.0f, 0.0f, 1.0f); glVertex3f(4,-4,4); glNormal3f(0.0f, 0.0f, 1.0f); glVertex3f(7.5,-5,3.5); glEnd(); glPopMatrix(); //Asa esquerda - baixo glPushMatrix(); glBegin(GL_TRIANGLE_FAN); glNormal3f(-1.0f, 0.0f, -1.0f); glVertex3f(-4,-3,0); glVertex3f(-7.5,-3.5,0.5); glVertex3f(-11,-4,1); glVertex3f(-11,-5,1); glVertex3f(-11,-6,1); glVertex3f(-7.5,-6.5,0.5); glVertex3f(-4,-7,0); glVertex3f(-4,-6,0); glVertex3f(-4,-5,0); glVertex3f(-4,-4,0); glVertex3f(-7.5,-5,0.5); glEnd(); glPopMatrix(); // Asa direita - baixo glPushMatrix(); glBegin(GL_TRIANGLE_FAN); glNormal3f(1.0f, 0.0f, -1.0f); glVertex3f(4,-3,0); glVertex3f(7.5,-3.5,0.5); glVertex3f(11,-4,1); glVertex3f(11,-5,1); glVertex3f(11,-6,1); glVertex3f(7.5,-6.5,0.5); glVertex3f(4,-7,0); glVertex3f(4,-6,0); glVertex3f(4,-5,0); glVertex3f(4,-4,0); glVertex3f(7.5,-5,0.5); glEnd(); glPopMatrix(); //Asa esquerda - lado - frente glPushMatrix(); glBegin(GL_TRIANGLE_FAN); glNormal3f(-1.0f, 1.0f, 0.0f); glVertex3f(-4,-3,4); glVertex3f(-4,-3,0); glVertex3f(-11,-4,1); glVertex3f(-11,-4,3); glEnd(); glPopMatrix(); // Asa direita - lado - frente glPushMatrix(); glBegin(GL_TRIANGLE_FAN); glNormal3f(1.0f, 1.0f, 0.0f); glVertex3f(4,-3,4); glVertex3f(4,-3,0); glVertex3f(11,-4,1); glVertex3f(11,-4,3); glEnd(); glPopMatrix(); // Asa direita - lado - trás glPushMatrix(); glBegin(GL_TRIANGLE_FAN); glNormal3f(1.0f, -1.0f, 0.0f); glVertex3f(4,-7,4); glVertex3f(4,-7,0); glVertex3f(11,-6,1); glVertex3f(11,-6,3); glEnd(); glPopMatrix(); //Asa esquerda - lado - trás glPushMatrix(); glBegin(GL_TRIANGLE_FAN); glNormal3f(-1.0f, -1.0f, 0.0f); glVertex3f(-4,-7,4); glVertex3f(-4,-7,0); glVertex3f(-11,-6,1); glVertex3f(-11,-6,3); glEnd(); glPopMatrix(); glPushMatrix(); glTranslated(-11.5, -5, 2); glScaled(1, 7, 2); glutSolidCube(1); glPopMatrix(); // missil esq glPushMatrix(); glTranslated(11.5, -5, 2); glScaled(1, 7, 2); glutSolidCube(1); glPopMatrix(); // missil dir glPopMatrix(); //-------- misseis e asas foram descidos com um translate------------------------------- glPushMatrix(); glTranslated(-.5, 9.5, 0); glScaled(1, 1, 2); glutSolidCube(1); glPopMatrix(); glPushMatrix(); glTranslated(.5, 9.5, 0); glScaled(1, 1, 2); glutSolidCube(1); glPopMatrix(); glPushMatrix(); glTranslated(-.5, 8.5, 0); glScaled(1, 1, 2); glutSolidCube(1); glPopMatrix(); glPushMatrix(); glTranslated(.5, 8.5, 0); glScaled(1, 1, 2); glutSolidCube(1); glPopMatrix(); // nariz glPushMatrix(); glBegin(GL_POLYGON); glNormal3f(1.0f, 1.0f, 1.0f); glVertex3f(-4,-3,4); glNormal3f(1.0f, 1.0f, 0.0f); glVertex3f(-4,-7,4); glNormal3f(-1.0f, 1.0f, 0.0f); glVertex3f(4,-7,4); glNormal3f(-1.0f, 1.0f, 1.0f); glVertex3f(4,-3,4); glNormal3f(0.0f, 1.0f, 1.0f); glVertex3f(0,-3,4); glEnd(); glPopMatrix(); //cubo central cima glPushMatrix(); glBegin(GL_POLYGON); glNormal3f(0.0f, 0.0f, -1.0f); glVertex3f(-4,-3,-2); glNormal3f(0.0f, 0.0f, -1.0f); glVertex3f(-4,-7,-2); glNormal3f(0.0f, 0.0f, -1.0f); glVertex3f(4,-7,-2); glNormal3f(0.0f, 0.0f, -1.0f); glVertex3f(4,-3,-2); glNormal3f(0.0f, 0.0f, -1.0f); glVertex3f(0,-3,-2); glEnd(); glPopMatrix(); //cubo central baixo glPushMatrix(); glBegin(GL_POLYGON); glNormal3f(-1.0f, 0.0f, 0.0f); glVertex3f(-4,-3,-2); glNormal3f(-1.0f, 0.0f, 0.0f); glVertex3f(-4,-7,-2); glNormal3f(-1.0f, 0.0f, 0.0f); glVertex3f(-4,-7,4); glNormal3f(-1.0f, 0.0f, 0.0f); glVertex3f(-4,-3,4); glEnd(); glPopMatrix(); //cubo central esq glPushMatrix(); glBegin(GL_POLYGON); glNormal3f(1.0f, 0.0f, 0.0f); glVertex3f(4,-3,-2); glNormal3f(1.0f, 0.0f, 0.0f); glVertex3f(4,-7,-2); glNormal3f(1.0f, 0.0f, 0.0f); glVertex3f(4,-7,4); glNormal3f(1.0f, 0.0f, 0.0f); glVertex3f(4,-3,4); glEnd(); glPopMatrix(); //cubo central dir glPushMatrix(); glBegin(GL_POLYGON); glNormal3f(0.0f, 1.0f, 0.0f); glVertex3f(-4,-3,-2); glNormal3f(0.0f, 1.0f, 0.0f); glVertex3f(4,-3,-2); glNormal3f(0.0f, 1.0f, 0.0f); glVertex3f(4,-3,4); glNormal3f(0.0f, 1.0f, 0.0f); glVertex3f(-4,-3,4); glEnd(); glPopMatrix(); //cubo central frente glPushMatrix(); glBegin(GL_POLYGON); glNormal3f(0.0f, -1.0f, 0.0f); glVertex3f(-4,-7,-2); glNormal3f(0.0f, -1.0f, 0.0f); glVertex3f(4,-7,-2); glNormal3f(0.0f, -1.0f, 0.0f); glVertex3f(4,-7,4); glNormal3f(0.0f, -1.0f, 0.0f); glVertex3f(-4,-7,4); glEnd(); glPopMatrix(); //cubo central trás for (float cx = -1.5; cx <= 1.5 ;cx++) { glPushMatrix(); glTranslated(cx, -7.5, 1); glScaled(1, 1, 4); glutSolidCube(1); glPopMatrix(); } glPushMatrix(); glTranslated(0, -8.5, 1); glScaled(2, 1, 2); glutSolidCube(1); glPopMatrix(); //traseira for (float cy = -7.5; cy >= -9.5; cy--) { glPushMatrix(); glTranslated(-3.5, cy, 2); glScaled(1, 1, 2); glutSolidCube(1); glPopMatrix(); } // motor esq for (float cy = -7.5; cy >= -9.5; cy--) { glPushMatrix(); glTranslated(3.5, cy, 2); glScaled(1, 1, 2); glutSolidCube(1); glPopMatrix(); } // motor dir //----------------------------------- glPushMatrix(); glBegin(GL_POLYGON); glNormal3f(1.0f, 1.0f, 1.0f); glVertex3f (-3,-3,4); // esq - baixo - frente glNormal3f(0.0f, 1.0f, 1.0f); glVertex3f (0,-3,4); // esq - baixo - frente glNormal3f(-1.0f, 1.0f, 1.0f); glVertex3f (3,-3,4); // dir - baixo - frente glNormal3f(1.0f, 1.0f, 0.0f); glVertex3f (1,8,1); // dir - cima - frente glNormal3f(-1.0f, 1.0f, 0.0f); glVertex3f (-1,8,1); // esq - cima - frente glEnd(); glBegin(GL_POLYGON); glNormal3f(.0f, 0.0f, -1.0f); glVertex3f (-1,8,-1); // esq - cima - tras glVertex3f (1,8,-1); // dir - cima - tras glVertex3f (3,-3,-2); // dir - baixo - tras glVertex3f (-3,-3,-2); // esq - baixo - tras glEnd(); glBegin(GL_POLYGON); glNormal3f(-1.0f, 0.0f, 0.0f); glVertex3f (-1,8,-1); // esq - cima - tras glVertex3f (-1,8,1); // esq - cima - frente glVertex3f (-3,-3,4); // esq - baixo - frente glVertex3f (-3,-3,-2); // esq - baixo - tras glEnd(); glBegin(GL_POLYGON); glNormal3f(1.0f, 0.0f, 0.0f); glVertex3f (1,8,-1); // dir - cima - tras glVertex3f (3,-3,-2); // dir - baixo - tras glVertex3f (1,8,1); // dir - cima - frente glVertex3f (3,-3,4); // dir - baixo - frente glEnd(); glPopMatrix(); // ponta da nave glPopMatrix(); glPopMatrix(); _coord = x; }
void displayScene (struct winampVisModule *this_mod) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); GLfloat lcolor = (GLfloat)winampDetectBass(this_mod,0,100)/100.0; rotateFactor += rotateRate; if (rotateFactor >= 1.0) rotateFactor = 0.0; /*Draw circle surface*/ if(SURFACE) { glColor3d(0.86,0.86,0.86); glBegin(GL_POLYGON); glVertex3d(0.0,0.0,0.0); for(double x = 1.02; x >=0; x -= .02) { glVertex3d(groundRad*my_cos(x), 0.0, groundRad*my_sin(x) ); } glEnd(); } if (WAVEFORMCIRCLES) { drawWaveformCircles(this_mod, NUM_CIRCLES); } /*Draw spheres and belonging cones to bump them*/ for(int o=0; o<NUMSPHERES; o++) { glPushMatrix(); //store the origin //get the next sphere from the ordered list by index i int i=order[o][0]; //Draw cones if(CONES) { glColor3d(0.9,0.9,0.9); glTranslatef(sphere[i].x,0.0,sphere[i].z); glRotatef(-90.0,1.0,0.0,0.0); //The cone is always 1/10 high as the height of its sphere if(sphere[i].firstUp) { glutSolidCone(sphere[i].r/1.5, sphere[i].height/10, 20.0+sphere[i].height/10, 10.0+sphere[i].height/8); } //if ball is bouncing draw the cone pretty small else { glutSolidCone(sphere[i].r/1.5, 0.1, 20.0+(int)((1-NUMSPHERES/MAXSPHERES)*(sphere[i].r/10)), 3.0); } glPopMatrix(); glPushMatrix(); } //-------->>>>> //Sound input for the balls goes here for sphere with size sphere[i].r //Input ranges from 0-MAXSTRENGTH, so now from 0-100 //the input is only computed if the ball is not in the air if (!sphere[i].inAir) input=computeSoundInput(i, NUMSPHERES, this_mod, BT_BEAT); //this function bumps the ball up and is called each time, it actually just bumps the ball up, //when it is on the ground and so just disregard the input if not. bump(&sphere[i], input); //-------->>>>> //Draw the sphere if (SPHERES) { glColor3fv(sphere[i].color); glTranslatef(sphere[i].x,sphere[i].r+sphere[i].height,sphere[i].z); if(SQUASH) { double squash = (sphere[i].height/100.0)*0.6 + 0.5; glScaled(1.0, squash,1.0); } glutSolidSphere(sphere[i].r, 20.0+(int)((1-NUMSPHERES/MAXSPHERES)*(sphere[i].r/10)), 50.0+(int)((1-NUMSPHERES/MAXSPHERES)*(sphere[i].r))); } glPopMatrix(); //restore the origin } /*Text output*/ setOrthographicProjection(); //switch to orthographic projection to easier print out text glPushMatrix(); glLoadIdentity(); //Data ouput of current settings if(OUTPUT) { char temp[50]; glColor4f(1.0,1.0,1.0, 1.0); //Number of Balls sprintf(temp," # Balls: %.d", NUMSPHERES); printOut(10,10,temp); //Balls on/off? sprintf(temp," Balls: %s", (SPHERES)?"on":"off"); printOut(10,25,temp); //Airtime sprintf(temp," max. Airtime: %.1f", NUMSEC); printOut(10,40,temp); //Speedfactor sprintf(temp," Speedfactor: %.1f", SPEEDFACTOR); printOut(10,55,temp); //Cones on/off? sprintf(temp," Cones: %s", (CONES)?"on":"off"); printOut(10,70,temp); //Surface on/off? sprintf(temp," Surface: %s", (SURFACE)?"on":"off"); printOut(10,85,temp); //Bouncing balls? sprintf(temp,"Bouncing Balls: %s", (BOUNCE)?"on":"off"); printOut(10,100,temp); //Squash balls? sprintf(temp," Squash Balls: %s", (SQUASH)?"on":"off"); printOut(10,115,temp); //Beat Circles? sprintf(temp," Beat Circles: %s", (WAVEFORMCIRCLES)?"on":"off"); printOut(10, 130, temp); //Color change? sprintf(temp," Change color: %s", (COLORCHANGE)?"on":"off"); printOut(10,145,temp); //Index color of balls printOut(10,160," Start color: "); char * color; if(COLOR==0) color="white"; if(COLOR==1) {color="red"; glColor3f(1.0,0.0,0.0);} if(COLOR==2) {color="green"; glColor3f(0.0,1.0,0.0);} if(COLOR==3) {color="blue"; glColor3f(0.0,0.0,1.0);} if(COLOR==4) {color="yellow"; glColor3f(1.0,1.0,0.0);} if(COLOR==5) {color="magenta"; glColor3f(1.0,0.0,1.0);} if(COLOR==6) {color="cyan"; glColor3f(0.0,1.0,1.0);} sprintf(temp,"%s", color); printOut(138,160,temp); glColor3f(1.0, 1.0, 1.0); //help message if(!HELP) { glColor3f(1.0,1.0,0.0); printOut(width-20*8,10,"Press \'h\' for help!"); } } //help instructions if(HELP) { glColor3f(1.0,1.0,0.0); int x=200; int y=0; printOut(x,y+10," h = switch help on/off"); printOut(x,y+25," o = switch output of the current settings on/off"); printOut(x,y+55,"z/x = decrease/increase number of balls"); printOut(x,y+70,"u/i = decrease/increase the maximum airtime of the balls"); printOut(x,y+85,"j/k = decrease/increase the speed factor of the balls"); printOut(x,y+100,"n/m = decrease/increase the start color of the balls"); printOut(x,y+130," c = display cones?"); printOut(x,y+145," s = display white circle surface?"); printOut(x,y+160," w = display beat circles?"); printOut(x,y+175," a = display balls?"); printOut(x,y+190," b = allow balls to bounce on the ground?"); printOut(x,y+205," t = allow balls to be squashed?"); printOut(x,y+220," l = allow balls to change color?"); printOut(x,y+250," r = reset all settings to default value"); printOut(x,y+280,"by Ryan Messner and Simon Beisel"); } glPopMatrix(); resetPerspectiveProjection(); //reset to old view glFlush(); /* clear buffers */ //glutSwapBuffers(); /*swap the buffers*/ }
void OpenGLRenderInterface::scale(const Eigen::Vector3d& _scale) { glScaled(_scale[0], _scale[1], _scale[2]); }
void LightingScene::display() { // ---- BEGIN Background, camera and axis setup // Clear image and depth buffer everytime we update the scene glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); // Initialize Model-View matrix as identity (no transformation glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Apply transformations corresponding to the camera position relative to the origin CGFscene::activeCamera->applyView(); light0->draw(); light1->draw(); light2->draw(); light3->draw(); // Draw axis axis.draw(); // ---- END Background, camera and axis setup // ---- BEGIN Primitive drawing section //First Table glPushMatrix(); glTranslated(5,0,8); table->draw(tableAppearance, materialA); glPopMatrix(); //Second Table //glPushMatrix(); // glTranslated(12,0,8); // table->draw(tableAppearance, materialA); //glPopMatrix(); // Cilindro glPushMatrix(); glTranslated(5,0,12); glScaled(1,5,1); materialA->apply(); cilindro->draw(); glPopMatrix(); // Cilindro 2 //glPushMatrix(); // glTranslated(10,0,12); // glScaled(1,5,1); // materialA->apply(); // cilindro2->draw(); //glPopMatrix(); //Floor glPushMatrix(); glTranslated(7.5,0,7.5); glScaled(15,0.2,15); floorAppearance->apply(); //materialA->apply(); wall->drawT(10,12); glPopMatrix(); //LeftWall glPushMatrix(); glTranslated(0,4,7.5); glRotated(-90.0,0,0,1); glRotated(90.0,0,1,0); glScaled(15,0.2,8); windowAppearance->setTextureWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE); windowAppearance->apply(); wall->drawHole(); //wall->drawCentered(); glPopMatrix(); //Landscape glPushMatrix(); glTranslated(-5,6,7.5); glRotated(-90.0,0,0,1); glRotated(90.0,0,1,0); glScaled(33,0.2,25); //landscapeAppearance->setTextureWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE); landscapeAppearance->apply(); //wall->drawHole(); wall->draw(); glPopMatrix(); //PlaneWall glPushMatrix(); glTranslated(7.5,4,0); glRotated(90.0,1,0,0); glScaled(15,0.2,8); materialA->apply(); wall->draw(); glPopMatrix(); // Board A glPushMatrix(); glTranslated(4,4,0.2); glScaled(BOARD_WIDTH,BOARD_HEIGHT,1); glRotated(90.0,1,0,0); slidesAppearance->apply(); boardA->draw(); glPopMatrix(); // Board B glPushMatrix(); glTranslated(10.5,4,0.2); glScaled(BOARD_WIDTH,BOARD_HEIGHT,1); glRotated(90.0,1,0,0); boardAppearance->setTextureWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE); boardAppearance->apply(); boardB->draw(512,372); glPopMatrix(); // Relogio glPushMatrix(); relogioAppearance->apply(); relogio->draw(); materialB->apply(); glPopMatrix(); // Robot if (robottexture == 1) robotAppearance->setTexture("../textures/robot1.jpg"); else if(robottexture == 2) robotAppearance->setTexture("../textures/floor.png"); else if(robottexture==3) robotAppearance->setTexture("../textures/landscape.jpg"); glPushMatrix(); robotAppearance->setTextureWrap(GL_REPEAT, GL_REPEAT); robotAppearance->apply(); robot->draw(mode); glPopMatrix(); // ---- END Primitive drawing section // We have been drawing in a memory area that is not visible - the back buffer, // while the graphics card is showing the contents of another buffer - the front buffer // glutSwapBuffers() will swap pointers so that the back buffer becomes the front buffer and vice-versa glutSwapBuffers(); }
// obyek yang akan digambar void draw(){ //meja glColor3f(0, 0, 1); glPushMatrix(); glScaled(2, 0.1, 1); glutSolidCube(0.8); glPopMatrix(); //net glColor3f(0, 0, 0); glPushMatrix(); glTranslated(0, 0.045, 0.41); glScaled(0.05, 0.3, 0.05); glutSolidCube(0.5); glPopMatrix(); glColor3f(0, 0, 0); glPushMatrix(); glTranslated(0, 0.045, -0.41); glScaled(0.05, 0.3, 0.05); glutSolidCube(0.5); glPopMatrix(); glColor3f(1, 1, 1); glPushMatrix(); glTranslated(0, 0.045, 0); glScaled(0.05, 0.3, 1.6); glutSolidCube(0.5); glPopMatrix(); //garis meja glColor3f(1, 1, 1); glPushMatrix(); glTranslated(0, 0.04, 0); glScaled(1.9, 0.01, 0.01); glutSolidCube(0.8); glPopMatrix(); glColor3f(1, 1, 1); glPushMatrix(); glTranslated(0, 0.04, 0.38); glScaled(1.9, 0.01, 0.01); glutSolidCube(0.8); glPopMatrix(); glColor3f(1, 1, 1); glPushMatrix(); glTranslated(0, 0.04, -0.38); glScaled(1.9, 0.01, 0.01); glutSolidCube(0.8); glPopMatrix(); glColor3f(1, 1, 1); glPushMatrix(); glTranslated(0.755, 0.04, 0); glScaled(0.01, 0.01, 0.95); glutSolidCube(0.8); glPopMatrix(); glColor3f(1, 1, 1); glPushMatrix(); glTranslated(-0.755, 0.04, 0); glScaled(0.01, 0.01, 0.95); glutSolidCube(0.8); glPopMatrix(); //kaki meja glColor3f(0, 0, 0); glPushMatrix(); glTranslated(0.5, -0.18, 0.2); glScaled(0.05, 0.7, 0.05); glutSolidCube(0.5); glPopMatrix(); glColor3f(0, 0, 0); glPushMatrix(); glTranslated(-0.5, -0.18, 0.2); glScaled(0.05, 0.7, 0.05); glutSolidCube(0.5); glPopMatrix(); glColor3f(0, 0, 0); glPushMatrix(); glTranslated(-0.5, -0.18, -0.2); glScaled(0.05, 0.7, 0.05); glutSolidCube(0.5); glPopMatrix(); glColor3f(0, 0, 0); glPushMatrix(); glTranslated(0.5, -0.18, -0.2); glScaled(0.05, 0.7, 0.05); glutSolidCube(0.5); glPopMatrix(); //tambahan kaki meja glColor3f(0, 0, 0); glPushMatrix(); glTranslated(0.5, -0.18, 0); glScaled(0.05, 0.05, 0.8); glutSolidCube(0.5); glPopMatrix(); glColor3f(0, 0, 0); glPushMatrix(); glTranslated(-0.5, -0.18, 0); glScaled(0.05, 0.05, 0.8); glutSolidCube(0.5); glPopMatrix(); glFlush(); }
inline void Streamsurface<DataSetWrapperParam>::glRenderAction( GLContextData& contextData) const { /* Set up OpenGL state for stream surface rendering: */ GLboolean cullFaceEnabled=glIsEnabled(GL_CULL_FACE); if(cullFaceEnabled) glDisable(GL_CULL_FACE); GLboolean lightingEnabled=glIsEnabled(GL_LIGHTING); if(!lightingEnabled) glEnable(GL_LIGHTING); GLboolean normalizeEnabled=glIsEnabled(GL_NORMALIZE); if(!normalizeEnabled) glEnable(GL_NORMALIZE); GLboolean lightModelTwoSide; glGetBooleanv(GL_LIGHT_MODEL_TWO_SIDE,&lightModelTwoSide); if(!lightModelTwoSide) glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE); GLboolean colorMaterialEnabled=glIsEnabled(GL_COLOR_MATERIAL); if(colorMaterialEnabled) glDisable(GL_COLOR_MATERIAL); GLMaterial frontMaterial=glGetMaterial(GLMaterialEnums::FRONT); GLMaterial backMaterial=glGetMaterial(GLMaterialEnums::BACK); glMaterial(GLMaterialEnums::FRONT_AND_BACK,GLMaterial(GLMaterial::Color(1.0f,1.0f,1.0f),GLMaterial::Color(0.6f,0.6f,0.6f),25.0f)); GLint colorControl; glGetIntegerv(GL_LIGHT_MODEL_COLOR_CONTROL,&colorControl); glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR); GLboolean texture1DEnabled=glIsEnabled(GL_TEXTURE_1D); if(!texture1DEnabled) glEnable(GL_TEXTURE_1D); GLboolean texture2DEnabled=glIsEnabled(GL_TEXTURE_2D); if(texture2DEnabled) glDisable(GL_TEXTURE_2D); GLboolean texture3DEnabled=glIsEnabled(GL_TEXTURE_3D); if(texture3DEnabled) glDisable(GL_TEXTURE_3D); /* Upload the color map as a 1D texture: */ glTexParameteri(GL_TEXTURE_1D,GL_TEXTURE_BASE_LEVEL,0); glTexParameteri(GL_TEXTURE_1D,GL_TEXTURE_MAX_LEVEL,0); glTexParameteri(GL_TEXTURE_1D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_1D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_1D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexImage1D(GL_TEXTURE_1D,0,GL_RGBA8,256,0,GL_RGBA,GL_FLOAT,colorMap->getColors()); glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE); GLint matrixMode; glGetIntegerv(GL_MATRIX_MODE,&matrixMode); if(matrixMode!=GL_TEXTURE) glMatrixMode(GL_TEXTURE); glPushMatrix(); glLoadIdentity(); double mapMin=colorMap->getScalarRangeMin(); double mapRange=colorMap->getScalarRangeMax()-mapMin; glScaled(1.0/mapRange,1.0,1.0); glTranslated(-mapMin,0.0,0.0); glColor4f(1.0f,1.0f,1.0f,1.0f); /* Render the stream surface representation: */ surface.glRenderAction(contextData); /* Reset OpenGL state: */ glPopMatrix(); if(matrixMode!=GL_TEXTURE) glMatrixMode(matrixMode); if(texture3DEnabled) glEnable(GL_TEXTURE_3D); if(texture2DEnabled) glEnable(GL_TEXTURE_2D); if(!texture1DEnabled) glDisable(GL_TEXTURE_1D); glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,colorControl); glMaterial(GLMaterialEnums::FRONT,frontMaterial); glMaterial(GLMaterialEnums::BACK,backMaterial); if(colorMaterialEnabled) glEnable(GL_COLOR_MATERIAL); if(!lightModelTwoSide) glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_FALSE); if(!normalizeEnabled) glDisable(GL_NORMALIZE); if(!lightingEnabled) glDisable(GL_LIGHTING); if(cullFaceEnabled) glEnable(GL_CULL_FACE); }
void GLShape::draw() { glPushMatrix(); glScaled(mScaleX, mScaleY, mScaleZ); static GLfloat normal[] = {0,0,0}; static GLfloat vertices [][3] = { //backface {1.0f,1.0f,1.0f}, {-1.0f,1.0f,1.0f}, {-1.0f,-1.0f,1.0f}, {1.0f,-1.0f,1.0f}, //frontface {1.0f,1.0f,-1.0f}, {-1.0f,1.0f,-1.0f}, {-1.0f,-1.0f,-1.0f}, {1.0f,-1.0f,-1.0f}, //topface {1.0f,1.0f,1.0f}, {-1.0f,1.0f,1.0f}, {-1.0f,1.0f,-1.0f}, {1.0f,1.0f,-1.0f}, //bottomface {1.0f,-1.0f,1.0f}, {-1.0f,-1.0f,1.0f}, {-1.0f,-1.0f,-1.0f}, {1.0f,-1.0f,-1.0f}, //leftFace {1.0f,-1.0f,1.0f}, {1.0f,-1.0f,-1.0f}, {1.0f,1.0f,-1.0f}, {1.0f,1.0f,1.0f}, //rightFace {-1.0f,-1.0f,1.0f}, {-1.0f,-1.0f,-1.0f}, {-1.0f,1.0f,-1.0f}, {-1.0f,1.0f,1.0f}, }; glBegin(GL_QUADS); // draw a box Vector::NormalVectorToPlane(vertices[0],vertices[1],vertices[2],normal); glNormal3fv(normal); glVertex3fv(vertices[0]); glVertex3fv(vertices[1]); glVertex3fv(vertices[2]); glVertex3fv(vertices[3]); //front Vector::NormalVectorToPlane(vertices[0],vertices[3],vertices[7],normal); glNormal3fv(normal); glVertex3fv(vertices[0]); glVertex3fv(vertices[3]); glVertex3fv(vertices[7]); glVertex3fv(vertices[4]); //back Vector::NormalVectorToPlane(vertices[1],vertices[5],vertices[6],normal); glNormal3fv(normal); glVertex3fv(vertices[1]); glVertex3fv(vertices[5]); glVertex3fv(vertices[6]); glVertex3fv(vertices[2]); //left Vector::NormalVectorToPlane(vertices[3],vertices[2],vertices[6],normal); glNormal3fv(normal); glVertex3fv(vertices[3]); glVertex3fv(vertices[2]); glVertex3fv(vertices[6]); glVertex3fv(vertices[7]); //right Vector::NormalVectorToPlane(vertices[1],vertices[0],vertices[4],normal); glNormal3fv(normal); glVertex3fv(vertices[1]); glVertex3fv(vertices[0]); glVertex3fv(vertices[4]); glVertex3fv(vertices[5]); //bottom Vector::NormalVectorToPlane(vertices[4],vertices[7],vertices[6],normal); glNormal3fv(normal); glVertex3fv(vertices[4]); glVertex3fv(vertices[7]); glVertex3fv(vertices[6]); glVertex3fv(vertices[5]); glEnd(); /* glPushAttrib(GL_COLOR_MATERIAL); Material::getInstance()->currentMaterialChrome(); glBegin(GL_LINES); glColor3f(1.0f,0.0f,0.0f); glVertex3d(t.x , t.y , t.z); glColor3f(0.0f,1.0f,0.0f); glVertex3d(direction.x,direction.y,direction.z); glEnd(); glPopAttrib(); */ glPopMatrix(); }
void Boat::drawCannonBarrel(double height) { double length=.22; double radius=.09; double thickness=.02; double inc=4; // transform glPushMatrix(); glTranslated(0,height,0); glRotated(cannonHorizAngle,0,1,0); glRotated(cannonVertAngle,0,0,1); // Begin drawing // Sphere glPushMatrix(); glScaled(.15,.15,.15); for (double i=0;i<180;i+=inc) { glBegin(GL_QUAD_STRIP); for (double j=0;j<=360;j+=inc) { glNormal3f( Cos(j)*Sin(i), Cos(i), Sin(j)*Sin(i)); glTexCoord2f(j/360, i/180); glVertex3f(Cos(j+0 )*Sin(i+0 ), Cos(i+0 ), Sin(j+0 )*Sin(i+0 )); glNormal3f( Cos(j)*Sin(i+inc), Cos(i+inc), Sin(j)*Sin(i+inc)); glTexCoord2f(j/360, (i+inc)/180); glVertex3f(Cos(j+0 )*Sin(i+inc), Cos(i+inc), Sin(j+0 )*Sin(i+inc)); } glEnd(); } glPopMatrix(); // Outside surface glBegin(GL_QUAD_STRIP); for(double i=0;i<=360;i+=5) { glNormal3f( 0,Sin(i), Cos(i)); glTexCoord2f(i/360,0); glVertex3d(0,Sin(i)*radius,Cos(i)*radius); glTexCoord2f(i/360,.2); glVertex3d(length,Sin(i)*radius,Cos(i)*radius); } glEnd(); // Inside surface glBegin(GL_QUAD_STRIP); for(double i=0;i<=360;i+=5) { glNormal3f( 0,-Sin(i), -Cos(i)); glTexCoord2f(i/360,0); glVertex3d(0,Sin(i)*(radius-thickness),Cos(i)*(radius-thickness) ); glTexCoord2f(i/360,.2); glVertex3d(length,Sin(i)*(radius-thickness),Cos(i)*(radius-thickness) ); } glEnd(); // End glBegin(GL_QUAD_STRIP); glNormal3f( 1,0,0); for(int i=0;i<=360;i+=5) { glTexCoord2f(.5+Sin(i)*.5, .5+Cos(i)*.5 ); glVertex3d(length,Sin(i)*(radius-thickness),Cos(i)*(radius-thickness) ); glTexCoord2f(.5+Sin(i)*.45, .5+Cos(i)*.45 ); glVertex3d(length,Sin(i)*radius,Cos(i)*radius); } glEnd(); // Black spot inside glBegin(GL_POLYGON); glColor3f(0,0,0); glNormal3f(-1,0,0); for(int i=0;i<=360;i+=5) { glVertex3d(.15,Sin(i)*(radius-thickness),Cos(i)*(radius-thickness)); } glEnd(); glPopMatrix(); }
void InteractiveWidget::DrawWidget() const { glPushAttrib( GL_LIGHTING_BIT | GL_ENABLE_BIT ); glEnable( GL_LIGHTING ); glPushMatrix(); glMultMatrixd( &m_matTrans(0,0) ); glMultMatrixd( &m_matTransDelta(0,0) ); glMultMatrixd( &m_matRot(0,0) ); glMultMatrixd( &m_matRotDelta(0,0) ); glMultMatrixd( &m_matScale(0,0) ); glMultMatrixd( &m_matScaleDelta(0,0) ); // ToDo: use sphere class to draw widget center //static Sphere sphere(2); SetSelectColor( TRANS ); glPushMatrix(); glScaled(0.1, 0.1, 0.1); //sphere.draw(); glPopMatrix(); if ( m_typeTransform == NONE || m_typeTransform == TRANS_X ) { SetSelectColor( TRANS_X ); glPushMatrix(); glRotated( -90, 0,0,1 ); DrawArrow( 1.0, 0.075, 10 ); glPopMatrix(); } if ( m_typeTransform == NONE || m_typeTransform == TRANS_Y ) { SetSelectColor( TRANS_Y ); DrawArrow( 1.0, 0.075, 10 ); } if ( m_typeTransform == NONE || m_typeTransform == TRANS_Z ) { SetSelectColor( TRANS_Z ); glPushMatrix(); glRotated( 90, 1,0,0 ); DrawArrow( 1.0, 0.075, 10 ); glPopMatrix(); } if ( m_typeTransform == NONE || m_typeTransform == SCALE_X ) { SetSelectColor( SCALE_X ); glPushMatrix(); glRotated( -90, 0,0,1 ); DrawSceptre( 0.5, 0.1, 10, 4 ); glPopMatrix(); } if ( m_typeTransform == NONE || m_typeTransform == SCALE_Y ) { SetSelectColor( SCALE_Y ); DrawSceptre( 0.5, 0.1, 10, 4 ); } if ( m_typeTransform == NONE || m_typeTransform == SCALE_Z ) { SetSelectColor( SCALE_Z ); glPushMatrix(); glRotated( 90, 1,0,0 ); DrawSceptre( 0.5, 0.1, 10, 4 ); glPopMatrix(); } SetSelectColor( ROTATE_X ); glPushMatrix(); glRotated( -90, 0,0,1 ); DrawSceptre(1.5, 0.05, 10, 4 ); if ( m_typeMove == ROTATE_X ) { glRotated( 90, 0,0,1 ); SetSelectColor( ROTATE_X, 1 ); DrawCylinderOpen( Point3(0,-0.1,0), 0.2, 1.5, 40 ); glRotated( 90, 1,0,0 ); SetSelectColor( ROTATE_X, 2 ); DrawCylinderOpen( Point3(0,-0.1,0), 0.2, 1.5, 40 ); } glPopMatrix(); glPushMatrix(); SetSelectColor( ROTATE_Y ); DrawSceptre( 1.5, 0.05, 10, 4 ); if ( m_typeMove == ROTATE_Y ) { glRotated( 90, 0,0,1 ); SetSelectColor( ROTATE_Y, 0 ); DrawCylinderOpen( Point3(0,-0.1,0), 0.2, 1.5, 40 ); glRotated( 90, 1,0,0 ); SetSelectColor( ROTATE_Y, 2 ); DrawCylinderOpen( Point3(0,-0.1,0), 0.2, 1.5, 40 ); } glPopMatrix(); SetSelectColor( ROTATE_Z ); glPushMatrix(); glRotated( 90, 1,0,0 ); DrawSceptre( 1.5, 0.05, 10, 4 ); if ( m_typeMove == ROTATE_Z ) { glRotated( 90, 0,0,1 ); SetSelectColor( ROTATE_Z, 0 ); DrawCylinderOpen( Point3(0,-0.1,0), 0.2, 1.5, 40 ); glRotated( 90, 1,0,0 ); SetSelectColor( ROTATE_Z, 1 ); DrawCylinderOpen( Point3(0,-0.1,0), 0.2, 1.5, 40 ); } glPopMatrix(); if ( m_typeTransform == NONE || m_typeTransform == SCALE ) { SetSelectColor( SCALE ); glPushMatrix(); glRotated( 90, 0,0,1 ); glRotated( -45, 1,0,0 ); DrawSceptre( sqrt(2.0) * 0.5, 0.075, 10, 4 ); glPopMatrix(); } glPopMatrix(); glPopAttrib(); }
void GUITLLogicPhasesTrackerWindow::drawValues(GUITLLogicPhasesTrackerPanel& caller) { // compute what shall be shown (what is visible) myFirstPhase2Show = 0; myFirstPhaseOffset = 0; size_t leftOffset = 0; myFirstTime2Show = 0; if (!myAmInTrackingMode) { myPhases.clear(); myDurations.clear(); // insert phases const MSSimpleTrafficLightLogic::Phases& phases = static_cast<MSSimpleTrafficLightLogic*>(myTLLogic)->getPhases(); MSSimpleTrafficLightLogic::Phases::const_iterator j; myLastTime = 0; myBeginTime = 0; for (j = phases.begin(); j != phases.end(); ++j) { myPhases.push_back(*(*j)); myDurations.push_back((*j)->duration); myLastTime += (*j)->duration; } } else { SUMOTime beginOffset = TIME2STEPS(myBeginOffset->getValue()); myBeginTime = myLastTime - beginOffset; myFirstTime2Show = myBeginTime; // check whether no phases are known at all if (myDurations.size() != 0) { SUMOTime durs = 0; size_t phaseOffset = myDurations.size() - 1; DurationsVector::reverse_iterator i = myDurations.rbegin(); while (i != myDurations.rend()) { if (durs + (*i) > beginOffset) { myFirstPhase2Show = phaseOffset; myFirstPhaseOffset = (durs + (*i)) - beginOffset; break; } durs += (*i); phaseOffset--; ++i; } if (i == myDurations.rend()) { // there are too few information stored; myFirstPhase2Show = 0; myFirstPhaseOffset = 0; leftOffset = beginOffset - durs; } } } // begin drawing glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslated(-1, -1, 0); glScaled(2, 2, 1); glDisable(GL_TEXTURE_2D); // draw the horizontal lines dividing the signal groups glColor3d(1, 1, 1); // compute some values needed more than once const SUMOReal height = (SUMOReal) caller.getHeight(); const SUMOReal width = (SUMOReal) caller.getWidth(); pfSetScaleXY((SUMOReal)(.08 * 300. / width), (SUMOReal)(.08 * 300. / height)); const SUMOReal h4 = ((SUMOReal) 4 / height); const SUMOReal h10 = ((SUMOReal) 10 / height); const SUMOReal h16 = ((SUMOReal) 16 / height); const SUMOReal h20 = ((SUMOReal) 20 / height); // draw the link names and the lines dividing them SUMOReal h = (SUMOReal)(1.0 - h10); SUMOReal h2 = 12; for (size_t i = 0; i < myTLLogic->getLinks().size() + 1; ++i) { // draw the bar glBegin(GL_LINES); glVertex2d(0, h); glVertex2d((SUMOReal)(30. / width), h); glEnd(); // draw the name if (i < myTLLogic->getLinks().size()) { glRotated(180, 1, 0, 0); pfSetPosition(0, 0); glTranslated(0.0, -h + h20 - h4, 0); pfDrawString(myLinkNames[i].c_str()); glTranslated(-0.0, h - h20 + h4, 0); glRotated(-180, 1, 0, 0); h2 += 20; } h -= h20; } glBegin(GL_LINES); glVertex2d(0, h + h20); glVertex2d(1.0, h + h20); glEnd(); // draw the names closure (vertical line) h += (SUMOReal) 20 / height; glColor3d(1, 1, 1); glBegin(GL_LINES); glVertex2d((SUMOReal) 30 / width, 1.0); glVertex2d((SUMOReal) 30 / width, h); glEnd(); // draw the phases // disable value addition while drawing myLock.lock(); // determine the initial offset SUMOReal x = ((SUMOReal) 31. / width); SUMOReal ta = (SUMOReal) leftOffset / width; ta *= (SUMOReal)(((width - 31.0) / ((SUMOReal)(myLastTime - myBeginTime)))); x += ta; // and the initial phase information PhasesVector::iterator pi = myPhases.begin() + myFirstPhase2Show; DurationsVector::iterator pd = myDurations.begin() + myFirstPhase2Show; size_t fpo = myFirstPhaseOffset; // start drawing for (size_t i = 30; pd != myDurations.end();) { // the first phase may be drawn incompletely size_t duration = *pd - fpo; // compute the heigh and the width of the phase h = (SUMOReal)(1.0 - h10); SUMOReal a = (SUMOReal) duration / width; a *= (SUMOReal)(((width - 31.0) / ((SUMOReal)(myLastTime - myBeginTime)))); SUMOReal x2 = x + a; // go through the links for (unsigned int j = 0; j < (unsigned int) myTLLogic->getLinks().size(); ++j) { // determine the current link's color LinkState state = (*pi).getSignalState(j); // draw the bar (red is drawn as a line) switch (state) { case LINKSTATE_TL_GREEN_MAJOR: case LINKSTATE_TL_GREEN_MINOR: glColor3d(0, 1.0, 0); glBegin(GL_QUADS); glVertex2d(x, h - h16); glVertex2d(x, h - h4); glVertex2d(x2, h - h4); glVertex2d(x2, h - h16); glEnd(); break; case LINKSTATE_TL_YELLOW_MAJOR: case LINKSTATE_TL_YELLOW_MINOR: glColor3d(1.0, 1.0, 0); glBegin(GL_QUADS); glVertex2d(x, h - h16); glVertex2d(x, h - h4); glVertex2d(x2, h - h4); glVertex2d(x2, h - h16); glEnd(); break; case LINKSTATE_TL_RED: glColor3d(1.0, 0, 0); glBegin(GL_LINES); glVertex2d(x, h - h10); glVertex2d(x2, h - h10); glEnd(); break; default: break; } // proceed to next link h -= h20; } // proceed to next phase i += duration; ++pi; ++pd; x = x2; // all further phases are drawn in full fpo = 0; } // allow value addition myLock.unlock(); glColor3d(1, 1, 1); if (myPhases.size() != 0) { SUMOTime tickDist = TIME2STEPS(10); // patch distances - hack SUMOReal t = myBeginOffset != 0 ? (SUMOReal) myBeginOffset->getValue() : STEPS2TIME(myLastTime - myBeginTime); while (t > (width - 31.) / 4.) { tickDist += TIME2STEPS(10); t -= (SUMOReal)((width - 31.) / 4.); } // draw time information h = (SUMOReal)(myTLLogic->getLinks().size() * 20 + 12); SUMOReal glh = (SUMOReal)(1.0 - myTLLogic->getLinks().size() * h20 - h10); // current begin time pfSetScaleXY((SUMOReal)(.05 * 300. / width), (SUMOReal)(.05 * 300. / height)); // time ticks SUMOTime currTime = myFirstTime2Show; int pos = 31;// + /*!!!currTime*/ - myFirstTime2Show; SUMOReal glpos = (SUMOReal) pos / width; while (pos < width + 50) { const std::string timeStr = time2string(currTime); const SUMOReal w = pfdkGetStringWidth(timeStr.c_str()); glRotated(180, 1, 0, 0); pfSetPosition(0, 0); glTranslated(glpos - w / 2., -glh + h20 - h4, 0); pfDrawString(timeStr.c_str()); glTranslated(-glpos + w / 2., glh - h20 + h4, 0); glRotated(-180, 1, 0, 0); glBegin(GL_LINES); glVertex2d(glpos, glh); glVertex2d(glpos, glh - h4); glEnd(); const SUMOReal a = STEPS2TIME(tickDist) * (width - 31.0) / STEPS2TIME(myLastTime - myBeginTime); pos += (int) a; glpos += a / width; currTime += tickDist; } } }
static GLuint UReadIsosurface ( char *szIsosurfaceFilename, unsigned int uXDim, unsigned int uYDim, unsigned int uZDim, float fIsosurfaceSpacingX, float fIsosurfaceSpacingY, float fIsosurfaceSpacingZ, int ibBothFacesIsosurface ) { size_t uNrOfVertices; size_t uNrOfFaces; size_t uNrOfFaceIndices; float *pfVertices = NULL; float *pfNormals = NULL; size_t *puFaceIndices = NULL; FILE *fpIsosurface; fopen_s(&fpIsosurface, szIsosurfaceFilename, "rt"); assert(fpIsosurface); #define SZ_TEMP_LENGTH 1024 static char szTemp[SZ_TEMP_LENGTH+1]; fgets(szTemp, SZ_TEMP_LENGTH, fpIsosurface); // # vtk DataFile Version 3.0 fgets(szTemp, SZ_TEMP_LENGTH, fpIsosurface); // vtk output fgets(szTemp, SZ_TEMP_LENGTH, fpIsosurface); // ASCII fgets(szTemp, SZ_TEMP_LENGTH, fpIsosurface); // DATASET POLYDATA fscanf(fpIsosurface, "%s", szTemp); // POINTS fscanf(fpIsosurface, "%d", &uNrOfVertices); fscanf(fpIsosurface, "%s", szTemp); // float pfVertices = (float*)calloc(uNrOfVertices * 3, sizeof(pfVertices[0])); assert( pfVertices ); for(size_t v = 0; v < uNrOfVertices; v++) fscanf(fpIsosurface, "%f %f %f", &pfVertices[3 * v], &pfVertices[3 * v + 1], &pfVertices[3 * v + 2]); fscanf(fpIsosurface, "%s", szTemp); // POLYGONS 29314 117256 fscanf(fpIsosurface, "%d %d", &uNrOfFaces, &uNrOfFaceIndices); puFaceIndices = (size_t*)calloc(uNrOfFaceIndices, sizeof(puFaceIndices[0])); assert( puFaceIndices ); for(size_t f = 0, p = 0; f < uNrOfFaces; f++) { size_t uNrOfIndices; fscanf(fpIsosurface, "%d", &uNrOfIndices); puFaceIndices[p] = uNrOfIndices; p++; for(size_t i = 0; i < uNrOfIndices; i++, p++) fscanf(fpIsosurface, "%d", &puFaceIndices[p]); } fgets(szTemp, SZ_TEMP_LENGTH, fpIsosurface); // NORMALS normals float fgets(szTemp, SZ_TEMP_LENGTH, fpIsosurface); // NORMALS normals float pfNormals = (float*)calloc(uNrOfVertices * 3, sizeof(pfNormals[0])); assert( pfNormals ); for(size_t v = 0; v < uNrOfVertices; v++) fscanf(fpIsosurface, "%f %f %f", &pfNormals[3 * v], &pfNormals[3 * v + 1], &pfNormals[3 * v + 2]); fclose(fpIsosurface); GLuint lid = glGenLists(1); glNewList(lid, GL_COMPILE); glPushMatrix(); glTranslatef(-1.0f, -1.0f, -1.0f); glScalef(2.0f, 2.0f, 2.0f); glScaled(1.0/(double)uXDim, 1.0/(double)uYDim, 1.0/(double)uZDim); glScalef(1.0f/fIsosurfaceSpacingX, 1.0f/fIsosurfaceSpacingY, 1.0f/fIsosurfaceSpacingZ); for(size_t i = 0, f = 0, uNrOfIndices = 0; f < uNrOfFaces; f++, i += uNrOfIndices) { uNrOfIndices = puFaceIndices[i++]; glBegin(GL_POLYGON); for(size_t v = 0; v < uNrOfIndices; v++) { glNormal3fv(&pfNormals[3*puFaceIndices[i+v]]); glVertex3fv(&pfVertices[3*puFaceIndices[i+v]]); } glEnd(); if( ibBothFacesIsosurface ) { glBegin(GL_POLYGON); for(size_t v = 0; v < uNrOfIndices; v++) { size_t rv = uNrOfIndices - 1 - v; glNormal3f(-pfNormals[3*puFaceIndices[i+rv]], -pfNormals[3*puFaceIndices[i+rv] + 1], -pfNormals[3*puFaceIndices[i+rv] + 2]); glVertex3fv(&pfVertices[3*puFaceIndices[i+rv]]); } glEnd(); } } glPopMatrix(); glEndList(); free(pfVertices); free(pfNormals); free(puFaceIndices); return lid; }
inline void glScale( const GLdouble & x, const GLdouble & y, const GLdouble & z ) { glScaled( x, y, z ); }
void Inicjuj( sf::RenderWindow &app ) { font.loadFromFile( "fonts/comicbd.ttf" ); std::string str( "Ladowanie textur..." ); CStopWatch timer; pisz( app, str ); const char *chTextures[ LiczbaTextur ] = { "textures/background.tga", "textures/cross.tga", "textures/life.tga", "textures/blood.tga", "textures/enemy.tga", "textures/comet.tga", "textures/bullet.tga", "textures/award.tga" }; GLsizei width, height; GLenum format, type; GLvoid *pixels; glPixelStorei(GL_UNPACK_ALIGNMENT,1); for ( int i = 0; i < LiczbaTextur; ++i ){ if ( !load_targa( chTextures[i], width, height, format, type, pixels) ){ str = "Brak pliku "; str += chTextures[i]; pisz( app, str ); while ( timer.GetElapsedSeconds() < 1.0f ){ continue; } } glGenTextures(1,&t_textures[ i ]); glBindTexture(GL_TEXTURE_2D, t_textures[ i ]); gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA,width,height,format,type,pixels); delete [] (unsigned char *)pixels; } str = "Ladowanie modeli..."; pisz( app, str ); load_obj( "models/award/WoodenBox02.obj", model_award ); load_obj( "models/comet/Rock.obj", model_rock ); load_obj( "models/bullet/bullet.obj", model_bullet ); load_obj( "models/SpaceShip/fighter.obj", model_space_ship ); str = "Ladowanie dzwiekow..."; pisz( app, str ); const char *chMusic[ LiczbaDzwiekow ] = { "sounds/MenuBackground#1.ogg", "sounds/MenuBackground#2.ogg", "sounds/Background.ogg", "sounds/fire.ogg", "sounds/Award.ogg", "sounds/ColShipComet.ogg", "sounds/ColShipShip.ogg", "sounds/CometExplo.ogg", "sounds/lifeLost.ogg", "sounds/ShipExplo.ogg", "sounds/hit.ogg" }; for ( int i = 0; i < LiczbaDzwiekow; ++i ){ if ( !sounds[i].openFromFile( chMusic[i] ) ){ str = "Brak pliku "; str += chMusic[i]; pisz( app, str ); while ( timer.GetElapsedSeconds() < 1.0f ){ continue; } } } sounds[0].setRelativeToListener( true ); sounds[1].setRelativeToListener( true ); sounds[2].setRelativeToListener( true ); sounds[3].setRelativeToListener( true ); sounds[4].setRelativeToListener( true ); sounds[8].setRelativeToListener( true ); sounds[10].setRelativeToListener( true ); sounds[2].setLoop( true ); sounds[2].setVolume( 20 ); sounds[9].setMinDistance( 7.0f ); sounds[9].setAttenuation( 15.0f ); sounds[7].setMinDistance( 7.0f ); sounds[7].setAttenuation( 15.0f ); sf::Listener::setGlobalVolume( 100.f ); sf::Listener::setDirection( 0.0f, 0.0f, -1.0f ); str = "Inicjowaie list wyswietlania..."; pisz( app, str ); ///Lista tla! list_SkyBox = glGenLists( 1 ); glNewList( list_SkyBox, GL_COMPILE ); glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, t_textures[0] ); glBegin( GL_QUADS ); ///Tyl glNormal3f( 0.0f, 0.0f, 1.0f ); glTexCoord2f(0, 1); glVertex3f(-1, -1, 1); glTexCoord2f(1, 1); glVertex3f(1, -1, 1); glTexCoord2f(1, 0); glVertex3f(1, 1, 1); glTexCoord2f(0, 0); glVertex3f(-1, 1, 1); glEnd(); glDisable( GL_TEXTURE_2D ); glEndList(); ///Lista celownika list_cross = glGenLists( 1 ); glNewList( list_cross, GL_COMPILE ); glColor3fv( White ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glEnable( GL_BLEND ); glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, t_textures[1] ); glBegin( GL_QUADS ); glNormal3f( 0.0f, 0.0f, 1.0f ); glTexCoord2f(0, 1); glVertex3f(-1, -1, 1); glTexCoord2f(1, 1); glVertex3f(1, -1, 1); glTexCoord2f(1, 0); glVertex3f(1, 1, 1); glTexCoord2f(0, 0); glVertex3f(-1, 1, 1); glEnd(); glDisable( GL_TEXTURE_2D ); glDisable( GL_BLEND ); glEndList(); ///lista zycia list_life = glGenLists( 1 ); glNewList( list_life, GL_COMPILE ); glColor3fv( White ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glEnable( GL_BLEND ); glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, t_textures[2] ); glBegin( GL_QUADS ); glNormal3f( 0.0f, 0.0f, 1.0f ); glTexCoord2f(0, 1); glVertex3f(-1, -1, 1); glTexCoord2f(1, 1); glVertex3f(1, -1, 1); glTexCoord2f(1, 0); glVertex3f(1, 1, 1); glTexCoord2f(0, 0); glVertex3f(-1, 1, 1); glEnd(); glDisable( GL_TEXTURE_2D ); glDisable( GL_BLEND ); glEndList(); ///lista krwi list_blood = glGenLists( 1 ); glNewList( list_blood, GL_COMPILE ); glColor3fv( White ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glEnable( GL_BLEND ); glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, t_textures[3] ); glBegin( GL_QUADS ); glNormal3f( 0.0f, 0.0f, 1.0f ); glTexCoord2f(0, 1); glVertex3f(-1, -1, 1); glTexCoord2f(1, 1); glVertex3f(1, -1, 1); glTexCoord2f(1, 0); glVertex3f(1, 1, 1); glTexCoord2f(0, 0); glVertex3f(-1, 1, 1); glEnd(); glDisable( GL_TEXTURE_2D ); glDisable( GL_BLEND ); glEndList(); list_dron = glGenLists( 1 ); glNewList( list_dron, GL_COMPILE ); glEnable( GL_LIGHTING ); glEnable( GL_LIGHT0 ); glEnable( GL_COLOR_MATERIAL ); glColorMaterial( GL_FRONT, GL_AMBIENT ); glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, t_textures[4] ); glRotatef( -90.0f, 1.0f, 0.0f, 0.0f ); glScalef( 0.22f, 0.22f, 0.22f ); glCallList( model_space_ship ); glDisable( GL_TEXTURE_2D ); glDisable( GL_COLOR_MATERIAL ); glDisable( GL_LIGHTING ); glEndList(); list_award = glGenLists( 1 ); glNewList( list_award, GL_COMPILE ); glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, t_textures[7] ); glEnable( GL_LIGHTING ); glEnable( GL_LIGHT0 ); glEnable( GL_COLOR_MATERIAL ); glColorMaterial( GL_FRONT, GL_AMBIENT ); glCallList( model_award ); glDisable( GL_COLOR_MATERIAL ); glDisable( GL_LIGHTING ); glDisable( GL_TEXTURE_2D ); glEndList(); list_rock = glGenLists( 1 ); glNewList( list_rock, GL_COMPILE ); glEnable( GL_LIGHTING ); glEnable( GL_LIGHT0 ); glEnable( GL_COLOR_MATERIAL ); glColorMaterial( GL_FRONT, GL_AMBIENT ); glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, t_textures[5] ); glCallList( model_rock ); glDisable( GL_TEXTURE_2D ); glDisable( GL_COLOR_MATERIAL ); glDisable( GL_LIGHTING ); glEndList(); list_bullet = glGenLists( 1 ); glNewList( list_bullet, GL_COMPILE ); glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, t_textures[6] ); glScaled(0.7,0.7,0.7); glCallList( model_bullet ); glDisable( GL_TEXTURE_2D ); glEndList(); str = "Pobieranie rankingu..."; pisz( app, str ); if ( DownloadFile() ) { str = "Pobieranie zakonczone..."; } else { str = "Nie udalo sie pobrac rankingu!"; } pisz( app, str ); while ( timer.GetElapsedSeconds() < 1.0f ){ continue; } str = "Tworzenie rankingu..."; pisz( app, str ); std::ifstream fin( "ranking.txt" ); if ( fin.good() ) { for ( int i = 0; i < 10; ++i ) { fin >> Top10[i].punkty; fin >> Top10[i].zycia; fin >> Top10[i].statki; fin >> Top10[i].nagrody_zdobyte; fin >> Top10[i].rozwalone_nagrody; fin >> Top10[i].rozbite_asteroidy; char ch; fin.get( ch ); ch = 'p'; while ( ch != '\n' && ch != '\r' ) { fin.get( ch ); Top10[i].name += ch; } } } else {
void drawCylinder(double x,double y,double z, double dx,double dy,double dz, double th, char lcol, char scol) { double i; double radius = 0.3, height = 0.2; glPushMatrix(); // Transform cube glTranslated(x,y,z); glRotated(th,0,0,1); glScaled(dx,dy,dz); //Set colors if (scol == 'r'){ glColor3f(1.0, 0.0, 0.0); //Set color to red } else if (scol == 'g') { glColor3f(0.0, 1.0, 0.0); //Set color to green } else if (scol == 'b') { glColor3f(0.0, 0.0, 1.0); //Set color to blue } else if (scol == 'w') { glColor3f(1.0, 1.0, 1.0); //Set color to white } else { glColor3f(0.8, 0.8, 0.8); //Default color to gray } /* Tube of Cylinder */ glBegin(GL_QUAD_STRIP); for(i = 0.0; i <= 2.1*PI; i+=.05){ glVertex3d(radius * cos(i), height, radius * sin(i)); glVertex3d(radius * cos(i), -height, radius * sin(i)); } glEnd(); //Set colors if (lcol == 'r'){ glColor3f(1.0, 0.0, 0.0); //Set color to red } else if (lcol == 'g') { glColor3f(0.0, 1.0, 0.0); //Set color to green } else if (lcol == 'b') { glColor3f(0.0, 0.0, 1.0); //Set color to blue } else if (lcol == 'w') { glColor3f(1.0, 1.0, 1.0); //Set color to white } else { glColor3f(0.8, 0.8, 0.8); //Default color to gray } /* Top of Cylinder */ glBegin(GL_TRIANGLE_FAN); glVertex3d(0.0, height, 0.0); for(i = 0.0; i < 2*PI*radius*4; i+=.125) { glVertex3d(radius * cos(i), height, radius * sin(i)); } glEnd(); /* Bottom of Cylinder */ glBegin(GL_TRIANGLE_FAN); glVertex3d(0.0, -height, 0.0); for(i = 0.0; i < 2*PI*radius*4; i+=.125) { glVertex3d(radius * cos(i), -height, radius * sin(i)); } glEnd(); glPopMatrix(); }
//-------------------------------------------------------------- void testApp::draw() { //btCollisionWorld::ClosestRayResultCallback rayCallback(rayFrom, rayTo); //getWorld()->rayTest(rayFrom,rayTo,rayCallback); //if (rayCallback.hasHit()) { light.resetTransform(); light.setPosition(ofVec3f(0, 0, 0)); light.orbit(90, -90, 500); camera.begin(); light.enable(); light.draw(); camera.draw(); //glPushMatrix(); //glTranslatef(ofGetWidth()/2, (ofGetHeight()/2), 40); //glScaled(SCALE, SCALE, SCALE); //ofRotateX(90); //ofRotateY(0); glPushMatrix(); glScaled(SCALE, SCALE, SCALE); ofSetColor(25, 225, 125); //bullet.draw(); //drawViaBulletGL(); drawViaCustomGL(); ofSetColor(125, 125, 125); bullet.drawFloor(); glPopMatrix(); light.disable(); camera.end(); /* btVector3 rayTo = bullet.getRayTo(mouseX, mouseY, &camera); ofVec3f camPos = camera.getPosition(); btVector3 rayFrom = btVector3(camPos.x, camPos.y, camPos.z); // printf("TO: %f,%f,%f\n", rayTo.x(), rayTo.y(), rayTo.z()); ofVec3f rayT(rayTo.x(), rayTo.y(), rayTo.z()); ofVec3f rayF(rayFrom.x(), rayFrom.y(), rayFrom.z()); ofPushStyle(); glLineWidth(3); ofSetColor(255, 0, 0); ofLine(rayT, rayF); ofPopStyle(); */ ofSetColor(255, 0, 0); ofSetWindowTitle(ofToString(ofGetFrameRate(), 1)); }
void OpenGLRenderInterface::drawEllipsoid(const Eigen::Vector3d& _size) { glScaled(_size(0), _size(1), _size(2)); drawSphere(0.5); }
void MyWindow::draw() { int i; if (!valid()) { //Init viewport and projection initGL(); double w = this->w(), h = this->h(); glViewport(0, 0, (int)w, (int)h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); double left = -.1; double bottom = -.1; double right = 1.1; double top = 1.1; if(w > 1 && h > 1) { if(w > h) { right = -0.1 + 1.2 * w / h; } if(h > w) { bottom = 1.1 - 1.2 * h / w; } } double scale = 1. / 1000.; left = -w * scale; right = w * scale; bottom = -h * scale; top = h * scale; glFrustum(left, right, bottom, top, 5., 30.); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); //Transform------ Vector3 trans = transform.getTrans(); glTranslated(trans[0], trans[1], -10 + trans[2]); double scale = transform.getScale(); glScaled(scale, scale, scale); Quaternion<> r = transform.getRot(); double ang = r.getAngle(); if(fabs(ang) > 1e-6) { Vector3 ax = r.getAxis(); glRotated(ang * 180. / M_PI, ax[0], ax[1], ax[2]); } //Draw---------- if(floor) drawFloor(); vector<const Mesh *> ms(meshes.size()); for(i = 0; i < (int)meshes.size(); ++i) { ms[i] = &(meshes[i]->getMesh()); } //shadows if(floor) { Vector3 lightRay = transform.getRot().inverse() * Vector3(1, 2, 2); if(lightRay[1] == 0) lightRay[1] = 1e-5; lightRay = -lightRay / lightRay[1]; glDisable(GL_LIGHTING); glColor3f(0.1f, 0.1f, 0.1f); glPushMatrix(); float matr[16] = {1,0,0,0, (float)lightRay[0],0,(float)lightRay[2],0, 0,0,1,0, 0,0.01f,0,1}; glMultMatrixf(matr); glDepthMask(0); for(i = 0; i < (int)ms.size(); ++i) drawMesh(*(ms[i]), flatShading); glDepthMask(1); glEnable(GL_LIGHTING); glPopMatrix(); } static GLfloat colr[4] = {1.f, .9f, .75f, 1.0f }; static GLfloat colrb[4] = {1.f, .9f, .75f, 1.0f }; glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, colr); glMaterialfv( GL_BACK, GL_AMBIENT_AND_DIFFUSE, colrb); //draw meshes for(i = 0; i < (int)meshes.size(); ++i) { drawMesh(*(ms[i]), flatShading); } //draw lines glDisable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); for(i = 0; i < (int)lines.size(); ++i) { glColor3d(lines[i].color[0], lines[i].color[1], lines[i].color[2]); glLineWidth((float)lines[i].thickness); glBegin(GL_LINES); glVertex3d(lines[i].p1[0], lines[i].p1[1], lines[i].p1[2]); glVertex3d(lines[i].p2[0], lines[i].p2[1], lines[i].p2[2]); glEnd(); } if(skeleton) { glLineWidth(5); for(i = 0; i < (int)meshes.size(); ++i) { vector<Vector3> v = meshes[i]->getSkel(); if(v.size() == 0) continue; glColor3d(.5, 0, 0); const vector<int> &prev = human.fPrev(); glBegin(GL_LINES); for(int j = 1; j < (int)prev.size(); ++j) { int k = prev[j]; glVertex3d(v[j][0], v[j][1], v[j][2]); glVertex3d(v[k][0], v[k][1], v[k][2]); } glEnd(); } } }
void weapon_HUD_ARM(Game* game,int mode,double time_offset){ #define BOW_GL_MATRIX() \ double real_rho=game->player->rho +fake_rho;\ double real_theta=game->player->theta+fake_theta;\ glRotated(real_rho*(-4),1,0,0);\ glRotated(real_theta*.5, 0.0, 1.0, 0.0);\ double real_HUD_drho_compensation=HUD_drho_compensation+fake_HUD_drho_compensation;\ glTranslated(0,0,-real_HUD_drho_compensation*real_HUD_drho_compensation*0.0007);\ glTranslated(5,0,-3);\ glTranslated(real_theta*(.05),0,0);\ glRotated(80, 0, 1, 0);\ glRotated(70, 1, 0, 0);\ glRotated(real_theta*(1),0,0,1);\ glRotated(real_HUD_drho_compensation,0,1,0);\ glTranslated(0,0,-1);\ glLineWidth(3.0) double time_pos=game->trigger_value+time_offset; #ifdef VISEUR_ENABLED viseur(game); #endif double oscill_force=.5*sin(SDL_GetTicks()*.001)+.5*sin(SDL_GetTicks()*.00085); glPushMatrix(); BOW_GL_MATRIX(); #define TEMP_MACRO() \ glTranslated(0, 1.5*time_pos, 2*time_pos);\ glRotated(-130*.5*time_pos, 0, 1, 0);\ glRotated(-30*.5*time_pos, 0, 0, 1); glPushMatrix(); TEMP_MACRO(); //ARROW glRotated(60+30*time_pos, 0, 1, 0); glRotated(60+30*time_pos, 1, 0, 0); // glTranslated( // -.3+.1*sin(SDL_GetTicks()*.0017*(1-time_pos)), // 1-.7*time_pos, // -5+1*oscill_force*(1-time_pos)+2*time_pos // ); glTranslated( -.3+.1*sin(SDL_GetTicks()*.0017)*(1-time_pos)-.7*time_pos, 1-.8*time_pos, -5+1*oscill_force*(1-time_pos)+2*time_pos ); glScaled(1,1,1+.2*time_pos); draw_arrow_high_quality(); if(mode){ glPushMatrix(); glTranslated(-1.7,0,1.5); glRotated(10,0,1,0); draw_arrow_high_quality(); glPopMatrix(); glPushMatrix(); glTranslated(1.7,0,0.75); glRotated(-10,0,1,0); draw_arrow_high_quality(); glPopMatrix(); // glPushMatrix(); // glTranslated(-1.3,0,1.7); // glRotated(10,0,1,0); // draw_arrow_high_quality(); // glPopMatrix(); // glPushMatrix(); // glTranslated(1.3,0,1); // glRotated(-10,0,1,0); // draw_arrow_high_quality(); // glPopMatrix(); }if(mode==2){ glPushMatrix(); glTranslated(-3.2,0,3); glRotated(20,0,1,0); draw_arrow_high_quality(); glPopMatrix(); glPushMatrix(); glTranslated(3.2,0,1.5); glRotated(-20,0,1,0); draw_arrow_high_quality(); glPopMatrix(); } glClear(GL_DEPTH_BUFFER_BIT); glPopMatrix(); TEMP_MACRO(); if(time_pos){//stable hands draw_hand(.3*time_pos,2*time_pos,TRUE); if(mode==2){ draw_bow_v3(.2,.2+.6*time_pos); }else if(mode==1){ draw_bow_v2(.2,.2+.6*time_pos); }else{ draw_bow(.2,.2+.6*time_pos); } }else{//shaking hands draw_hand( .3+.1*oscill_force,0,FALSE); if(mode==2){ draw_bow_v3(.2,.2+.1*oscill_force); }else if(mode==1){ draw_bow_v2(.2,.2+.1*oscill_force); }else{ draw_bow(.2,.2+.1*oscill_force); } } #undef TEMP_MACRO // glTranslated( 0, 1, -5+1*oscill_force); // glTranslated(-.3+.1*sin(SDL_GetTicks()*.0017), 0, 0); // draw_arrow(.2); glPopMatrix(); }
void GUITriggeredRerouter::GUITriggeredRerouterEdge::drawGL(const GUIVisualizationSettings& s) const { if (s.scale * s.addExaggeration >= 3) { glPushName(getGlID()); const SUMOReal prob = myParent->getProbability(); if (myAmClosedEdge) { // draw closing symbol onto all lanes if (myParent->hasCurrentReroute(MSNet::getInstance()->getCurrentTimeStep()) && prob > 0) { const RerouteInterval& ri = myParent->getCurrentReroute(MSNet::getInstance()->getCurrentTimeStep()); // draw only if the edge is closed at this time if (std::find(ri.closed.begin(), ri.closed.end(), myEdge) != ri.closed.end()) { const size_t noLanes = myFGPositions.size(); for (size_t j = 0; j < noLanes; ++j) { Position pos = myFGPositions[j]; SUMOReal rot = myFGRotations[j]; glPushMatrix(); glTranslated(pos.x(), pos.y(), 0); glRotated(rot, 0, 0, 1); glTranslated(0, -1.5, 0); int noPoints = 9; if (s.scale > 25) { noPoints = (int)(9.0 + s.scale / 10.0); if (noPoints > 36) { noPoints = 36; } } glTranslated(0, 0, getType()); //glScaled(s.addExaggeration, s.addExaggeration, 1); glColor3d(0.7, 0, 0); GLHelper::drawFilledCircle((SUMOReal) 1.3, noPoints); glTranslated(0, 0, .1); glColor3d(1, 0, 0); GLHelper::drawFilledCircle((SUMOReal) 1.3, noPoints, 0, prob * 360); glTranslated(0, 0, .1); glColor3d(1, 1, 1); glRotated(-90, 0, 0, 1); glBegin(GL_TRIANGLES); glVertex2d(0 - .3, -1.); glVertex2d(0 - .3, 1.); glVertex2d(0 + .3, 1.); glVertex2d(0 + .3, -1.); glVertex2d(0 - .3, -1.); glVertex2d(0 + .3, 1.); glEnd(); glPopMatrix(); } } } } else { // draw rerouter symbol onto all lanes for (size_t i = 0; i < myFGPositions.size(); ++i) { const Position& pos = myFGPositions[i]; SUMOReal rot = myFGRotations[i]; glPushMatrix(); glTranslated(pos.x(), pos.y(), 0); glRotated(rot, 0, 0, 1); glTranslated(0, 0, getType()); glScaled(s.addExaggeration, s.addExaggeration, 1); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glBegin(GL_TRIANGLES); glColor3d(1, .8f, 0); // base glVertex2d(0 - 1.4, 0); glVertex2d(0 - 1.4, 6); glVertex2d(0 + 1.4, 6); glVertex2d(0 + 1.4, 0); glVertex2d(0 - 1.4, 0); glVertex2d(0 + 1.4, 6); glEnd(); glTranslated(0, 0, .1); glColor3d(0, 0, 0); pfSetPosition(0, 0); pfSetScale(3.f); SUMOReal w = pfdkGetStringWidth("U"); glRotated(180, 0, 1, 0); glTranslated(-w / 2., 2, 0); pfDrawString("U"); glTranslated(w / 2., -2, 0); std::string str = toString((int)(prob * 100)) + "%"; pfSetPosition(0, 0); pfSetScale(.7f); w = pfdkGetStringWidth(str.c_str()); glTranslated(-w / 2., 4, 0); pfDrawString(str.c_str()); glPopMatrix(); } } glPopName(); } }
bool GraphicsWindow::ToolbarDrawOrHitTest(int mx, int my, bool paint, int *menuHit) { int i; int x = 17, y = (int)(height - 52); int fudge = 8; int h = 32*16 + 3*16 + fudge; int aleft = 0, aright = 66, atop = y+16+fudge/2, abot = y+16-h; bool withinToolbar = (mx >= aleft && mx <= aright && my <= atop && my >= abot); if(!paint && !withinToolbar) { // This gets called every MouseMove event, so return quickly. return false; } if(paint) { glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glTranslated(-1, -1, 0); glScaled(2.0/width, 2.0/height, 0); glDisable(GL_LIGHTING); double c = 30.0/255; glColor4d(c, c, c, 1.0); ssglAxisAlignedQuad(aleft, aright, atop, abot); } struct { bool show; const char *str; } toolTip = { false, NULL }; bool leftpos = true; for(i = 0; Toolbar[i].image; i++) { if(Toolbar[i].image == SPACER) { if(!leftpos) { leftpos = true; y -= 32; x -= 32; } y -= 16; if(paint) { // Draw a separator bar in a slightly different color. int divw = 30, divh = 2; glColor4d(0.17, 0.17, 0.17, 1); x += 16; y += 24; ssglAxisAlignedQuad(x+divw, x-divw, y+divh, y-divh); x -= 16; y -= 24; } continue; } if(paint) { glRasterPos2i(x - 12, y - 12); glDrawPixels(24, 24, GL_RGB, GL_UNSIGNED_BYTE, Toolbar[i].image); if(toolbarHovered == Toolbar[i].menu || pending.operation == Toolbar[i].menu) { // Highlight the hovered or pending item. glColor4d(1, 1, 0, 0.3); int boxhw = 15; ssglAxisAlignedQuad(x+boxhw, x-boxhw, y+boxhw, y-boxhw); } if(toolbarTooltipped == Toolbar[i].menu) { // Display the tool tip for this item; postpone till later // so that no one draws over us. Don't need position since // that's just wherever the mouse is. toolTip.show = true; toolTip.str = Toolbar[i].tip; } } else { int boxhw = 16; if(mx < (x+boxhw) && mx > (x - boxhw) && my < (y+boxhw) && my > (y - boxhw)) { if(menuHit) *menuHit = Toolbar[i].menu; } } if(leftpos) { x += 32; leftpos = false; } else { x -= 32; y -= 32; leftpos = true; } } if(paint) { // Do this last so that nothing can draw over it. if(toolTip.show) { ssglInitializeBitmapFont(); std::string str = toolTip.str; for(i = 0; SS.GW.menu[i].level >= 0; i++) { if(toolbarTooltipped == SS.GW.menu[i].id) { std::string accel = MakeAcceleratorLabel(SS.GW.menu[i].accel); if(!accel.empty()) { str += ssprintf(" (%s)", accel.c_str()); } break; } } int tw = str.length() * (SS.TW.CHAR_WIDTH - 1) + 10, th = SS.TW.LINE_HEIGHT + 2; double ox = toolbarMouseX + 3, oy = toolbarMouseY + 3; glLineWidth(1); glColor4d(1.0, 1.0, 0.6, 1.0); ssglAxisAlignedQuad(ox, ox+tw, oy, oy+th); glColor4d(0.0, 0.0, 0.0, 1.0); ssglAxisAlignedLineLoop(ox, ox+tw, oy, oy+th); glColor4d(0, 0, 0, 1); glPushMatrix(); glTranslated(ox+5, oy+3, 0); glScaled(1, -1, 1); ssglBitmapText(str, Vector::From(0, 0, 0)); glPopMatrix(); } ssglDepthRangeLockToFront(false); } return withinToolbar; }
void FileSystemActor::onRender(uint flags) { #ifdef TESTING_ALTERNATE_RENDERING if (isActorType(Invisible)) return; // _isAnimatedTexture is always false right now since we don't robustly support animated gifs if (_isAnimatedTexture) { bool successful = true; // if this is an animated texture and we've never loaded the animation // then do so now if (!_animatedTextureSource.load()) _isAnimatedTexture = false; if (_animatedTextureSource.numFrames() <= 1) successful = false; else { AnimatedTextureFrame * frame = _animatedTextureSource.getCurrentTextureFrame(); Vec3 sz = getDims(); glPushAttribToken token(GL_ENABLE_BIT); glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); // Conditionals if (isSelected() || isActorType(Temporary)) glDisable(GL_DEPTH_TEST); if (isActorType(Invisible)) return; //transform our unit cube: glPushMatrix(); ShapeVis::setupGLMatrix(getGlobalPosition(), getGlobalOrientation()); glScaled(sz.x, sz.y, sz.z); // render the current index glBindTexture(GL_TEXTURE_2D, _animatedTextureSource.GLId()); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, frame->width, frame->height, GL_BGRA, GL_UNSIGNED_BYTE, frame->pixelData); // Set the Texture glColor4f(1, 1, 1, getAlpha()); // Scale the image uint squareSize = closestPowerOfTwo(NxMath::max(frame->width, frame->height)); float w = (float) frame->width / squareSize; float h = (float) frame->height / squareSize; h = 1.0f - (h * w); glBegin(GL_QUADS); glNormal3f(0,0,1); glTexCoord2f(w,0); glVertex3f(1,1,1); glTexCoord2f(0,0); glVertex3f(-1,1,1); glTexCoord2f(0,h); glVertex3f(-1,-1,1); glTexCoord2f(w,h); glVertex3f(1,-1,1); glNormal3f(0,0,-1); glTexCoord2f(0,h); glVertex3f(1,-1,-1); glTexCoord2f(w,h); glVertex3f(-1,-1,-1); glTexCoord2f(w,0); glVertex3f(-1,1,-1); glTexCoord2f(0,0); glVertex3f(1,1,-1); glEnd(); glPopMatrix(); } // skip the normal rendering routine if (successful) return; } // Render the previous actor first Actor::onRender(flags); // Render an overlay bool isLinkOverlay = (isFileSystemType(Link) || isFileSystemType(DeadLink)) && GLOBAL(settings).manualArrowOverlay; bool isFileTypeOverlay = !getTextIcon().isEmpty(); if (isLinkOverlay || isFileTypeOverlay) { glPushAttribToken token(GL_ENABLE_BIT); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); // Render the shortcut/file type icon Arrow QString renderTextureId = QT_NT("icon.linkOverlay"); Vec3 renderPos = getGlobalPosition(); Vec3 renderDims = getDims(); bool shouldScaleIcon = false; if (isFileTypeOverlay) { renderTextureId = getTextIcon(); shouldScaleIcon = true; } else if (isLinkOverlay) { // If the creator of the theme has a bad icon link overlay, we need to re-size it so it does not take up the entire actor // A "good" icon link overlay is 256x255; with the actual overlay part taking up 77x75 in the bottom-left corner Vec3 dimensions = texMgr->getTextureDims(renderTextureId); if (dimensions.x > 0 && dimensions.y > 0) { if ((closestPowerOfTwo(dimensions.x) != 256) || (closestPowerOfTwo(dimensions.y) != 256)) { shouldScaleIcon = true; // position the link icon to the corner of the actual actor (instead of scaling/stretching it) float maxSide = max(dimensions.x, dimensions.y); renderDims.x = renderDims.y = maxSide; } } } if (shouldScaleIcon) { Vec3 offset(getDims().x, -getDims().y, 0); // Scale the actor to proper size (256/77 =~ 3.4; 255/75 = 3.4) renderDims.x /= 3.4f; renderDims.y /= 3.4f; offset += Vec3(-renderDims.x - 0.25f, renderDims.y + 0.25f, 0); offset = getGlobalOrientation() * offset; renderPos += offset; } glBindTexture(GL_TEXTURE_2D, texMgr->getGLTextureId(renderTextureId)); glColor4f(1, 1, 1, getAlpha()); ShapeVis::renderSideLessBox(renderPos, getGlobalOrientation(), renderDims); } #elif !defined DXRENDER // _isAnimatedTexture is always false right now since we don't robustly support animated gifs if (_isAnimatedTexture) { bool successful = true; // if this is an animated texture and we've never loaded the animation // then do so now if (!_animatedTextureSource.load()) _isAnimatedTexture = false; if (_animatedTextureSource.numFrames() <= 1) successful = false; else { AnimatedTextureFrame * frame = _animatedTextureSource.getCurrentTextureFrame(); Vec3 sz = getDims(); glPushAttribToken token(GL_ENABLE_BIT); glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); // Conditionals if (isSelected() || isActorType(Temporary)) glDisable(GL_DEPTH_TEST); if (isActorType(Invisible)) return; //transform our unit cube: glPushMatrix(); ShapeVis::setupGLMatrix(getGlobalPosition(), getGlobalOrientation()); glScaled(sz.x, sz.y, sz.z); // render the current index glBindTexture(GL_TEXTURE_2D, _animatedTextureSource.GLId()); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, frame->width, frame->height, GL_BGRA, GL_UNSIGNED_BYTE, frame->pixelData); // Set the Texture glColor4f(1, 1, 1, getAlpha()); // Scale the image uint squareSize = closestPowerOfTwo(NxMath::max(frame->width, frame->height)); float w = (float) frame->width / squareSize; float h = (float) frame->height / squareSize; h = 1.0f - (h * w); glBegin(GL_QUADS); glNormal3f(0,0,1); glTexCoord2f(w,0); glVertex3f(1,1,1); glTexCoord2f(0,0); glVertex3f(-1,1,1); glTexCoord2f(0,h); glVertex3f(-1,-1,1); glTexCoord2f(w,h); glVertex3f(1,-1,1); glNormal3f(0,0,-1); glTexCoord2f(0,h); glVertex3f(1,-1,-1); glTexCoord2f(w,h); glVertex3f(-1,-1,-1); glTexCoord2f(w,0); glVertex3f(-1,1,-1); glTexCoord2f(0,0); glVertex3f(1,1,-1); glEnd(); glPopMatrix(); } // skip the normal rendering routine if (successful) return; } // Render the previous actor first Actor::onRender(flags); // Render a link overlay arrow if ((isFileSystemType(Link) || isFileSystemType(DeadLink)) && !isActorType(Invisible)) { glPushAttribToken token(GL_ENABLE_BIT); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); // Render the shortcut Arrow if (GLOBAL(settings).manualArrowOverlay) { glBindTexture(GL_TEXTURE_2D, texMgr->getGLTextureId("icon.linkOverlay")); bool scaleOverlayActor = false; //If the creator of the theme has a bad icon link overlay, we need to re-size it so it does not take up the entire actor Vec3 dimensions = texMgr->getTextureDims("icon.linkOverlay"); //A "good" icon link overlay is 256x255; with the actual overlay part taking up 77x75 in the bottom-left corner if(dimensions.x > 0 && dimensions.y > 0) { if((closestPowerOfTwo(dimensions.x) != 256)||(closestPowerOfTwo(dimensions.y) != 256)) scaleOverlayActor = true; } glColor4f(1, 1, 1, getAlpha()); // Render Shape Vec3 pos = getGlobalPosition(); Vec3 dims = getDims(); Vec3 normalizedDims = dims; // position the link icon to the corner of the actual actor (instead of scaling/stretching it) float maxSide = max(dims.x, dims.y); normalizedDims.x = normalizedDims.y = maxSide; // Scale the actor to proper size (256/77 =~ 3.4; 255/75 = 3.4) if(scaleOverlayActor){ normalizedDims.x /= 3.4f; normalizedDims.y /= 3.4f; } if(scaleOverlayActor) { Vec3 offset(dims.x, -dims.y, 0); offset = getGlobalOrientation() * offset; pos += offset; } else { pos.x -= normalizedDims.x - dims.x; pos.z += normalizedDims.y - dims.y; } ShapeVis::renderSideLessBox(pos, getGlobalOrientation(), normalizedDims); } } #elif defined DXRENDER // Render the previous actor first Actor::onRender(flags); // Render a link overlay arrow if ((isFileSystemType(Link) || isFileSystemType(DeadLink)) && !isActorType(Invisible)) { // Render the shortcut Arrow if (GLOBAL(settings).manualArrowOverlay) { bool scaleOverlayActor = false; //If the creator of the theme has a bad icon link overlay, we need to re-size it so it does not take up the entire actor Vec3 dimensions = texMgr->getTextureDims("icon.linkOverlay"); //A "good" icon link overlay is 256x255; with the actual overlay part taking up 77x75 in the bottom-left corner if(dimensions.x > 0 && dimensions.y > 0) { if((closestPowerOfTwo(dimensions.x) != 256)||(closestPowerOfTwo(dimensions.y) != 256)) scaleOverlayActor = true; } // Render Shape Vec3 pos = getGlobalPosition(); Vec3 dims = getDims(); Vec3 normalizedDims = dims; // position the link icon to the corner of the actual actor (instead of scaling/stretching it) float maxSide = max(dims.x, dims.y); normalizedDims.x = normalizedDims.y = maxSide; // Scale the actor to proper size (256/77 =~ 3.4; 255/75 = 3.4) if(scaleOverlayActor){ normalizedDims.x /= 3.4f; normalizedDims.y /= 3.4f; } if(scaleOverlayActor) { Vec3 offset(dims.x, -dims.y, 0); offset = getGlobalOrientation() * offset; pos += offset; } else { pos.x -= normalizedDims.x - dims.x; pos.z += normalizedDims.y - dims.y; } dxr->device->SetRenderState(D3DRS_ZENABLE, false); dxr->renderSideLessBox(pos, getGlobalOrientation(), normalizedDims, texMgr->getGLTextureId("icon.linkOverlay")); dxr->device->SetRenderState(D3DRS_ZENABLE, true); } } #endif }
void draw_cube(double radius) { GLfloat matspec[4] = { 0.5, 0.5, 0.5, 0.0 }; glPushMatrix(); glScaled(radius, radius, radius); glMaterialfv(GL_FRONT, GL_SPECULAR, matspec); glMaterialf(GL_FRONT, GL_SHININESS, 64.0); glBegin(GL_POLYGON); glColor3fv(lightblu_col); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, lightblu_col); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, lightblu_col); glNormal3f(0.0, 0.0, -1.0); glVertex3f(1.0, 1.0, -1.0); glVertex3f(1.0, -1.0, -1.0); glVertex3f(-1.0, -1.0, -1.0); glVertex3f(-1.0, 1.0, -1.0); glEnd(); glBegin(GL_POLYGON); glColor3fv(blu_col); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, blu_col); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, blu_col); glNormal3f(0.0, 0.0, 1.0); glVertex3f(-1.0, 1.0, 1.0); glVertex3f(-1.0, -1.0, 1.0); glVertex3f(1.0, -1.0, 1.0); glVertex3f(1.0, 1.0, 1.0); glEnd(); glBegin(GL_POLYGON); glColor3fv(yel_col); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, yel_col); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, yel_col); glNormal3f(0.0, -1.0, 0.0); glVertex3f(1.0, -1.0, 1.0); glVertex3f(-1.0, -1.0, 1.0); glVertex3f(-1.0, -1.0, -1.0); glVertex3f(1.0, -1.0, -1.0); glEnd(); glBegin(GL_POLYGON); glColor3fv(grn_col); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, grn_col); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, grn_col); glNormal3f(0.0, 1.0, 0.0); glVertex3f(1.0, 1.0, 1.0); glVertex3f(1.0, 1.0, -1.0); glVertex3f(-1.0, 1.0, -1.0); glVertex3f(-1.0, 1.0, 1.0); glEnd(); glBegin(GL_POLYGON); glColor3fv(pur_col); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, pur_col); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, pur_col); glNormal3f(-1.0, 0.0, 0.0); glVertex3f(-1.0, 1.0, 1.0); glVertex3f(-1.0, 1.0, -1.0); glVertex3f(-1.0, -1.0, -1.0); glVertex3f(-1.0, -1.0, 1.0); glEnd(); glBegin(GL_POLYGON); glColor3fv(red_col); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, red_col); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, red_col); glNormal3f(1.0, 0.0, 0.0); glVertex3f(1.0, -1.0, 1.0); glVertex3f(1.0, -1.0, -1.0); glVertex3f(1.0, 1.0, -1.0); glVertex3f(1.0, 1.0, 1.0); glEnd(); glPopMatrix(); }
void GlslApplication::render_scene() const { // backup state so it doesn't mess up students stuff glPushAttrib( GL_ALL_ATTRIB_BITS ); glPushClientAttrib( GL_CLIENT_ALL_ATTRIB_BITS ); // we set most gl state each time since it all gets popped each frame glClearColor( scene.background_color.r, scene.background_color.g, scene.background_color.b, 1.0f ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glEnable( GL_NORMALIZE ); glEnable( GL_DEPTH_TEST ); glEnable( GL_LIGHTING ); glEnable( GL_TEXTURE_2D ); // set camera transform const Camera& camera = camera_control.camera; glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective( camera.get_fov_degrees(), camera.get_aspect_ratio(), camera.get_near_clip(), camera.get_far_clip() ); const Vector3& campos = camera.get_position(); const Vector3 camref = camera.get_direction() + campos; const Vector3& camup = camera.get_up(); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); gluLookAt( campos.x, campos.y, campos.z, camref.x, camref.y, camref.z, camup.x, camup.y, camup.z ); // set light data float arr[4]; arr[3] = 1.0; // w is always 1 scene.ambient_light.to_array( arr ); glLightModelfv( GL_LIGHT_MODEL_AMBIENT, arr ); glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE ); const Scene::PointLightList& lights = scene.get_lights(); for ( size_t i = 0; i < NUM_GL_LIGHTS && i < lights.size(); i++ ) { const PointLight& light = lights[i]; glEnable( LightConstants[i] ); light.color.to_array( arr ); glLightfv( LightConstants[i], GL_DIFFUSE, arr ); glLightfv( LightConstants[i], GL_SPECULAR, arr ); glLightf( LightConstants[i], GL_CONSTANT_ATTENUATION, light.attenuation.constant ); glLightf( LightConstants[i], GL_LINEAR_ATTENUATION, light.attenuation.linear ); glLightf( LightConstants[i], GL_QUADRATIC_ATTENUATION, light.attenuation.quadratic ); light.position.to_array( arr ); glLightfv( LightConstants[i], GL_POSITION, arr ); } // render each object const Scene::GeometryList& geometries = scene.get_geometries(); for ( size_t i = 0; i < geometries.size(); ++i ) { const Geometry& geom = *geometries[i]; Vector3 axis; real_t angle; glPushMatrix(); glTranslated( geom.position.x, geom.position.y, geom.position.z ); geom.orientation.to_axis_angle( &axis, &angle ); glRotated( angle * ( 180.0 / PI ), axis.x, axis.y, axis.z ); glScaled( geom.scale.x, geom.scale.y, geom.scale.z ); geom.render(); glPopMatrix(); } glPopClientAttrib(); glPopAttrib(); }
void BillboardCaption3DScene::drawMyself(CloudViewDialog *dialog) { /*Caption drawing*/ OpenGLTools::GLWrapper wrapper; GLPainter painter(&wrapper); Matrix44 modelview = OpenGLTools::glGetModelViewMatrix(); Matrix44 projection = OpenGLTools::glGetProjectionMatrix(); Matrix44 glMatrix = projection * modelview; /* Setting new matrices */ int width = dialog->mUi.widget->width(); int height = dialog->mUi.widget->height(); /* SetMatrices to draw on 2D canvas */ glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(- width / 2.0 , width / 2.0, -height / 2.0, height / 2.0, 10, -10); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); double size = mParameters.fontSize() / 25.0; for (auto caption: mLabels) { /* QString text = QString("[%1, %2, %3]") .arg(centralPoint.x(), 0, 'f', 2).arg(centralPoint.y(), 0, 'f', 2).arg(centralPoint.z(), 0, 'f', 2); */ QString text = QString::fromStdString(caption.second); Vector3dd labelPos = glMatrix * caption.first; if ((!dialog->isOrtho((CloudViewDialog::CameraType)dialog->mUi.cameraTypeBox->currentIndex())) && (labelPos.z() < 0)) { continue; } glPushMatrix(); glTranslated(labelPos[0] * width / 2.0, labelPos[1] * height / 2.0, 0.0); glScaled(size, -size, size); bool depthTest = glIsEnabled(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST); GLint lineWidth; glGetIntegerv(GL_LINE_WIDTH, &lineWidth); glLineWidth(mParameters.fontWidth()); //glColor3ub(mParameters.fontColor().r(), mParameters.fontColor().g(), mParameters.fontColor().b()); painter.drawFormatVector(0, 0, mParameters.fontColor(), 1, text.toLatin1().constData()); if (depthTest) { glEnable(GL_DEPTH_TEST); } glLineWidth(lineWidth); glPopMatrix(); } /*Restore old matrices */ glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); }
inline void glScale( const GLdouble & s ) { glScaled( s, s, s ); }
/*!***************************************************************************** ******************************************************************************* \note osc_display \date Aug 2010 display function for oscilloscope ******************************************************************************* Function Parameters: [in]=input,[out]=output ******************************************************************************/ static void osc_display(void) { int i,j,c,r; static int firsttime = TRUE; static int listID = 999; static double freq_AD = 0; static double start_time_AD = 0; double offx_left = 0.2; double offx_right = 0.1; double offy = 0.05; double offy_extra = 0.1; double tick_length = 0.1; int its=0; int ivs=0; double tstart=0,tend=1; double tend_ivs=0; int count = 0; double last_ts = 0; int last_c = 0; char string[40]; double aux; double dist = 1.e10; double last_dist = 1.e10; GLfloat colors[][4]={ {(float)0.0,(float)1.0,(float)1.0,(float)1.0}, // cyan {(float)0.5,(float)0.5,(float)1.0,(float)1.0}, // blue {(float)1.0,(float)0.25,(float)0.25,(float)1.0}, // red {(float)0.1,(float)0.5,(float)0.5,(float)1.0}, // green {(float)0.8,(float)0.8,(float)0.8,(float)1.0}, // gray {(float)0.7,(float)1.0,(float)0.7,(float)1.0}, // light green {(float)1.,(float)1.,(float)1.0,(float)1.0}, // white {(float)1.0,(float)1.0,(float)0.0,(float)1.0}, // yellow {(float)1.0,(float)0.7,(float)0.7,(float)1.0}, // pink {(float)1.0,(float)0.0,(float)1.0,(float)1.0}, // magenta }; if (firsttime) { firsttime = FALSE; // cache all possible information in a display list glNewList((GLuint)((unsigned long) listID), GL_COMPILE); glBegin(GL_LINE_STRIP); glVertex2d(0.0,0.0); glVertex2d(0.0,1.0); glVertex2d(1.0,1.0); glVertex2d(1.0,0.0); glVertex2d(0.0,0.0); glEnd(); glBegin(GL_LINES); for (i=1; i<=9; ++i) { glVertex2d(0.1*i,0.0); glVertex2d(0.1*i,tick_length); } glEnd(); glEndList(); } glClear(GL_COLOR_BUFFER_BIT); glDisable(GL_LIGHTING); glLoadIdentity(); glPushMatrix(); // draw the coordinate axes glColor4f (1.0,1.0,1.0,1.0); for (i=0; i<=n_oscilloscope_plots; ++i) { glPushMatrix(); if (i==0) glTranslated(offx_left,(n_oscilloscope_plots-i)+offy,0.0); else glTranslated(offx_left,(n_oscilloscope_plots-i)+offy-offy_extra,0.0); glScaled(1.-offx_left-offx_right,1-2*offy,1.0); glCallList((GLuint)((unsigned long)listID)); glPopMatrix(); } // draw data traces =========================================================== // the 0-th plot is special for the A/D signals ------------------------------- // find "D2A_task" for trigger for (i=1; i<=osc_data[0].n_active; ++i) { if (strcmp("D2A_task [%]",osc_data[0].names[i])==0) break; } if ( i > osc_data[0].n_active ) { if (osc_data[0].n_active > 1000) printf("Could not find D2A_task in oscilloscope data\n"); glutSwapBuffers(); return; } else { its = i; // store this index } // find "D2A_vision" to try to sync the vision servo in trigger for (i=1; i<=osc_data[0].n_active; ++i) { if (strcmp("D2A_vision",osc_data[0].names[i])==0) { ivs = i; break; } } // search for "periods_window_AD" number of complete periods backwards, and // if vision servo exists, try to find a trigger point the closest to the vision // servo such that the trigger image is more coherent // first find last vision_servo minimum if (ivs) { tend_ivs = 0; for (i=0; i < osc_data[0].n_data[ivs]; ++i) { c = osc_data[0].current_index[ivs]-i; if (c < 1) c += MAX_OSC_DATA; if (osc_data[0].data[ivs][c][2] == 0.0) { tend_ivs = osc_data[0].data[ivs][c][1]; break; } } if (tend_ivs == 0) // nothing found ivs = FALSE; } count = 0; for (i=0; i < osc_data[0].n_data[its]; ++i) { c = osc_data[0].current_index[its]-i; if (c < 1) c += MAX_OSC_DATA; if (osc_data[0].data[its][c][2] == 0.0 && count == 0) { tend = osc_data[0].data[its][c][1]; count = 1; if (ivs) last_dist = fabs(tend_ivs - tend); } else if (osc_data[0].data[its][c][2] == 0.0 && count == periods_window_AD) { if (ivs) { dist = fabs(tend_ivs - osc_data[0].data[its][c][1]); if (dist < last_dist) { // change tend and count tend = osc_data[0].data[its][c][1]; last_dist = dist; count = 1; continue; } } tstart = osc_data[0].data[its][c][1]; ++count; break; } else if (osc_data[0].data[its][c][2] == 0.0) { ++count; if (ivs) { dist = fabs(tend_ivs - osc_data[0].data[its][c][1]); if (dist < last_dist) { // change tend and count tend = osc_data[0].data[its][c][1]; last_dist = dist; count = 1; } } } } if (count != periods_window_AD+1) { // not enough periods yet glutSwapBuffers(); return; } // plot all data within the tstart->tend time window glPushMatrix(); glTranslated(offx_left,n_oscilloscope_plots+offy,0.0); glScaled(1.-offx_left-offx_right,1-2*offy,1.0); aux = (-offx_left*0.95)/(1.-offx_left-offx_right); for (j=1; j<=osc_data[0].n_active; ++j) { glColor4fv(colors[j%10]); glRasterPos2d(aux,(j-1)*0.1); glutBitmapString(GLUT_BITMAP_HELVETICA_10,(const unsigned char *)osc_data[0].names[j]); } glColor4f (1.0,1.0,1.0,1.0); start_time_AD = -(tend-tstart) * 0.01 + 0.99*start_time_AD; sprintf(string,"%3.1e",start_time_AD); glRasterPos2d(-0.0,-2*offy); glutBitmapString(GLUT_BITMAP_HELVETICA_10,(const unsigned char *)string); freq_AD = ((double)periods_window_AD)/(tend-tstart)*0.01 + 0.99*freq_AD; sprintf(string,"%5.1f Hz",freq_AD); glRasterPos2d(0.5,-2*offy); glutBitmapString(GLUT_BITMAP_HELVETICA_10,(const unsigned char *)string); sprintf(string,"0.0"); glRasterPos2d(1.0,-2*offy); glutBitmapString(GLUT_BITMAP_HELVETICA_10,(const unsigned char *)string); sprintf(string,"% .2f",osc_data[0].min); glRasterPos2d(1.0,0.0); glutBitmapString(GLUT_BITMAP_HELVETICA_10,(const unsigned char *)string); sprintf(string,"% .2f",osc_data[0].max); glRasterPos2d(1.0,1.0-2*offy); glutBitmapString(GLUT_BITMAP_HELVETICA_10,(const unsigned char *)string); for (j=1; j<=osc_data[0].n_active; ++j) { glColor4fv(colors[j%10]); last_ts = 0.0; last_c = 0; glBegin(GL_LINE_STRIP); for (i=0; i < osc_data[0].n_data[j]; ++i) { c = osc_data[0].current_index[j]-i; if (c < 1) c += MAX_OSC_DATA; if (osc_data[0].data[j][c][1] > tend) continue; if (osc_data[0].data[j][c][1] < tstart) { glVertex2d(0.0,osc_data[0].data[j][last_c][2]/100.); break; } // A/D data is unequally sampled and needs thus to be drawn as steps if (last_ts != 0) glVertex2d((last_ts-tstart)/(tend-tstart),osc_data[0].data[j][c][2]/100.); else glVertex2d(1.0,osc_data[0].data[j][c][2]/100.); glVertex2d((osc_data[0].data[j][c][1]-tstart)/(tend-tstart),osc_data[0].data[j][c][2]/100.); last_ts = osc_data[0].data[j][c][1]; last_c = c; } glEnd(); } glPopMatrix(); // the variable plots --------------------------------------------------------- for (r=1; r<=n_oscilloscope_plots; ++r) { // determine start and end time from all the trajectories tend = -1.e10; for (j=1; j<=osc_data[r].n_active; ++j) { if (osc_data[r].data[j][osc_data[r].current_index[j]][1] > tend) tend = osc_data[r].data[j][osc_data[r].current_index[j]][1]; } tstart = tend - time_window_vars; for (j=1; j<=osc_data[r].n_active; ++j) { glPushMatrix(); glTranslated(offx_left,(n_oscilloscope_plots-r)+offy-offy_extra,0.0); glScaled(1.-offx_left-offx_right,1-2*offy,1.0); aux = (-offx_left*0.95)/(1.-offx_left-offx_right); glColor4fv(colors[j%10]); glRasterPos2d(aux,(j-1)*0.1); glutBitmapString(GLUT_BITMAP_HELVETICA_10,(const unsigned char *)osc_data[r].names[j]); glColor4f (1.0,1.0,1.0,1.0); sprintf(string,"% .2f",osc_data[r].min); glRasterPos2d(1.0,0.0); glutBitmapString(GLUT_BITMAP_HELVETICA_10,(const unsigned char *)string); sprintf(string,"% .2f",osc_data[r].max); glRasterPos2d(1.0,1.0-2*offy); glutBitmapString(GLUT_BITMAP_HELVETICA_10,(const unsigned char *)string); glColor4fv(colors[j%10]); glBegin(GL_LINE_STRIP); for (i=0; i < osc_data[r].n_data[j]; ++i) { c = osc_data[r].current_index[j]-i; if (c < 1) c += MAX_OSC_DATA; if (osc_data[r].data[j][c][1] > tend) continue; if (osc_data[r].data[j][c][1] < tstart) break; // just make the data a vertex glVertex2d((osc_data[r].data[j][c][1]-tstart)/(tend-tstart), (osc_data[r].data[j][c][2]-osc_data[r].min)/(osc_data[r].max-osc_data[r].min)); } glEnd(); glPopMatrix(); } } glPushMatrix(); glTranslated(offx_left,offy-offy_extra,0.0); glScaled(1.-offx_left-offx_right,1-2*offy,1.0); glColor4f (1.0,1.0,1.0,1.0); sprintf(string,"%6.3f",-(tend-tstart)); glRasterPos2d(-0.0,-2*offy); glutBitmapString(GLUT_BITMAP_HELVETICA_10,(const unsigned char *)string); sprintf(string,"0.0"); glRasterPos2d(1.0,-2*offy); glutBitmapString(GLUT_BITMAP_HELVETICA_10,(const unsigned char *)string); glPopMatrix(); glutSwapBuffers(); }
M(void, glScaled, jdouble x, jdouble y, jdouble z) { glScaled(x, y, z); }