void draw_flame_4_map(struct buffer_for_gl *gl_buf, int iflag_write_ps){ int i, j, nd, inum, ierr; double rtp_flame[6], d_map_flame[4], f_color[4]; glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glVertexPointer(ITWO, GL_FLOAT, IZERO, gl_buf->xy); glColorPointer(IFOUR, GL_FLOAT, IZERO, gl_buf->rgba); glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); glEnable(GL_LINE_STIPPLE); glLineStipple(1,0x3333); if (iflag_write_ps == ON) {ierr = gl2psEnable(GL2PS_LINE_STIPPLE);}; set_black_color_c(f_color); inum = 0; rtp_flame[0] = ONE; rtp_flame[3] = ONE; for(j=0; j<NUM_P+1; j++){ rtp_flame[2] = phi_p_grid[j]; rtp_flame[5] = phi_p_grid[j]; for(i=0; i<N_CURVE; i++){ rtp_flame[1] = theta_p_grid[i]; rtp_flame[4] = theta_p_grid[i+1]; aitoff_c(ITWO, rtp_flame, d_map_flame); gl_buf->xy[ITWO*inum ][0] = d_map_flame[0]; gl_buf->xy[ITWO*inum ][1] = d_map_flame[1]; gl_buf->xy[ITWO*inum+1][0] = d_map_flame[2]; gl_buf->xy[ITWO*inum+1][1] = d_map_flame[3]; inum = inum + 1; } } for(j=0; j<NUM_T-1; j++){ rtp_flame[1] = theta_t_grid[j] ; rtp_flame[4] = theta_t_grid[j]; for(i=0; i<N_CURVE; i++){ rtp_flame[2] = phi_t_grid[i]; rtp_flame[5] = phi_t_grid[i+1]; aitoff_c(ITWO, rtp_flame, d_map_flame); gl_buf->xy[ITWO*inum ][0] = d_map_flame[0]; gl_buf->xy[ITWO*inum ][1] = d_map_flame[1]; gl_buf->xy[ITWO*inum+1][0] = d_map_flame[2]; gl_buf->xy[ITWO*inum+1][1] = d_map_flame[3]; inum = inum + 1; } } for (j=0; j<ITWO*inum; j++) { for(nd=0;nd<4;nd++){gl_buf->rgba[j][nd] = f_color[nd];} } if(inum>0){glDrawArrays(GL_LINES, IZERO, (ITWO*inum));}; if (iflag_write_ps == ON) {ierr = gl2psDisable(GL2PS_LINE_STIPPLE);}; glDisable(GL_LINE_STIPPLE); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); return; }
void extras() { glColor3f(1., 0., 0.); glPointSize(1.); gl2psPointSize(1.); glBegin(GL_POINTS); glVertex3f(-1., 1.0, 0.); glEnd(); glPointSize(3.); gl2psPointSize(3.); glBegin(GL_POINTS); glVertex3f(-0.8, 1.0, 0.); glEnd(); glPointSize(5.); gl2psPointSize(5.); glBegin(GL_POINTS); glVertex3f(-0.6, 1.0, 0.); glEnd(); glPointSize(7.); gl2psPointSize(7.); glBegin(GL_POINTS); glVertex3f(-0.4, 1.0, 0.); glEnd(); glLineWidth(1.); gl2psLineWidth(1.); glBegin(GL_LINES); glVertex3f(-0.2, 1.05, 0.); glVertex3f(0.2, 1.05, 0.); glEnd(); glEnable(GL_LINE_STIPPLE); glLineStipple(1, 0x087F); gl2psEnable(GL2PS_LINE_STIPPLE); glBegin(GL_LINES); glVertex3f(-0.2, 0.95, 0.); glVertex3f(0.2, 0.95, 0.); glEnd(); glDisable(GL_LINE_STIPPLE); gl2psDisable(GL2PS_LINE_STIPPLE); glLineWidth(3.); gl2psLineWidth(3.); glBegin(GL_LINES); glVertex3f(0.4, 1.05, 0.); glVertex3f(0.8, 1.05, 0.); glEnd(); glEnable(GL_LINE_STIPPLE); glLineStipple(2, 0x0F0F); /* glLineStipple(1, 0xAAAA); */ gl2psEnable(GL2PS_LINE_STIPPLE); glBegin(GL_LINES); glVertex3f(0.4, 0.95, 0.); glVertex3f(0.8, 0.95, 0.); glEnd(); glDisable(GL_LINE_STIPPLE); gl2psDisable(GL2PS_LINE_STIPPLE); glPointSize(1); gl2psPointSize(1); glLineWidth(1); gl2psLineWidth(1); }
void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); printOpenGLError(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); gluLookAt(m_camera.position.x, m_camera.position.y, m_camera.position.z, m_camera.lookat.x, m_camera.lookat.y, m_camera.lookat.z, m_camera.up.x, m_camera.up.y, m_camera.up.z); printOglError(0,0); if(true) { gl2psEnable(GL2PS_LINE_STIPPLE); if(!noxyz) UIHelper::drawXYZ(); glPolygonMode(GL_FRONT_AND_BACK, polygon_mode); glColor3f(0.1, 0.8, 0); UIHelper::drawBoundingBox(boxobj2); { mat4 rotateMatrix = rotateDeg == 0 ? mat4::Identity : mat4::GetRotate(rotateDeg, rotateAxis); mat4 translateMatrix = mat4::GetTranslate(translatePos); mat4 transformMatrix = translateMatrix * rotateMatrix; { mat4 indentity = mat4::Identity; //double tx = 1.51, ty = 0, tz = 0; double tx = translatePos.x, ty = translatePos.y, tz = translatePos.z; double m [16] = { 1.0, 0, 0, 0, 0.0, 1.0, 0, 0, 0.0, 0, 1.0, 0, tx, ty, tz, 1.0 }; { dtSelectObject(&object1); dtLoadMatrixd(m); //dtLoadIdentity(); //dtTranslate(tx, ty, tz); if(dtTestPair(&object1, &object2)) //if(dtTest() > 0) glColor3f(1.0, 0, 0); else glColor3f(0.1, 0.8, 0); } } } if(rotateDeg != 0) glRotatef(rotateDeg, rotateAxis.x, rotateAxis.y, rotateAxis.z); glTranslatef(translatePos.x, translatePos.y, translatePos.z); UIHelper::drawBoundingBox(boxobj1); gl2psDisable(GL2PS_LINE_STIPPLE); }else { glColor3f(1, 0, 1); glPolygonMode(GL_FRONT_AND_BACK ,GL_LINE); glLineWidth(1.0); GLUquadricObj *qobj = gluNewQuadric(); gluSphere(qobj,3,16,16); glLineWidth(2.0); UIHelper::drawNormals(normals, 3); glPointSize(5.0f); UIHelper::drawPoints(normals); } glPopMatrix(); glFlush(); if( finish_without_update ) glFinish(); else glutSwapBuffers(); }
static void display(void) { unsigned int i; unsigned int N = 50; const char *help = "Press 's' to save image or 'q' to quit"; glClearColor(0.3, 0.5, 0.8, 0.); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* draw a smooth-shaded torus */ glPushMatrix(); glRotatef(-60., 2., 0., 1.); glEnable(GL_LIGHTING); glutSolidTorus(0.3, 0.6, 30, 30); glDisable(GL_LIGHTING); glPopMatrix(); /* draw three triangles on the same zplane and use polygon offset to order the layers: the grey triangle should be drawn on the middle layer */ glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(1.0, 1.0); gl2psEnable(GL2PS_POLYGON_OFFSET_FILL); glColor3f(0.,0.,0.); glBegin(GL_TRIANGLES); glVertex3f(0.6, 0.8, 0); glVertex3f(0.8, 0.8, 0); glVertex3f(0.7, 0.92, 0); glEnd(); glPolygonOffset(2.0, 2.0); gl2psEnable(GL2PS_POLYGON_OFFSET_FILL); glColor3f(1.,1.,1.); glBegin(GL_TRIANGLES); glVertex3f(0.7, 0.8, 0); glVertex3f(0.9, 0.8, 0); glVertex3f(0.8, 0.92, 0); glEnd(); glPolygonOffset(1.5, 1.5); gl2psEnable(GL2PS_POLYGON_OFFSET_FILL); glColor3f(0.5,0.5,0.5); glBegin(GL_TRIANGLES); glVertex3f(0.65, 0.86, 0); glVertex3f(0.85, 0.86, 0); glVertex3f(0.75, 0.98, 0); glEnd(); glDisable(GL_POLYGON_OFFSET_FILL); gl2psDisable(GL2PS_POLYGON_OFFSET_FILL); glColor3f(0.1,0.1,0.1); /* draw a stippled line with many small segments (this tests the ability of gl2ps to render lines using as few strokes as possible) */ glEnable(GL_LINE_STIPPLE); glLineStipple(1, 0x087F); gl2psEnable(GL2PS_LINE_STIPPLE); glBegin(GL_LINE_STRIP); for(i = 0; i < N; i++) glVertex3f(-0.75 + 1.5 * (double)i/(double)(N - 1), 0.75, -0.9); glEnd(); glDisable(GL_LINE_STIPPLE); gl2psDisable(GL2PS_LINE_STIPPLE); /* draw a text string */ glRasterPos2d(-0.9,-0.9); gl2psText(help, "Times-Roman", 24); for (i = 0; i < strlen(help); i++) glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, help[i]); glFlush(); }