void hand::draw_axes( float r, float g, float b) { const double len=1; // Length of axes // Draw axes - no lighting from here on glColor3f(r,g,b); if (axes) { glDisable(GL_LIGHTING); glBegin(GL_LINES); glVertex3f(0.0,0.0,0.0); glVertex3f(len,0.0,0.0); glVertex3f(0.0,0.0,0.0); glVertex3f(0.0,len,0.0); glVertex3f(0.0,0.0,0.0); glVertex3f(0.0,0.0,len); glEnd(); // Label axes glColor3f(1,1,1); glRasterPos3d(len,0.0,0.0); Print("X"); glRasterPos3d(0.0,len,0.0); Print("Y"); glRasterPos3d(0.0,0.0,len); Print("Z"); } glEnable(GL_LIGHTING); }
/* * drawAxes() * ------ * Draw the axes */ void drawAxes(void) { if (toggleAxes) { /* Length of axes */ double len = 2.0; glDisable(GL_LIGHTING); glColor3fv(white); glBegin(GL_LINES); glVertex3d(0,0,0); glVertex3d(len,0,0); glVertex3d(0,0,0); glVertex3d(0,len,0); glVertex3d(0,0,0); glVertex3d(0,0,len); glEnd(); /* Label axes */ glRasterPos3d(len,0,0); print("X"); glRasterPos3d(0,len,0); print("Y"); glRasterPos3d(0,0,len); print("Z"); if (toggleLight) glEnable(GL_LIGHTING); } }
/* draw_axes */ void draw_axes() { if(Glo_Show_Axis) { float scaler = Glo_Scale/1.5; // Draw axes in white glColor3f(1, 1, 1); glBegin(GL_LINES); glVertex3d(0, 0, 0); glVertex3d(scaler, 0, 0); glVertex3d(0, 0, 0); glVertex3d(0, scaler, 0); glVertex3d(0, 0, 0); glVertex3d(0, 0, scaler); glEnd(); // Label Axes glRasterPos3d(scaler, 0, 0); Print("X"); glRasterPos3d(0, scaler, 0); Print("Y"); glRasterPos3d(0, 0, scaler); Print("Z"); } }
//--------------------------------------------------------------------------- void CFabAtHomeView::DrawMainAxes(double size) //--------------------------------------------------------------------------- { // Draw axes of main coord system glLineWidth(2.0); glBegin(GL_LINES); glColor3d(size,0,0); glVertex3d(0,0,0); glVertex3d(size,0,0); glVertex3d(0,0,0); glVertex3d(0,size,0); glVertex3d(0,0,0); glVertex3d(0,0,size); glEnd(); glListBase(1000); glColor3d(0,1,1); glRasterPos3d(size,0,size/10.0); glCallLists(1, GL_UNSIGNED_BYTE, "x"); glRasterPos3d(0,size,size/10.0); glCallLists(1, GL_UNSIGNED_BYTE, "y"); glRasterPos3d(0,0,size); glCallLists(1, GL_UNSIGNED_BYTE, "z"); glColor3d(1,0,0); CVec o(0,0,0); o.DrawMarker(); }
//--------------------------------------------------------------------------- void CCoordSys::Draw(CVec color) //--------------------------------------------------------------------------- { //draw coordinate system axes glBegin(GL_LINES); glColor3d(color.x,color.y,color.z); glVertex3d(m_vecOrg); glVertex3d(m_vecOrg+m_vecDirX); glVertex3d(m_vecOrg); glVertex3d(m_vecOrg+m_vecDirY); glVertex3d(m_vecOrg); glVertex3d(m_vecOrg+m_vecDirZ); glEnd(); glListBase(1000); glColor3d(0,1,1); glRasterPos3d(m_vecOrg+m_vecDirX); glCallLists(1, GL_UNSIGNED_BYTE, "x"); glRasterPos3d(m_vecOrg+m_vecDirY); glCallLists(1, GL_UNSIGNED_BYTE, "y"); glRasterPos3d(m_vecOrg+m_vecDirZ); glCallLists(1, GL_UNSIGNED_BYTE, "z"); m_vecOrg.DrawMarker(); }
void display (void) { const double len=2.5; // Length of axes glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); // Enable Z-buffering in OpenGL glEnable(GL_DEPTH_TEST); // glEnable(GL_CULL_FACE); // Undo previous transformations glLoadIdentity(); // Perspective - set eye position glLoadIdentity(); camera(); if (axes) { glBegin(GL_LINES); glVertex3d(0.0,0.0,0.0); glVertex3d(len,0.0,0.0); glVertex3d(0.0,0.0,0.0); glVertex3d(0.0,len,0.0); glVertex3d(0.0,0.0,0.0); glVertex3d(0.0,0.0,len); glEnd(); // Label axes glRasterPos3d(len,0.0,0.0); Print("X"); glRasterPos3d(0.0,len,0.0); Print("Y"); glRasterPos3d(0.0,0.0,len); Print("Z"); } glutSwapBuffers(); //swap the buffers angle++; //increase the angle }
void drawAllAlxes(void) { const double len=5.0; if (axes) { glDisable(GL_LIGHTING); glColor3fv(white); glBegin(GL_LINES); glVertex3d(0.0,0.0,0.0); glVertex3d(len,0.0,0.0); glVertex3d(0.0,0.0,0.0); glVertex3d(0.0,len,0.0); glVertex3d(0.0,0.0,0.0); glVertex3d(0.0,0.0,len); glEnd(); glRasterPos3d(len,0.0,0.0); print("X"); glRasterPos3d(0.0,len,0.0); print("Y"); glRasterPos3d(0.0,0.0,len); print("Z"); glEnable(GL_LIGHTING); } }
/* * Display the scene */ void display() { // Clear the image glClear(GL_COLOR_BUFFER_BIT); // Reset previous transforms glLoadIdentity(); // Set view angle glRotated(ph,1,0,0); glRotated(th,0,1,0); // Draw 1 pixel points - Randomly generated colors glColor3ub( rand()%255, rand()%255, rand()%255 ); glPointSize(1); glBegin(GL_LINE_STRIP); int i; /* Coordinates */ double x = 1; double y = 1; double z = 1; /* Time step */ double dt = 0.001; for (i=0;i<50000;i++) { double dx = s*(y-x); double dy = x*(r-z)-y; double dz = x*y - b*z; x += dt*dx; y += dt*dy; z += dt*dz; glVertex4f(x*0.03,y*0.03,z*0.03,w); } glEnd(); // Draw axes in white glColor3f(1,1,1); glBegin(GL_LINES); glVertex3d(0,0,0); glVertex3d(1,0,0); glVertex3d(0,0,0); glVertex3d(0,1,0); glVertex3d(0,0,0); glVertex3d(0,0,1); glEnd(); // Label axes glRasterPos3d(1,0,0); Print("X"); glRasterPos3d(0,1,0); Print("Y"); glRasterPos3d(0,0,1); Print("Z"); // Display parameters glWindowPos2i(5,5); Print("View Angle=%d,%d; s = %f; b = %f; r = %f",th,ph,s,b,r); // Sanity check ErrCheck("display"); // Flush and swap glFlush(); glutSwapBuffers(); }
void displayScoreboard(){ char sc[100]; sprintf(sc,"Score:%d Lives:%d Level:%d",score,lives,level); glRasterPos3d(100,810 ,0.0); glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_24,(unsigned char*)sc ); sprintf(sc,"HighScore:%d (%s)",hs,playerHigh); glRasterPos3d(100,770 ,0.0); glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_24,(unsigned char*)sc ); }
/* * Render data of simulation. */ int RenderText(D_PARAM *disp, MODEL *model){ char string[64]; sprintf(string, "Step : %5d", disp->curstep/10); glRasterPos3d(0.05, 0.75, 0.0); glprint("bitmap", string); sprintf(string, "Particle : %5d", disp->curstep); glRasterPos3d(0.05, 0.50, 0.0); glprint("bitmap", string); return 0; }
/* * Replacement for glRastePos3f() which avoids the problem with invalid * raster pos. */ void trRasterPos3d(const TRcontext *tr, GLdouble x, GLdouble y, GLdouble z) { if (tr->CurrentTile<0) { /* not doing tile rendering right now. Let OpenGL do this. */ glRasterPos3d(x, y, z); } else { GLdouble modelview[16], proj[16]; GLint viewport[4]; GLdouble winX, winY, winZ; /* Get modelview, projection and viewport */ glGetDoublev(GL_MODELVIEW_MATRIX, modelview); glGetDoublev(GL_PROJECTION_MATRIX, proj); viewport[0] = 0; viewport[1] = 0; viewport[2] = tr->CurrentTileWidth; viewport[3] = tr->CurrentTileHeight; /* Project object coord to window coordinate */ if (gluProject(x, y, z, modelview, proj, viewport, &winX, &winY, &winZ)){ /* set raster pos to window coord (0,0) */ glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0.0, (double)tr->CurrentTileWidth, 0.0, (double)tr->CurrentTileHeight, 0.0, 1.0); glRasterPos3d(0.0, 0.0, -winZ); /* Now use empty bitmap to adjust raster position to (winX,winY) */ { GLubyte bitmap[1] = {0}; glBitmap(1, 1, 0.0f, 0.0f, (GLfloat)winX, (GLfloat)winY, bitmap); } /* restore original matrices */ glPopMatrix(); /*proj*/ glMatrixMode(GL_MODELVIEW); glPopMatrix(); } #ifdef DEBUG if (glGetError()) printf("GL error!\n"); #endif } }
static void drawElementLabels(drawContext *ctx, GEntity *e, std::vector<T*> &elements, int forceColor=0, unsigned int color=0) { unsigned col = forceColor ? color : getColorByEntity(e); glColor4ubv((GLubyte *) & col); int labelStep = CTX::instance()->mesh.labelSampling; if(labelStep <= 0) labelStep = 1; for(unsigned int i = 0; i < elements.size(); i++){ MElement *ele = elements[i]; if(!isElementVisible(ele)) continue; if(i % labelStep == 0) { SPoint3 pc = ele->barycenter(); char str[256]; if(CTX::instance()->mesh.labelType == 4) sprintf(str, "(%g,%g,%g)", pc.x(), pc.y(), pc.z()); else if(CTX::instance()->mesh.labelType == 3) sprintf(str, "%d", ele->getPartition()); else if(CTX::instance()->mesh.labelType == 2){ int np = e->physicals.size(); int p = np ? e->physicals[np - 1] : 0; sprintf(str, "%d", p); } else if(CTX::instance()->mesh.labelType == 1) sprintf(str, "%d", e->tag()); else sprintf(str, "%d", ele->getNum()); glRasterPos3d(pc.x(), pc.y(), pc.z()); ctx->drawString(str); } } }
void text(char str[],double x,double y,double z=0,int choice=1) { glColor3d(0.0,0.0,0.0); glRasterPos3d(x,y,z); if(choice)glutBitmapString(GLUT_BITMAP_HELVETICA_12,(const unsigned char*)str); else glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_10,(const unsigned char*)str); }
void HPoint::glCommands(bool select, bool marked, bool no_color) { if(!no_color){ wxGetApp().glColorEnsuringContrast(color); } GLfloat save_depth_range[2]; if(marked){ glGetFloatv(GL_DEPTH_RANGE, save_depth_range); glDepthRange(0, 0); } else if(!m_draw_unselected) { glBegin(GL_POINTS); glVertex3d(m_p.X(), m_p.Y(), m_p.Z()); glEnd(); return; } glRasterPos3d(m_p.X(), m_p.Y(), m_p.Z()); glBitmap(16, 16, 8, 8, 10.0, 0.0, marked ? cross16_selected : cross16); if(marked){ glDepthRange(save_depth_range[0], save_depth_range[1]); } }
static void DrawText(const R3Point& p, const char *s) { // Draw text string s and position p glRasterPos3d(p[0], p[1], p[2]); while (*s) glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, *(s++)); }
void Font::putstring (char* s, float x, float y) { int i; glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); glColor3f(1.0f,1.0f,1.0f); glRasterPos3d(x,y,0.8); for (i=0; s[i]; i++) glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12,s[i]); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); }
void RasterFont::printString(const char *s, double x, double y, double z) { int length = (int)strlen(s); if (!length) return; if (length >= TEMP_BUFFER_SIZE) length = TEMP_BUFFER_SIZE - 1; // Sanitize string to avoid GL errors. char *s2 = temp_buffer; memcpy(s2, s, length); s2[length] = 0; for (int i = 0; i < length; i++) { if (s2[i] < 32 || s2[i] > 126) s2[i] = '!'; } // go to the right spot glRasterPos3d(x, y, z); glPushAttrib (GL_LIST_BIT); glListBase(fontOffset); glCallLists((GLsizei)strlen(s2), GL_UNSIGNED_BYTE, (GLubyte *) s2); glPopAttrib(); }
void myglBitmapString(double x, double y, double z, std::string const& str){ glRasterPos3d(x, y, z); for(unsigned int i=0; i<str.size(); ++i){ glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, str[i]); } }
void GMSH_CutGridPlugin::draw(void *context) { #if defined(HAVE_OPENGL) glColor4ubv((GLubyte *) & CTX::instance()->color.fg); double p[3]; drawContext *ctx = (drawContext*)context; getPoint(0, 0, p); glRasterPos3d(p[0], p[1], p[2]); ctx->drawString("(X0, Y0, Z0)"); if(getNbU() > 1){ getPoint(getNbU() - 1, 0, p); glRasterPos3d(p[0], p[1], p[2]); ctx->drawString("(X1, Y1, Z1)"); } if(getNbV() > 1){ getPoint(0, getNbV() - 1, p); glRasterPos3d(p[0], p[1], p[2]); ctx->drawString("(X2, Y2, Z2)"); } if(CutGridOptions_Number[11].def){ glBegin(GL_LINES); for(int i = 0; i < getNbU(); ++i){ getPoint(i, 0, p); glVertex3d(p[0], p[1], p[2]); getPoint(i, getNbV()-1, p); glVertex3d(p[0], p[1], p[2]); } for(int i = 0; i < getNbV(); ++i){ getPoint(0, i, p); glVertex3d(p[0], p[1], p[2]); getPoint(getNbU()-1, i, p); glVertex3d(p[0], p[1], p[2]); } glEnd(); } else{ for(int i = 0; i < getNbU(); ++i){ for(int j = 0; j < getNbV(); ++j){ getPoint(i, j, p); ctx->drawSphere(CTX::instance()->pointSize, p[0], p[1], p[2], 1); } } } #endif }
void renderBitmapString(double x, double y, double z, void *font, string str, double drop, int max) { int chars = 1; int newlines = 1; glRasterPos3d(x,y - (newlines * drop),z); for (string::iterator c = (&str)->begin(); c != (&str)->end(); ++c) { if (chars == max) break; chars ++; char chr = *c; if (chr == '_') chr = ' '; if (chr == '\n' || chr == '|') { newlines ++; glRasterPos3d(x,y - (newlines * drop),z); }else{ glutBitmapCharacter(font, chr); } } }
void drawNum(int id, double x, double y) { glRasterPos3d(x,y,0); string s = IntToStr(id); for(int i=0;i<s.size();i++){ glutBitmapCharacter(GLUT_BITMAP_8_BY_13, s.at(i)); } }
static void draw_text_start(GLfloat* pos, GLfloat char_height, GLfloat line_width) { glLineWidth(line_width); glPushMatrix(); glTranslatef(pos[0], pos[1], pos[2]); glRasterPos3d(pos[0],pos[1],pos[2]); float w = char_height/STROKE_SCALE; glScalef(w, w, w); }
// Desenha um texto na janela GLUT void Texto(){ int i; glColor3f(0,0,0); // Posição onde o textpontos será colocado //sprintf(textpontos,"Pontos: %d",pontos); glRasterPos3d(10, 0, 0); for(i=0; textpontos[i] != '\0'; ++i) glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,textpontos[i]); }
static void DrawText(const R2Point& p, const char *s) { // Draw text string s and position p R3Ray ray = viewer->WorldRay((int) p[0], (int) p[1]); R3Point position = ray.Point(2 * viewer->Camera().Near()); glRasterPos3d(position[0], position[1], position[2]); while (*s) glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, *(s++)); }
/* * Display the scene */ void display() { // Lorenz dat shit lorenz(); // Clear the image glClear(GL_COLOR_BUFFER_BIT); // Reset previous transforms glLoadIdentity(); // Set view angle glRotated(ph,1,0,0); glRotated(th,0,1,0); int i; glBegin(GL_LINE_STRIP); for (i=0;i<N;i++) { glColor3dv(pa[i]); glVertex3dv(pa[i]); } glEnd(); // Draw axes in white glColor3f(1,1,1); glBegin(GL_LINES); glVertex3d(0,0,0); glVertex3d(1,0,0); glVertex3d(0,0,0); glVertex3d(0,1,0); glVertex3d(0,0,0); glVertex3d(0,0,1); glEnd(); // Label axes glRasterPos3d(1,0,0); Print("X"); glRasterPos3d(0,1,0); Print("Y"); glRasterPos3d(0,0,1); Print("Z"); // Display parameters glWindowPos2i(5,5); Print("View Angle=%d,%d",th,ph); // Flush and swap glFlush(); glutSwapBuffers(); }
void myglStrokeString(double x, double y, double z, std::string const& str){ glPushMatrix(); glRasterPos3d(x, y, z); glScaled(0.1, 0.1, 0.1); for(unsigned int i=0; i<str.size(); ++i){ glutStrokeCharacter(GLUT_STROKE_MONO_ROMAN, str[i]); } glPopMatrix(); }
/* * Display the scene */ void display() { // Clear the image glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Reset previous transforms glLoadIdentity(); // Set view angle glRotated(ph,1,0,0); glRotated(th,0,1,0); glEnable(GL_DEPTH_TEST); //Enable z buffering /* Draw 4 Clyinders */ drawCylinder(0, 0, 0, 1, 1, 1, 0, 'r', 'b'); drawCylinder(.5, .5, .5, 1, 3, 1, 20, 'b', 'q'); drawCylinder(-.9, 0, 0, 2, 2, 1, 90, 'w', 'g'); drawCylinder(-.6, -.6, -.8, .3, .5, .3, -45, 'g', 'r'); // Draw axes in white glColor3f(1,1,1); glBegin(GL_LINES); glVertex3d(0,0,0); glVertex3d(1,0,0); glVertex3d(0,0,0); glVertex3d(0,1,0); glVertex3d(0,0,0); glVertex3d(0,0,1); glEnd(); // Label axes glRasterPos3d(1,0,0); Print("X"); glRasterPos3d(0,1,0); Print("Y"); glRasterPos3d(0,0,1); Print("Z"); // Display parameters glWindowPos2i(5,5); Print("View Angle=%d,%d",th,ph); // Flush and swap glFlush(); glutSwapBuffers(); }
void GLUTDrawText(const R3Point& p, const char *s) { // Draw text string s and position p glRasterPos3d(p[0], p[1], p[2]); #ifndef __CYGWIN__ while (*s) glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, *(s++)); #else while (*s) glutBitmapCharacter((void*)7, *(s++)); #endif }
/********************************************* ||displayString() function ||Purpose: draw a string on the screen *********************************************/ void displayString(double x, double y, char *str) { glRasterPos3d(x, y, 1); while (*str) { glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, *str); // Other fonts available. For example.. //glutBitmapCharacter(GLUT_BITMAP_9_BY_15, *str); //glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, *str); str++; } }
void axes() { // Draw axes in white glColor3f(1,1,1); glBegin(GL_LINES); glVertex3d(0,0,0); glVertex3d(90,0,0); glVertex3d(0,0,0); glVertex3d(0,90,0); glVertex3d(0,0,0); glVertex3d(0,0,90); glEnd(); // Label axes glRasterPos3d(90,0,0); Print("X"); glRasterPos3d(0,90,0); Print("Y"); glRasterPos3d(0,0,90); Print("Z"); }