void RenderScene() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer glLoadIdentity(); // Reset The matrix // Position View Up Vector gluLookAt(0, 0, 6, 0, 0, 0, 0, 1, 0); // This determines where the camera's position and view is /////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// * glColor3f(0, 1, 0); // Make the next text green // Here we draw our text at (0, 25). This text will be green. glDrawText(0, 25, "Brought to you by www.GameTutorials.com..."); glColor3f(1, 1, 0); // Make the next text yellow // Now we want to move the next text down, so we use (25 + FONT_HEIGHT * n) for the Y glDrawText(0, 25 + FONT_HEIGHT * 2, "abcdefghijklmnopqrstuvwxyz"); glDrawText(0, 25 + FONT_HEIGHT * 3, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); // You will notice in this one, that I added some arguments that take integers. // You can see how you can treat this function like printf()/sprintf() glDrawText(0, 25 + FONT_HEIGHT * 4, "%d%d!@#$%^&*(){}[]..,/?><", 12345, 67890); glColor3f(1, 0, 1); // Make the next text purple glDrawText(0, 25 + FONT_HEIGHT * 6, "AREN'T FONTS EASY?!"); // They sure are! /////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// * SwapBuffers(g_hDC); // Swap the backbuffers to the foreground }
/* print a floating number on the screen */ void print_number(double x, double y, real v, color_t color) { char string[20]; glColorc(color); snprintf(string, 20, "%.4f", v); glDrawText(x, y, 1.0, string); }
void write_status(const wchar_t *text) { MGLrect dims; mglGetDimensions(NULL, &dims); glSetColour(0x336699); dims.left = SCN_WID * 48; glFillRect(dims.left, dims.top, dims.right, dims.bottom); RectInflate(&dims, -48, -48); glSetColour(0x000000); glDrawText(&dims, text, -1); }
static void DrawGraph(const GraphData * gd) { unsigned int i; float lastx = 0; glPushMatrix(); glTranslatef(NUM_WIDTH + RES_WIDTH * (float) gd->numGames + TOTAL_GAP + COL_WIDTH + (INTER_GAP + MID_GAP) / 2.0f, NUM_HEIGHT / 2, 0.f); glColor3f(1.f, 1.f, 1.f); glLineWidth(.5f); glScalef(NUM_WIDTH * 10, NUM_HEIGHT * 10, 1.f); glDrawText(totalText); glPopMatrix(); DrawLeftAxis(gd); for (i = 0; i < gd->numGames; i++) { float x = NUM_WIDTH + RES_WIDTH * (float) i + COL_WIDTH + (INTER_GAP + MID_GAP) / 2.0f; DrawBars(i, gd->data[i], 0); if (x > lastx + NUM_WIDTH) { PrintBottomNumber(i + 1, NUM_WIDTH * 10, NUM_HEIGHT * 10, x, NUM_HEIGHT / 2.0f); lastx = x; } } /* Total bars */ DrawBars(i, gd->data[i], 1); /* Axis */ glColor3f(1.f, 1.f, 1.f); glBegin(GL_LINES); glVertex2f(NUM_WIDTH, NUM_HEIGHT); glVertex2f(modelWidth - 1, NUM_HEIGHT); glVertex2f(NUM_WIDTH, NUM_HEIGHT); glVertex2f(NUM_WIDTH, modelHeight * .95f); glEnd(); glBegin(GL_POINTS); glVertex2f(NUM_WIDTH, NUM_HEIGHT); glEnd(); }
void glDrawShape(ors::Shape *s) { //set name (for OpenGL selection) glPushName((s->index <<2) | 1); glColor(s->color[0], s->color[1], s->color[2], orsDrawAlpha); double scale=.33*(s->size[0]+s->size[1]+s->size[2] + 2.*s->size[3]); //some scale if(!scale) scale=1.; scale*=.3; double GLmatrix[16]; s->X.getAffineMatrixGL(GLmatrix); glLoadMatrixd(GLmatrix); if(!orsDrawShapes) { glDrawAxes(scale); glColor(0, 0, .5); glDrawSphere(.1*scale); } if(orsDrawShapes) { switch(s->type) { case ors::noneST: break; case ors::boxST: if(orsDrawMeshes && s->mesh.V.N) s->mesh.glDraw(); else glDrawBox(s->size[0], s->size[1], s->size[2]); break; case ors::sphereST: if(orsDrawMeshes && s->mesh.V.N) s->mesh.glDraw(); else glDrawSphere(s->size[3]); break; case ors::cylinderST: if(orsDrawMeshes && s->mesh.V.N) s->mesh.glDraw(); else glDrawCylinder(s->size[3], s->size[2]); break; case ors::cappedCylinderST: if(orsDrawMeshes && s->mesh.V.N) s->mesh.glDraw(); else glDrawCappedCylinder(s->size[3], s->size[2]); break; case ors::markerST: if(orsDrawMarkers){ glDrawDiamond(s->size[0]/5., s->size[0]/5., s->size[0]/5.); glDrawAxes(s->size[0]); } break; case ors::meshST: CHECK(s->mesh.V.N, "mesh needs to be loaded to draw mesh object"); s->mesh.glDraw(); break; case ors::pointCloudST: CHECK(s->mesh.V.N, "mesh needs to be loaded to draw point cloud object"); glDrawPointCloud(s->mesh.V, NoArr); break; default: HALT("can't draw that geom yet"); } } if(orsDrawZlines) { glColor(0, .7, 0); glBegin(GL_LINES); glVertex3d(0., 0., 0.); glVertex3d(0., 0., -s->X.pos.z); glEnd(); } glColor(1,1,1); if(orsDrawBodyNames && s->body) glDrawText(s->body->name, 0, 0, 0); glPopName(); }