/* display() renders 3 cones at different z positions. */ void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glTranslatef(-1.0, -1.0, -1.0); glRotatef(-90.0, 1.0, 0.0, 0.0); glIndexi(RAMPSTART); glutSolidCone(1.0, 2.0, 10, 10); glPopMatrix(); glPushMatrix(); glTranslatef(0.0, -1.0, -2.25); glRotatef(-90.0, 1.0, 0.0, 0.0); glIndexi(RAMPSTART); glutSolidCone(1.0, 2.0, 10, 10); glPopMatrix(); glPushMatrix(); glTranslatef(1.0, -1.0, -3.5); glRotatef(-90.0, 1.0, 0.0, 0.0); glIndexi(RAMPSTART); glutSolidCone(1.0, 2.0, 10, 10); glPopMatrix(); glFlush(); }
void TOpenGL_Form::DrawScene() { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glPushMatrix(); latitude += latinc; longitude += longinc; polarView( radius, 0, latitude, longitude ); glIndexi(RED_INDEX); glCallList(CONE); glIndexi(BLUE_INDEX); glCallList(GLOBE); glIndexi(GREEN_INDEX); glPushMatrix(); glTranslatef(0.8F, -0.65F, 0.0F); glRotatef(30.0F, 1.0F, 0.5F, 1.0F); glCallList(CYLINDER); glPopMatrix(); glPopMatrix(); SwapBuffers(ghDC); }
void gl_color(Fl_Color i) { #if USE_GL_OVERLAY #ifndef _WIN32 if (fl_overlay) {glIndexi(int(fl_xpixel(i))); return;} #else if (fl_overlay && fl_overlay_depth) { i = fl_nearest_color(i); // convert to 8-bit color if (fl_overlay_depth < 8) { // only black & white produce the expected colors. This could // be improved by fixing the colormap set in Fl_Gl_Overlay.cxx unsigned size = 1<<fl_overlay_depth; if (!i) glIndexi(size-2); else if (i >= size-2) glIndexi(size-1); else glIndexi(i); } else { glIndexi(i ? i : FL_GRAY_RAMP); } return; } #endif #endif Fl_Color c = fl_get_color(i); glColor3ub((uchar)(c>>24), (uchar)(c>>16), (uchar)(c>>8)); }
static void draw_cube( void ) { /* X faces */ glIndexi( Red ); glColor3f( 1.0, 0.0, 0.0 ); glBegin( GL_POLYGON ); 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 ); 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(); /* Y faces */ glIndexi( Green ); glColor3f( 0.0, 1.0, 0.0 ); glBegin( GL_POLYGON ); 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 ); 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(); /* Z faces */ glIndexi( Blue ); glColor3f( 0.0, 0.0, 1.0 ); glBegin( GL_POLYGON ); 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 ); 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(); }
void on_gl_draw () { glClear (GL_COLOR_BUFFER_BIT); glBegin (GL_TRIANGLES); glIndexi (0); glColor3f (1.0f, 0.0f, 0.0f); glVertex2i (0, 1); glIndexi (0); glColor3f (0.0f, 1.0f, 0.0f); glVertex2i (-1, -1); glIndexi (0); glColor3f (0.0f, 0.0f, 1.0f); glVertex2i (1, -1); glEnd (); }
static GLuint make_ball(void) { GLuint list; GLfloat a, b; GLfloat da = 18.0, db = 18.0; GLfloat radius = 1.0; GLuint color; GLfloat x, y, z; list = glGenLists(1); glNewList(list, GL_COMPILE); color = 0; for (a = -90.0; a + da <= 90.0; a += da) { glBegin(GL_QUAD_STRIP); for (b = 0.0; b <= 360.0; b += db) { if (color) { glIndexi(RED); glColor3f(1, 0, 0); } else { glIndexi(WHITE); glColor3f(1, 1, 1); } x = radius * COS(b) * COS(a); y = radius * SIN(b) * COS(a); z = radius * SIN(a); glVertex3f(x, y, z); x = radius * COS(b) * COS(a + da); y = radius * SIN(b) * COS(a + da); z = radius * SIN(a + da); glVertex3f(x, y, z); color = 1 - color; } glEnd(); } glEndList(); return list; }
bool wxGLCanvasBase::SetColour(const wxString& colour) { wxColour col = wxTheColourDatabase->Find(colour); if ( !col.IsOk() ) return false; #ifdef wxHAS_OPENGL_ES wxGLAPI::glColor3f((GLfloat) (col.Red() / 256.), (GLfloat) (col.Green() / 256.), (GLfloat) (col.Blue() / 256.)); #else GLboolean isRGBA; glGetBooleanv(GL_RGBA_MODE, &isRGBA); if ( isRGBA ) { glColor3f((GLfloat) (col.Red() / 256.), (GLfloat) (col.Green() / 256.), (GLfloat) (col.Blue() / 256.)); } else // indexed colour { GLint pix = GetColourIndex(col); if ( pix == -1 ) { wxLogError(_("Failed to allocate colour for OpenGL")); return false; } glIndexi(pix); } #endif return true; }
void DrawScene(void) { int i; glPushMatrix(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0); for (i = 0; i < RINGS; i++) { if (rgb) { glColor3ubv(rgb_colors[i]); } else { glIndexi(mapped_colors[i]); } glPushMatrix(); glTranslatef(dests[i][0] + offsets[i][0], dests[i][1] + offsets[i][1], dests[i][2] + offsets[i][2]); glRotatef(angs[i], rotAxis[i][0], rotAxis[i][1], rotAxis[i][2]); glCallList(theTorus); glPopMatrix(); } glPopMatrix(); if (doubleBuffer) { glutSwapBuffers(); } else { glFlush(); } }
bool wxGLCanvasBase::SetColour(const wxString& colour) { wxColour col = wxTheColourDatabase->Find(colour); if ( !col.Ok() ) return false; GLboolean isRGBA; glGetBooleanv(GL_RGBA_MODE, &isRGBA); if ( isRGBA ) { glColor3f(col.Red() / 256., col.Green() / 256., col.Blue() / 256.); } else // indexed colour { GLint pix = GetColourIndex(col); if ( pix == -1 ) { wxLogError(_("Failed to allocate colour for OpenGL")); return false; } glIndexi(pix); } return true; }
/* display() draws an icosahedron. */ void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glIndexi(RAMPSTART); auxWireIcosahedron(1.0); glFlush(); }
void wxGLContext::SetColour(const wxChar *colour) { wxColour the_colour = wxTheColourDatabase->Find(colour); if(the_colour.Ok()) { GLboolean b; glGetBooleanv(GL_RGBA_MODE, &b); if(b) { glColor3ub(the_colour.Red(), the_colour.Green(), the_colour.Blue()); } else { #ifdef __WXMOTIF__ the_colour.AllocColour(m_window->GetXDisplay()); #else the_colour.CalcPixel(wxTheApp->GetMainColormap(wxGetDisplay())); #endif GLint pix = (GLint)the_colour.GetPixel(); if(pix == -1) { wxLogError(wxT("wxGLCanvas: cannot allocate color\n")); return; } glIndexi(pix); } } }
void overlayDisplay(void) { if (glutLayerGet(GLUT_OVERLAY_DAMAGED)) { /* If damaged, clear the overlay. */ glClear(GL_COLOR_BUFFER_BIT); } else { /* If not damaged, undraw last overlay sphere. */ glIndexi(transparent); drawSphere(&oldOverlaySphere); } glIndexi(opaque); drawSphere(&overlaySphere); /* Single buffered window needs flush. */ glFlush(); /* Remember last overaly sphere position for undrawing. */ oldOverlaySphere = overlaySphere; }
static void Draw(void) { GLint ci1, ci2; glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); if (antiAlias) { ci1 = CI_OFFSET_1; ci2 = CI_OFFSET_2; glBlendFunc(GL_SRC_ALPHA, GL_ONE); glEnable(GL_BLEND); glEnable(GL_POLYGON_SMOOTH); glDisable(GL_DEPTH_TEST); } else { ci1 = 4; ci2 = 2; glDisable(GL_BLEND); glDisable(GL_POLYGON_SMOOTH); glEnable(GL_DEPTH_TEST); } if (stipple) { glEnable(GL_POLYGON_STIPPLE); } else { glDisable(GL_POLYGON_STIPPLE); } glBegin(GL_TRIANGLES); (rgb) ? glColor3f(0.0, 0.0, 1.0) : glIndexi(ci1); glVertex3f( 0.9, -0.9, -30.0); glVertex3f( 0.9, 0.9, -30.0); glVertex3f(-0.9, 0.0, -30.0); (rgb) ? glColor3f(0.0, 1.0, 0.0) : glIndexi(ci2); glVertex3f(-0.9, -0.9, -40.0); glVertex3f(-0.9, 0.9, -40.0); glVertex3f( 0.9, 0.0, -25.0); glEnd(); if (doubleBuffer) { glutSwapBuffers(); } else { glFlush(); } }
static void GLUTCALLBACK Draw(void) { GLint ci, i; glClear(GL_COLOR_BUFFER_BIT); glLineWidth(size); if (mode1) { glEnable(GL_LINE_STIPPLE); } else { glDisable(GL_LINE_STIPPLE); } if (mode2) { ci = CI_OFFSET; glEnable(GL_LINE_SMOOTH); glEnable(GL_POINT_SMOOTH); glEnable(GL_BLEND); } else { ci = COLOR_YELLOW; glDisable(GL_LINE_SMOOTH); glDisable(GL_POINT_SMOOTH); glDisable(GL_BLEND); } glPushMatrix(); glShadeModel( GL_FLAT ); for (i = 0; i < 360; i += 5) { glRotatef(5.0, 0,0,1); (rgb) ? glColor3f(1.0, 1.0, 0.0) : glIndexi(ci); glBegin(GL_LINE_STRIP); glVertex3fv(pntA); glVertex3fv(pntB); glEnd(); glPointSize(1+i/36); SetColor(COLOR_GREEN); glBegin(GL_POINTS); glVertex3fv(pntA); glVertex3fv(pntB); glEnd(); } glPopMatrix(); glFlush(); if (doubleBuffer) { glutSwapBuffers(); } }
void MAOpenGLInitCb( Widget w, XtPointer clientData, XtPointer callData) { static String xFontStr = "-*-courier-*-*-*-*-14-*-*-*-*-*-*-*"; Font xFont; WlzDVertex3 tVtx, orgVtx; Display *dpy = XtDisplay( w ); (void )HGUglwCreateCanvasGlxContext(w, NULL); HGUglwCanvasGlxMakeCurrent(w, NULL); xFont = XLoadFont(XtDisplay(w), xFontStr); if(xFont) { threeDFont = HGUglTextFontCreate(xFont); } glShadeModel(GL_FLAT); glEnable(GL_DEPTH_TEST); if( globals.toplDepth == 24 ){ glClearColor(0.0, 0.0, 0.0, 1.0); glEnable(GL_FOG); glFogf(GL_FOG_MODE, GL_LINEAR); } else { glClearIndex( (GLfloat) BlackPixelOfScreen(XtScreen(w)) ); } /* set the initial transform - should be from resources */ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRotated( (GLdouble) 90.0, (GLdouble) 1.0, (GLdouble) 0.0, (GLdouble) 0.0); glRotated((GLdouble) -40.0, (GLdouble) 0.0, (GLdouble) 0.0, (GLdouble) 1.0); glRotated( (GLdouble) 20.0, (GLdouble) 0.6, (GLdouble) 0.4, (GLdouble) 0.0); glGetDoublev(GL_MODELVIEW_MATRIX, &initial_rot[0][0]); /* create the default 3D display DisplayList */ globals.ref_display_list = glGenLists( (GLsizei) 1 ); glNewList( globals.ref_display_list, GL_COMPILE ); WLZ_VTX_3_SET(tVtx, 10.0, 10.0, 10.0); WLZ_VTX_3_SET(orgVtx, 5.0, 5.0, 5.0); if( globals.toplDepth == 24 ){ glColor3d((GLdouble) 1.0, (GLdouble) 1.0, (GLdouble) 1.0); } else { glIndexi( HGU_XGetColorPixel(dpy, globals.cmap, 1.0, 1.0, 1.0) ); } HGUglShapeWireCube(tVtx, orgVtx); glEndList(); WLZ_VTX_3_SET(globals.bbox_vtx, -2.0, -2.0, -2.0); WLZ_VTX_3_SET(globals.bbox_size, 14.0, 14.0, 14.0); return; }
void QGLWidget::qglColor( const QColor& c ) const { const QGLContext* ctx = QGLContext::currentContext(); if ( ctx ) { if ( ctx->format().rgba() ) glColor3ub( c.red(), c.green(), c.blue() ); else glIndexi( ctx->colorIndex( c ) ); } }
/* * Togl widget display callback. This is called by Tcl/Tk when the widget's * contents have to be redrawn. Typically, we clear the color and depth * buffers, render our objects, then swap the front/back color buffers. */ void display_cb(Togl *togl) { glClearIndex(black); glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); glTranslatef(0.3, -0.3, 0.0); glRotatef(Angle, 0.0, 0.0, 1.0); glIndexi(red); glBegin(GL_TRIANGLES); glVertex2f(-0.5, -0.3); glVertex2f(0.5, -0.3); glVertex2f(0.0, 0.6); glEnd(); glPopMatrix(); glPushMatrix(); glRotatef(Angle, 0.0, 0.0, 1.0); glIndexi(green); glBegin(GL_TRIANGLES); glVertex2f(-0.5, -0.3); glVertex2f(0.5, -0.3); glVertex2f(0.0, 0.6); glEnd(); glPopMatrix(); glPushMatrix(); glTranslatef(-0.3, 0.3, 0.0); glRotatef(Angle, 0.0, 0.0, 1.0); glIndexi(blue); glBegin(GL_TRIANGLES); glVertex2f(-0.5, -0.3); glVertex2f(0.5, -0.3); glVertex2f(0.0, 0.6); glEnd(); glPopMatrix(); glFlush(); Togl_SwapBuffers(togl); }
static void redraw(void) { glClear( GL_COLOR_BUFFER_BIT ); glPushMatrix(); glRotatef( Zrot, 0.0F, 0.0F, 1.0F ); #ifdef GL_SGI_index_func if (glIndexFuncSGIptr) { if (DoTest) { glEnable( GL_INDEX_TEST_SGI ); (*glIndexFuncSGIptr)( GL_GREATER, 128.0F ); } else { glDisable( GL_INDEX_TEST_SGI ); } } #endif glBegin( GL_LINES ); glIndexi( 10 ); glVertex2f( -1.0F, 0.0F ); glIndexi( 240 ); glVertex2f( 1.0F, 0.0F ); glEnd(); glBegin( GL_TRIANGLES ); glIndexi( 11 ); glVertex2f( 0.0F, 1.0F ); glIndexi( 100 ); glVertex2f( 0.5F, 0.1F ); glIndexi( 240 ); glVertex2f( -0.5F, 0.1F ); glEnd(); glRasterPos2f( 0.5F, -0.2F ); glDrawPixels( 32, 32, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, Image ); glPopMatrix(); SwapBuffers(hDC); checkError("after swap buffers"); }
/* * Togl widget overlay display callback. This is called by Tcl/Tk when the * overlay has to be redrawn. */ void overlay_display_cb( struct Togl *togl ) { glClear(GL_COLOR_BUFFER_BIT); glIndexi(Red); glBegin( GL_LINES ); glVertex2f( -1.0, -1.0 ); glVertex2f( 1.0, 1.0 ); glVertex2f( -1.0, 1.0 ); glVertex2f( 1.0, -1.0 ); glEnd(); glIndexi(Green); glBegin( GL_LINE_LOOP ); glVertex2f( -0.5, -0.5 ); glVertex2f( 0.5, -0.5 ); glVertex2f( 0.5, 0.5 ); glVertex2f( -0.5, 0.5 ); glEnd(); glFlush(); }
void display() { /* rotate a triangle around */ glClear(GL_COLOR_BUFFER_BIT); if (animate) glRotatef(1.0f, 0.0f, 0.0f, 1.0f); glBegin(GL_TRIANGLES); glIndexi(1); glColor3f(1.0f, 0.0f, 0.0f); glVertex2i(0, 1); glIndexi(2); glColor3f(0.0f, 1.0f, 0.0f); glVertex2i(-1, -1); glIndexi(3); glColor3f(0.0f, 0.0f, 1.0f); glVertex2i(1, -1); glEnd(); glFlush(); SwapBuffers(hDC); /* nop if singlebuffered */ }
/* display() draws 5 spheres at different z positions. */ void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glIndexi (RAMPSTART); renderSphere (-2., -0.5, -1.0); renderSphere (-1., -0.5, -2.0); renderSphere (0., -0.5, -3.0); renderSphere (1., -0.5, -4.0); renderSphere (2., -0.5, -5.0); glFlush(); }
void display(void) { int i; glClear(GL_COLOR_BUFFER_BIT); glIndexi (RAMPSTART); glBegin (GL_POINTS); for (i = 1; i < 10; i++) { glVertex2f ((GLfloat) i * 10.0, (GLfloat) i * 10.0); } glEnd (); glFlush(); }
UGL_LOCAL void drawGL (void) { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_TRIANGLES); (rgb) ? glColor3f(1.0, 0.3, 0.3) : glIndexi(RED); glVertex2f(0.75, -0.50); (rgb) ? glColor3f(0.3, 1.0, 0.3) : glIndexi(GREEN); glVertex2f(0.0, 0.75); (rgb) ? glColor3f(0.3, 0.3, 1.0) : glIndexi(BLUE); glVertex2f(-0.75, -0.50); glEnd(); glBegin(GL_LINES); (rgb) ? glColor3f(1.0, 0.3, 0.3) : glIndexi(RED); glVertex2f(-1.0, 1.0); (rgb) ? glColor3f(0.3, 0.3, 1.0) : glIndexi(BLUE); glVertex2f(1.0, -1.0); glEnd(); glFlush(); uglMesaSwapBuffers(); }
/* Draw 2 diagonal lines to form an X */ static void display(void) { glClear(GL_COLOR_BUFFER_BIT); glIndexi(RAMP1START); glPushMatrix(); glRotatef(-rotAngle, 0.0, 0.0, 0.1); glBegin (GL_LINES); glVertex2f (-0.5, 0.5); glVertex2f (0.5, -0.5); glEnd (); glPopMatrix(); glIndexi(RAMP2START); glPushMatrix(); glRotatef(rotAngle, 0.0, 0.0, 0.1); glBegin (GL_LINES); glVertex2f (0.5, 0.5); glVertex2f (-0.5, -0.5); glEnd (); glPopMatrix(); glFlush(); }
void DrawScene(void) { int i, j; GLboolean goIdle; goIdle = GL_TRUE; for (i = 0; i < RINGS; i++) { if (iters[i]) { for (j = 0; j < 3; j++) { offsets[i][j] = Clamp(iters[i], offsets[i][j]); } angs[i] = Clamp(iters[i], angs[i]); iters[i]--; goIdle = GL_FALSE; } } if (goIdle) { glutIdleFunc(NULL); } glPushMatrix(); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); gluLookAt(0,0,10, 0,0,0, 0,1,0); for (i = 0; i < RINGS; i++) { if (rgb) { glColor3ubv(rgb_colors[i]); } else { glIndexi(mapped_colors[i]); } glPushMatrix(); glTranslatef(dests[i][0]+offsets[i][0], dests[i][1]+offsets[i][1], dests[i][2]+offsets[i][2]); glRotatef(angs[i], rotAxis[i][0], rotAxis[i][1], rotAxis[i][2]); glCallList(theTorus); glPopMatrix(); } glPopMatrix(); if (doubleBuffer) { glutSwapBuffers(); } else { glFlush(); } }
/* ARGSUSED1 */ void key2(unsigned char c, int w, int h) { int transP; printf("c=%d\n", c); switch (c) { case 'g': glutReshapeWindow( glutGet(GLUT_WINDOW_WIDTH) + 2, glutGet(GLUT_WINDOW_HEIGHT) + 2); break; case 's': glutReshapeWindow( glutGet(GLUT_WINDOW_WIDTH) - 2, glutGet(GLUT_WINDOW_HEIGHT) - 2); break; case 'u': glutPopWindow(); break; case 'd': glutPushWindow(); break; case 'e': glutEstablishOverlay(); transP = glutLayerGet(GLUT_TRANSPARENT_INDEX); glClearIndex(transP); glutSetColor((transP + 1) % 2, 0.0, 0.25, 0.0); glIndexi((transP + 1) % 2); break; case 'c': if (glutLayerGet(GLUT_HAS_OVERLAY)) { glutUseLayer(GLUT_OVERLAY); glutCopyColormap(main_w); } break; case 'r': glutRemoveOverlay(); break; case ' ': printf("overlay possible: %d\n", glutLayerGet(GLUT_OVERLAY_POSSIBLE)); printf("layer in use: %d\n", glutLayerGet(GLUT_LAYER_IN_USE)); printf("has overlay: %d\n", glutLayerGet(GLUT_HAS_OVERLAY)); printf("transparent index: %d\n", glutLayerGet(GLUT_TRANSPARENT_INDEX)); break; } }
static void draw(void) { GLint i; glClear(GL_COLOR_BUFFER_BIT); glIndexi(CYAN); glColor3f(0, 1, 1); glBegin(GL_LINES); for (i = -5; i <= 5; i++) { glVertex2i(i, -5); glVertex2i(i, 5); } for (i = -5; i <= 5; i++) { glVertex2i(-5, i); glVertex2i(5, i); } for (i = -5; i <= 5; i++) { glVertex2i(i, -5); glVertex2f(i * 1.15, -5.9); } glVertex2f(-5.3, -5.35); glVertex2f(5.3, -5.35); glVertex2f(-5.75, -5.9); glVertex2f(5.75, -5.9); glEnd(); glPushMatrix(); glTranslatef(Xpos, Ypos, 0.0); glScalef(2.0, 2.0, 2.0); glRotatef(8.0, 0.0, 0.0, 1.0); glRotatef(90.0, 1.0, 0.0, 0.0); glRotatef(Zrot, 0.0, 0.0, 1.0); glCallList(Ball); glPopMatrix(); glFlush(); glutSwapBuffers(); }
void s2_menu(int option) { int transP; switch (option) { case 1: glutRemoveOverlay(); break; case 2: glutEstablishOverlay(); transP = glutLayerGet(GLUT_TRANSPARENT_INDEX); glClearIndex(transP); glutSetColor((transP + 1) % 2, 0.0, 0.25, 0.0); glIndexi((transP + 1) % 2); break; case 666: exit(0); break; } }
void CVisText::draw() { if(Show){ // Only get exact calibration location of center // and approximate the rest of the points float x = XPosToScreen(X,Y); float y = YPosToScreen(X,Y); // Only ask if center is clipped?! Clipped = VISWIN_IS_CLIPPED(x,y); // Setup Transformation glMatrixMode (GL_MODELVIEW); glLoadIdentity(); glTranslatef(x,y,Z); // 4: Translate to POS glRotatef(Angle,0,0,1); // 3: Rotate About Z axis glScalef(ScaleX,ScaleY,1); // 2: Scale glTranslatef(-Length/2,-Height/2,0); // 1: Translate to Center the Text // Set Color and Lighting Properties #if INDEX_MODE glIndexi(ColorIndex); #else glColor4f(Color[0],Color[1],Color[2],Alpha); #endif // glPushAttrib(GL_LIST_BIT); // Pushes The Display List Bits // Indicate start of glyph display lists glListBase (listBase); // Now draw the characters in a string glCallLists (strlen(textString), GL_UNSIGNED_BYTE, textString); // glPopAttrib(); // Pops The Display List Bits } }
GLXContext * init_GL(ModeInfo * mi) { Display *dpy = mi->dpy; Window window = mi->window; Screen *screen = mi->xgwa.screen; Visual *visual = mi->xgwa.visual; GLXContext glx_context = 0; XVisualInfo vi_in, *vi_out; int out_count; vi_in.screen = screen_number (screen); vi_in.visualid = XVisualIDFromVisual (visual); vi_out = XGetVisualInfo (dpy, VisualScreenMask|VisualIDMask, &vi_in, &out_count); if (! vi_out) abort (); { XSync (dpy, False); orig_ehandler = XSetErrorHandler (BadValue_ehandler); glx_context = glXCreateContext (dpy, vi_out, 0, GL_TRUE); XSync (dpy, False); XSetErrorHandler (orig_ehandler); if (got_error) glx_context = 0; } XFree((char *) vi_out); if (!glx_context) { fprintf(stderr, "%s: couldn't create GL context for visual 0x%x.\n", progname, (unsigned int) XVisualIDFromVisual (visual)); exit(1); } glXMakeCurrent (dpy, window, glx_context); { GLboolean rgba_mode = 0; glGetBooleanv(GL_RGBA_MODE, &rgba_mode); if (!rgba_mode) { glIndexi (WhitePixelOfScreen (screen)); glClearIndex (BlackPixelOfScreen (screen)); } } /* jwz: the doc for glDrawBuffer says "The initial value is GL_FRONT for single-buffered contexts, and GL_BACK for double-buffered contexts." However, I find that this is not always the case, at least with Mesa 3.4.2 -- sometimes the default seems to be GL_FRONT even when glGet(GL_DOUBLEBUFFER) is true. So, let's make sure. Oh, hmm -- maybe this only happens when we are re-using the xscreensaver window, and the previous GL hack happened to die with the other buffer selected? I'm not sure. Anyway, this fixes it. */ { GLboolean d = False; glGetBooleanv (GL_DOUBLEBUFFER, &d); if (d) glDrawBuffer (GL_BACK); else glDrawBuffer (GL_FRONT); } /* GLXContext is already a pointer type. Why this function returns a pointer to a pointer, I have no idea... */ { GLXContext *ptr = (GLXContext *) malloc(sizeof(GLXContext)); *ptr = glx_context; return ptr; } }