void PartialDisque::BuildAndDisplay() { // Génération du cylindre partiel exterieur _cylExtPartiel->FastDisplay(); // Génération du cylindre interieur if(_diametreInterieur != 0){ GLUquadric* paramsCylInt = gluNewQuadric(); gluCylinder(paramsCylInt, _diametreInterieur/2, _diametreInterieur/2,_height,_slices,1); } // Géréation des 2 disques GLUquadric* paramsDiscH = gluNewQuadric(); gluPartialDisk(paramsDiscH,_diametreInterieur/2,_diametreExterieur/2,_slices,1, 0, _angle); gluDisk(paramsDiscH,0,_diametreInterieur/2,_slices,1); glPushMatrix(); glTranslatef(0.0, 0.0, _height); GLUquadric* paramsDiscB = gluNewQuadric(); gluPartialDisk(paramsDiscH,_diametreInterieur/2,_diametreExterieur/2,_slices,1, 0, _angle); gluDisk(paramsDiscH,0,_diametreInterieur/2,_slices,1); glPopMatrix(); float angle = DEGREES_TO_RADIANS(15); // Pattern Point3D patternFlanc[2], flanc[4]; patternFlanc[0] = Point3D(0, -_diametreExterieur/2, 0); patternFlanc[1] = Point3D(0, -_diametreExterieur/2, _height); for(int i=0; i<4; i++) flanc[i] = Point3D(patternFlanc[i%2]._x * cosf((i>1)?-angle:angle) - patternFlanc[i%2]._y * sinf((i>1)?-angle:angle), patternFlanc[i%2]._x * sinf((i>1)?-angle:angle) + patternFlanc[i%2]._y * cosf((i>1)?-angle:angle), patternFlanc[i%2]._z); }
void PolarGridRenderer::render() { if(m_grid) { glPushMatrix(); glTranslatef(0.f, 0.f, m_depth); if(m_position) { glTranslatef(m_position->x, m_position->y, 0.f); glRotatef(rad2deg(m_position->theta), 0.f, 0.f, 1.f); } double sweep = 2*M_PI/(m_phiEdges->size() - 1); for(unsigned int i = 0; i < m_grid->size(); i ++) { for(unsigned int j = 0; j < (*m_grid)[i].size(); j++) { glPushMatrix(); m_color.lightness() = m_maxValue == 0.? 1. : 1. - 0.5*(*m_grid)[i][j]/m_maxValue; Color color(HSL2RGB(m_color)); double inner = (*m_rhoEdges)[j]; double outer = (*m_rhoEdges)[j+1]; double start = -(*m_phiEdges)[i] + M_PI_2; glColor4f(color.red(), color.green(), color.blue(), color.alpha()); gluQuadricDrawStyle(m_GLUSectors[i * (*m_grid)[i].size() + j], GLU_FILL); gluPartialDisk(m_GLUSectors[i * (*m_grid)[i].size() + j], inner, outer, m_subdivision[0], m_subdivision[1], rad2deg(start), rad2deg(-sweep)); glColor4f(0.f, 0.f, 0.f, 1.f); gluQuadricDrawStyle(m_GLUGrids[i * (*m_grid)[i].size() + j], GLU_SILHOUETTE); gluPartialDisk(m_GLUGrids[i * (*m_grid)[i].size() + j], inner, outer, m_subdivision[0], m_subdivision[1], rad2deg(start), rad2deg(-sweep)); glPopMatrix(); } } glColor4f(0.f,0.f,0.f,1.f); glBegin(GL_LINES); glVertex3f(0.f, 0.f, 0.f); glVertex3f((*m_rhoEdges)[m_rhoEdges->size() - 1] + 0.1f, 0.f, 0.f); glEnd(); glPopMatrix(); } }
void ssr::QOpenGLPlotter::_draw_loudspeaker(bool muted, bool active) { glColor3f(0.4f, 0.4f, 0.4f); if (muted) { // plot muted loudspeaker // TODO: Make lines wider? glBegin(GL_LINE_STRIP); glVertex3f( -0.02f, 0.017f, 0.0f); glVertex3f( -0.02f, -0.017f, 0.0f); glVertex3f( 0.002f, -0.017f, 0.0f); glVertex3f( 0.024f, -0.040f, 0.0f); glVertex3f( 0.024f, 0.040f, 0.0f); glVertex3f( 0.002f, 0.017f, 0.0f); glVertex3f( -0.02f, 0.017f, 0.0f); glEnd(); } else { // plot loudspeaker glBegin(GL_TRIANGLE_FAN); // magnet glVertex3f( -0.02f, 0.017f, 0.0f); glVertex3f( -0.02f, -0.017f, 0.0f); glVertex3f( -0.002f, -0.017f, 0.0f); glVertex3f( -0.002f, 0.017f, 0.0f); glEnd(); glBegin(GL_TRIANGLE_FAN); // cone glVertex3f( 0.002f, 0.017f, 0.0f); glVertex3f( 0.002f, -0.017f, 0.0f); glVertex3f( 0.024f, -0.040f, 0.0f); glVertex3f( 0.024f, 0.040f, 0.0f); glEnd(); glColor3f(1.0f, 1.0f, 1.0f); glBegin(GL_TRIANGLE_FAN); // ring glVertex3f( -0.002f, 0.017f, 0.0f); glVertex3f( -0.002f, -0.017f, 0.0f); glVertex3f( 0.002f, -0.017f, 0.0f); glVertex3f( 0.002f, 0.017f, 0.0f); glEnd(); if (active) { // plot sound waves // TODO: more elegant if (_active_source == -1) _active_source = 0; qglColor(_color_vector[_id_of_last_clicked_source%_color_vector.size()]); gluPartialDisk(_glu_quadric, 0.05f ,0.055f, LEVELOFDETAIL, 1, 50.0f, 80.0f); gluPartialDisk(_glu_quadric, 0.1f , 0.105f, LEVELOFDETAIL, 1, 50.0f, 80.0f); gluPartialDisk(_glu_quadric, 0.15f, 0.155f, LEVELOFDETAIL, 1, 50.0f, 80.0f); } } }
void drawRangeRing(GLfloat range, GLfloat fov, GLfloat range_width) { glPushMatrix(); glRotatef((fov/2.0f) - 90, 0.f, 0.f, 1.f); gluPartialDisk(GLUWrapper::getQuadradic(), range, range + range_width, 32, 1, 0.f, fov); glPopMatrix(); }
void __fastcall TFormMapper::Render() { CameraLookAt(0,-4,12,0,0,0,0,1,0); glClearColor(bgr,bgg,bgb,0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glPushMatrix(); //Render all that stuff here //Quadrics //gluSphere, gluCylinder, gluDisk, gluPartialDisk glEnable(GL_TEXTURE_2D); textures.SetTexture(0); glRotatef(xrot,1,0,0); glRotatef(yrot,0,1,0); glRotatef(zrot,0,0,1); if (tool==0)gluSphere(obj,4,128,16); if (tool==1) { glTranslatef(0,0,-3); gluCylinder(obj,3,3,6,128,16); } if (tool==2)gluDisk(obj,1,4,128,16); if (tool==3)gluPartialDisk(obj,1,4,128,16,0,270); glDisable(GL_TEXTURE_2D); glPushMatrix(); SwapBuffers(hDC); glFlush(); }
JNIEXPORT void JNICALL Java_OpenGL_GLUQuadric_partialDisk (JNIEnv *env, jobject obj, jlong quadric, jdouble innerRadius, jdouble outerRadius, jint slices, jint loops, jdouble startAngle, jdouble sweepAngle) { gluPartialDisk(TO_POINTER(quadric), innerRadius, outerRadius, slices, loops, startAngle, sweepAngle); }
void GLThread::DrawArcBetweenMats(Vector3d& center, Vector3d& dir1, Vector3d& dir2, double inner_radius, double outer_radius, string& str) { updateThreadPoints(); GLUquadricObj *quadric=gluNewQuadric(); gluQuadricNormals(quadric, GLU_SMOOTH); glDisable(GL_TEXTURE_2D); glPushMatrix(); float pt_loc[3]; for (int j=0; j < 3; j++) { pt_loc[j] = (float)center(j)-display_start_pos(j); } glTranslatef(pt_loc[0], pt_loc[1], pt_loc[2]); Matrix3d rot_mat; rot_mat.col(0) = dir1; Vector3d newy = dir2; make_vectors_perpendicular(rot_mat.col(0), newy); rot_mat.col(1) = newy.normalized(); rot_mat.col(2) = rot_mat.col(0).cross(rot_mat.col(1)).normalized(); //rot_mat = Eigen::AngleAxisd(M_PI/2.0, rot_mat.col(0))*rot_mat; double angx, angy, angz; euler_angles_from_rotation(rot_mat, angz, angy, angx); glRotatef(angz*180.0/M_PI, 0.0, 0.0, 1.0); glRotatef(angy*180.0/M_PI, 0.0, 1.0, 0.0); glRotatef(angx*180.0/M_PI, 1.0, 0.0, 0.0); double max_ang = abs(acos(dir1.dot(dir2)))*180.0/M_PI; gluPartialDisk(quadric, inner_radius, outer_radius, 20, 20, 90, max_ang); glRasterPos3f (0,-3.0,3.0); for (string::iterator s = str.begin(); s != str.end(); ++s) { char c = *s; glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, c); } glPopMatrix(); glEnable(GL_TEXTURE_2D); }
void display_all(void) { GLUquadricObj *qobj = NULL; double innerRadiusOfRing; double outerRadiusOfRing; double start_angle; double angular_step; static int current_list = 0 ; int ring, spoke ; double scaleFactor; glClear(GL_COLOR_BUFFER_BIT); current_list = !current_list ; glNewList(current_list, GL_COMPILE) ; angular_step = 360.0/numSpokes; scaleFactor = pow( (maxEcc/minEcc), (1.0/( (double) numRings) ) ); innerRadiusOfRing = minEcc; outerRadiusOfRing = minEcc * scaleFactor; /* draw radial checkerboard */ for (ring = 0; ring < numRings; ring++) { for (spoke = 0; spoke < numSpokes; spoke++) { start_angle = spoke * angular_step; glColor3f(redFrames[ring][spoke][currentFrame], greenFrames[ring][spoke][currentFrame], blueFrames[ring][spoke][currentFrame]) ; qobj = gluNewQuadric(); gluPartialDisk(qobj, (GLdouble) innerRadiusOfRing, /* inner radius */ (GLdouble) outerRadiusOfRing, /* outer radius */ (GLint) angular_step, /* #vert. on disk perimeter */ 1, /* # vertices on disk ray (minus 1) */ (GLdouble) start_angle, /* start angle for wedge */ (GLdouble) angular_step); /* wedge width in degrees */ } innerRadiusOfRing *= scaleFactor; outerRadiusOfRing *= scaleFactor; } /* glTranslatef( -Width/2 , -Height/2 , 0 ); */ glEndList() ; glCallList(current_list) ; /* glFlush();*/ glutSwapBuffers(); }
static void init(void) { GLUquadricObj *qobj; GLfloat mat_ambient[] = { 0.5, 0.5, 0.5, 1.0 }; GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat mat_shininess[] = { 50.0 }; GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; GLfloat model_ambient[] = { 0.5, 0.5, 0.5, 1.0 }; glClearColor(0.0, 0.0, 0.0, 0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); glLightfv(GL_LIGHT0, GL_POSITION, light_position); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, model_ambient); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); /* Create 4 display lists, each with a different quadric object. * Different drawing styles and surface normal specifications * are demonstrated. */ startList = glGenLists(4); qobj = gluNewQuadric(); gluQuadricCallback(qobj, GLU_ERROR, (GLvoid (CALLBACK*) ()) errorCallback); gluQuadricDrawStyle(qobj, GLU_FILL); /* smooth shaded */ gluQuadricNormals(qobj, GLU_SMOOTH); glNewList(startList, GL_COMPILE); gluSphere(qobj, 0.75, 15, 10); glEndList(); gluQuadricDrawStyle(qobj, GLU_FILL); /* flat shaded */ gluQuadricNormals(qobj, GLU_FLAT); glNewList(startList+1, GL_COMPILE); gluCylinder(qobj, 0.5, 0.3, 1.0, 15, 5); glEndList(); gluQuadricDrawStyle(qobj, GLU_LINE); /* all polygons wireframe */ gluQuadricNormals(qobj, GLU_NONE); glNewList(startList+2, GL_COMPILE); gluDisk(qobj, 0.25, 1.0, 20, 4); glEndList(); gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); /* boundary only */ gluQuadricNormals(qobj, GLU_NONE); glNewList(startList+3, GL_COMPILE); gluPartialDisk(qobj, 0.0, 1.0, 20, 4, 0.0, 225.0); glEndList(); gluDeleteQuadric(qobj); }
// Draw function void Arc::drawFunc() { BEGIN_DLIST GLUquadricObj* qobj = gluNewQuadric(); if (isFilled()) { gluQuadricDrawStyle(qobj, GLU_FILL); } else { gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); } if (connected) { gluPartialDisk(qobj, 0, getRadius(), getSlices(), 2, startAngle, arcLength); } else { gluPartialDisk(qobj, getRadius(), getRadius(), getSlices(), 2, startAngle, arcLength); } gluDeleteQuadric(qobj); END_DLIST }
void View::initDlPacMan2D() { // création de la liste pour le dessin du PacMan 2D idList_PacMan_2D = idList_SuperPill + 1; glNewList(idList_PacMan_2D, GL_COMPILE); GLUquadricObj *disque = gluNewQuadric(); gluQuadricDrawStyle(disque, GLU_FILL); gluPartialDisk(disque, 0, 10, 100, 1, 135, 270); gluDeleteQuadric(disque); glEndList(); }
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer glLoadIdentity(); // Reset The View glTranslatef(0.0f,0.0f,z); glRotatef(xrot,1.0f,0.0f,0.0f); glRotatef(yrot,0.0f,1.0f,0.0f); glBindTexture(GL_TEXTURE_2D, texture[filter]); switch(object) { case 0: glDrawCube(); break; case 1: glTranslatef(0.0f,0.0f,-1.5f); // Center The Cylinder gluCylinder(quadratic,1.0f,1.0f,3.0f,32,32); // A Cylinder With A Radius Of 0.5 And A Height Of 2 break; case 2: gluDisk(quadratic,0.5f,1.5f,32,32); // Draw A Disc (CD Shape) With An Inner Radius Of 0.5, And An Outer Radius Of 2. Plus A Lot Of Segments ;) break; case 3: gluSphere(quadratic,1.3f,32,32); // Draw A Sphere With A Radius Of 1 And 16 Longitude And 16 Latitude Segments break; case 4: glTranslatef(0.0f,0.0f,-1.5f); // Center The Cone gluCylinder(quadratic,1.0f,0.0f,3.0f,32,32); // A Cone With A Bottom Radius Of .5 And A Height Of 2 break; case 5: part1+=p1; part2+=p2; if(part1>359) // 360 Degrees { p1=0; part1=0; p2=1; part2=0; } if(part2>359) // 360 Degrees { p1=1; p2=0; } gluPartialDisk(quadratic,0.5f,1.5f,32,32,part1,part2-part1); // A Disk Like The One Before break; }; xrot+=xspeed; yrot+=yspeed; return TRUE; // Keep Going }
void Sample_18::draw() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer glLoadIdentity(); // Reset The View glTranslatef(0.0f,0.0f,m_z); // Translate Into The Screen glRotatef(m_xrot,1.0f,0.0f,0.0f); // Rotate On The X Axis glRotatef(m_yrot,0.0f,1.0f,0.0f); // Rotate On The Y Axis glBindTexture(GL_TEXTURE_2D, m_texture[m_filter]); // Select A Filtered Texture switch(m_object) // Check object To Find Out What To Draw { case 0: // Drawing Object 1 glDrawCube(); // Draw Our Cube break; // Done case 1: // Drawing Object 2 glTranslatef(0.0f,0.0f,-1.5f); // Center The Cylinder gluCylinder(m_quadratic,1.0f,1.0f,3.0f,32,32); // Draw Our Cylinder break; // Done case 2: // Drawing Object 3 gluDisk(m_quadratic,0.5f,1.5f,32,32); // Draw A Disc (CD Shape) break; // Done case 3: // Drawing Object 4 gluSphere(m_quadratic,1.3f,32,32); // Draw A Sphere break; // Done case 4: // Drawing Object 5 glTranslatef(0.0f,0.0f,-1.5f); // Center The Cone gluCylinder(m_quadratic,1.0f,0.0f,3.0f,32,32); // A Cone With A Bottom Radius Of .5 And A Height Of 2 break; // Done case 5: // Drawing Object 6 m_part1+=m_p1; // Increase Start Angle m_part2+=m_p2; // Increase Sweep Angle if(m_part1>359) // 360 Degrees { m_p1=0; // Stop Increasing Start Angle m_part1=0; // Set Start Angle To Zero m_p2=1; // Start Increasing Sweep Angle m_part2=0; // Start Sweep Angle At Zero } if(m_part2>359) // 360 Degrees { m_p1=1; // Start Increasing Start Angle m_p2=0; // Stop Increasing Sweep Angle } gluPartialDisk(m_quadratic,0.5f,1.5f,32,32,m_part1,m_part2-m_part1); // A Disk Like The One Before break; // Done }; m_xrot+=m_xspeed; // Increase Rotation On X Axis m_yrot+=m_yspeed; // Increase Rotation On Y Axis }
/* quad:PartialDisk (inner, outer, slices, loops, start, sweep) -> quad */ static int luaglu_partial_disk(lua_State *L) { LuaGLUquadric *lquad=luaglu_checkquadric(L,1); gluPartialDisk(lquad->quad,luaL_checknumber(L, 2), luaL_checknumber(L, 3), luaL_checkinteger(L, 4),luaL_checkinteger(L, 5), luaL_checknumber(L, 6),luaL_checknumber(L, 7)); lua_pushvalue(L,1); return 1; }
void gst_opengl_gluPartialDisk (GLenum draw, GLenum normals, GLenum orient, GLboolean texture, GLdouble inner, GLdouble outer, GLint slices, GLint loops, GLdouble start, GLdouble sweep) { GLUquadric *q = gluNewQuadric (); gluQuadricDrawStyle (q, draw); gluQuadricNormals (q, normals); gluQuadricOrientation (q, orient); gluQuadricTexture (q, texture); gluPartialDisk (q, inner, outer, slices, loops, start, sweep); gluDeleteQuadric (q); }
// Draw function void OcclusionArc::drawFunc() { BEGIN_DLIST GLUquadricObj* qobj = gluNewQuadric(); if (isFilled()) { gluQuadricDrawStyle(qobj, GLU_FILL); } else { gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); } gluPartialDisk(qobj, getRadius(), outerRadius, getSlices(), 2, getStartAngle(), getArcLength()); gluDeleteQuadric(qobj); END_DLIST }
void RobotDrawComponent::drawObject() { //drawCircle(getXDisplay(rPos.x), getYDisplay(rPos.y), 0.1, 10); //GLUquadric* test = gluNewQuadric(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glTranslatef(getXDisplay(rPos.x), getYDisplay(rPos.y), 0.0f); for (int i = 0; i < NUM_OF_CONES; i++) cones[i]->drawObject(); glColor4f(1.0, 0.0, 0.0, 0.8f); gluPartialDisk(gluNewQuadric(), 0, 0.1, 100, 10, -orientationAngle+100, 340); glTranslatef(-getXDisplay(rPos.x), -getYDisplay(rPos.y), 0.0f); }
void Display(void) { glClear(GL_COLOR_BUFFER_BIT); //用当前背景色填充窗口 glMatrixMode(GL_MODELVIEW); //制定设置模型视图变换参数 glLoadIdentity(); //消除以前的变换 glRotatef(xRot,1.0f,0.0f,0.0f); //绕X轴旋转图形 glRotatef(yRot,0.0f,1.0f,0.0f); //绕y轴旋转图形 switch(iMode) { case 1: glutWireTetrahedron();break; //绘制线框正四面体 case 2: glutSolidTetrahedron();break; //绘制实体正四面体 case 3: glutWireOctahedron();break; //绘制线框正八面体 case 4: glutSolidOctahedron();break;//绘制实体正八面体 case 5: glutWireSphere(1.0f,15,15);break; //绘制线框球 case 6: glutSolidSphere(1.0f,15,15);break;//绘制实体球 case 7: glutWireTeapot(1.0f);break; //绘制线框茶壶 case 8: glutSolidTeapot(1.0f);break;//绘制实体茶壶 case 9: gluSphere(obj,1.0f,15,15);break; //绘制二次曲面(球) case 10: gluCylinder(obj,1.0f,0.0f,1.0f,15,15);break;//绘制二次曲面(圆锥) case 11: gluPartialDisk(obj,0.3f,0.8f,15,15,30.0f,260.0f);break; //绘制二次曲面(圆环) default: break; } }
Pacman::Pacman(void) { lives = 3; dir = 0; x = 0; y = 0; z = 0; step = 1.00; material = 6; ang = 0; inc_ang = -1; list_ptr = glGenLists(1); GLUquadricObj *qobj = gluNewQuadric(); gluQuadricDrawStyle(qobj, GLU_FILL); gluQuadricNormals(qobj, GLU_NONE); glNewList(list_ptr, GL_COMPILE); glPushMatrix(); //dibuja el tope gluPartialDisk(qobj, 0.0, 0.5, 20, 4, 0.0, 270.0); glPopMatrix(); glEndList(); }
//------------------------------------------------------------------------------ // drawFunc() -- draws the object(s) //------------------------------------------------------------------------------ void DialArcSegment::drawFunc() { // get our data from our base class double startAngle = getStartAngle(); double radius = getRadius(); double sweepAngle = getSweepAngle(); GLint curSlices = getSlices(); // our slice amount should go up as we get more of a sweep, if not, it will // look funny. Pretty much one slice per degree sweep double y = std::fabs(static_cast<double>(sweepAngle)); curSlices = curSlices + static_cast<GLint>(y * 0.05f); // draw our arc glPushMatrix(); GLUquadric* qobj = gluNewQuadric(); if (filled) gluQuadricDrawStyle(qobj, GL_FILL); else gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); gluPartialDisk(qobj, radius, outerRadius, curSlices, 1, startAngle, sweepAngle); gluDeleteQuadric(qobj); glPopMatrix(); }
static int tolua_glu_gluPartialDisk00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"GLUquadricObj",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnumber(tolua_S,6,0,&tolua_err) || !tolua_isnumber(tolua_S,7,0,&tolua_err) || !tolua_isnoobj(tolua_S,8,&tolua_err) ) goto tolua_lerror; else #endif { GLUquadricObj* qobj = ((GLUquadricObj*) tolua_tousertype(tolua_S,1,0)); double innerRadius = (( double) tolua_tonumber(tolua_S,2,0)); double outerRadius = (( double) tolua_tonumber(tolua_S,3,0)); int slices = (( int) tolua_tonumber(tolua_S,4,0)); int loops = (( int) tolua_tonumber(tolua_S,5,0)); double startAngle = (( double) tolua_tonumber(tolua_S,6,0)); double sweepAngle = (( double) tolua_tonumber(tolua_S,7,0)); { gluPartialDisk(qobj,innerRadius,outerRadius,slices,loops,startAngle,sweepAngle); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'gluPartialDisk'.",&tolua_err); return 0; #endif }
void display_expanding_rings(void) { GLUquadricObj *qobj = NULL; double innerRadiusOfRing; double outerRadiusOfRing; double start_angle; double angular_step; static int current_list = 0 ; int ring, spoke, bit; double scaleFactor; double t, T, eccRange; double innerRadiusOfAnnulus; double outerRadiusOfAnnulus; putenv("__GL_SYNC_TO_VBLANK=23") ; /* will force syncing with vertical retrace */ glClear(GL_COLOR_BUFFER_BIT); current_list = !current_list ; glNewList(current_list, GL_COMPILE) ; angular_step = 360.0/numSpokes; scaleFactor = pow( (maxEcc/minEcc), (1.0/( (double) numRings) ) ); innerRadiusOfRing = minEcc; outerRadiusOfRing = minEcc * scaleFactor; /* draw radial checkerboard */ for (ring = 0; ring < numRings; ring++) { if ( ring % 2 ) bit = 0; else bit = 1; for (spoke = 0; spoke < numSpokes; spoke++) { start_angle = spoke * angular_step; if ( (spoke + bit) % 2 ) glColor3f(On, On, On); else glColor3f(1-On, 1-On, 1-On); qobj = gluNewQuadric(); gluPartialDisk(qobj, (GLdouble) innerRadiusOfRing, /* inner radius */ (GLdouble) outerRadiusOfRing, /* outer radius */ (GLint) angular_step, /* #vert. on disk perimeter */ 1, /* # vertices on disk ray (minus 1) */ (GLdouble) start_angle, /* start angle for wedge */ (GLdouble) angular_step); /* wedge width in degrees */ } innerRadiusOfRing *= scaleFactor; outerRadiusOfRing *= scaleFactor; } T = stimPeriod; t = timePoint - counter*T; if (t > T) { outerRadiusOfAnnulus = maxEcc; innerRadiusOfAnnulus = minEcc; counter++; } eccRange = log(maxEcc) - log(minEcc); if (OUTWARD == 1) { /*** --------- EXP. OUTWARD ---------- ***/ if ( t < T/2 ) { outerRadiusOfAnnulus = maxEcc; innerRadiusOfAnnulus = (log(minEcc) + log(maxEcc))/2 + eccRange * (1/T) * t; innerRadiusOfAnnulus = exp(innerRadiusOfAnnulus); /* Threshold, and add 1 (pixel?) so that mask overcovers stim */ if ( outerRadiusOfAnnulus >= maxEcc) outerRadiusOfAnnulus = maxEcc + 1; /* Threshold, and subtract 1 so that mask overcovers stim */ if ( innerRadiusOfAnnulus <= minEcc) innerRadiusOfAnnulus = minEcc - 1; /*** GL calls to draw annulus ***/ glColor3f(0.5, 0.5, 0.5); gluDisk(qobj, (GLdouble) innerRadiusOfAnnulus, (GLdouble) outerRadiusOfAnnulus, 360, 1); outerRadiusOfAnnulus = log(minEcc) + eccRange * (1/T) * t; outerRadiusOfAnnulus = exp(outerRadiusOfAnnulus); innerRadiusOfAnnulus = minEcc; /* Threshold, and add 1 (pixel?) so that mask overcovers stim */ if ( outerRadiusOfAnnulus >= maxEcc) outerRadiusOfAnnulus = maxEcc + 1; /* Threshold, and subtract 1 so that mask overcovers stim */ if ( innerRadiusOfAnnulus <= minEcc) innerRadiusOfAnnulus = minEcc - 1; /*** GL calls to draw annulus ***/ glColor3f(0.5, 0.5, 0.5); gluDisk(qobj, (GLdouble) innerRadiusOfAnnulus, (GLdouble) outerRadiusOfAnnulus, 360, 1); } else { innerRadiusOfAnnulus = log(minEcc) + eccRange * (1/T) * (t - T/2); innerRadiusOfAnnulus = exp(innerRadiusOfAnnulus); outerRadiusOfAnnulus = (log(minEcc) + log(maxEcc))/2 + eccRange * (1/T) * (t - T/2); outerRadiusOfAnnulus = exp(outerRadiusOfAnnulus); /* Threshold, and add 1 (pixel?) so that mask overcovers stim */ if ( outerRadiusOfAnnulus >= maxEcc) outerRadiusOfAnnulus = maxEcc + 1; /* Threshold, and subtract 1 so that mask overcovers stim */ if ( innerRadiusOfAnnulus <= minEcc) innerRadiusOfAnnulus = minEcc - 1; /*** GL calls to draw annulus ***/ glColor3f(0.5, 0.5, 0.5); gluDisk(qobj, (GLdouble) innerRadiusOfAnnulus, (GLdouble) outerRadiusOfAnnulus, 360, 1); } } else { /*** --------- EXP. INWARD ---------- ***/ if ( t < T/2 ) { outerRadiusOfAnnulus = (log(minEcc) + log(maxEcc))/2 - eccRange * (1/T) * t; outerRadiusOfAnnulus = exp(outerRadiusOfAnnulus); innerRadiusOfAnnulus = minEcc; /* Threshold, and add 1 (pixel?) so that mask overcovers stim */ if ( outerRadiusOfAnnulus >= maxEcc) outerRadiusOfAnnulus = maxEcc + 1; /* Threshold, and subtract 1 so that mask overcovers stim */ if ( innerRadiusOfAnnulus <= minEcc) innerRadiusOfAnnulus = minEcc - 1; /*** GL calls to draw annulus ***/ glColor3f(0.5, 0.5, 0.5); gluDisk(qobj, (GLdouble) innerRadiusOfAnnulus, (GLdouble) outerRadiusOfAnnulus, 360, 1); outerRadiusOfAnnulus = maxEcc; innerRadiusOfAnnulus = log(maxEcc) - eccRange * (1/T) * t; innerRadiusOfAnnulus = exp(innerRadiusOfAnnulus); /* Threshold, and add 1 (pixel?) so that mask overcovers stim */ if ( outerRadiusOfAnnulus >= maxEcc) outerRadiusOfAnnulus = maxEcc + 1; /* Threshold, and subtract 1 so that mask overcovers stim */ if ( innerRadiusOfAnnulus <= minEcc) innerRadiusOfAnnulus = minEcc - 1; /*** GL calls to draw annulus ***/ glColor3f(0.5, 0.5, 0.5); gluDisk(qobj, (GLdouble) innerRadiusOfAnnulus, (GLdouble) outerRadiusOfAnnulus, 360, 1); } else { innerRadiusOfAnnulus = (log(minEcc) + log(maxEcc))/2 - eccRange * (1/T) * (t - T/2); innerRadiusOfAnnulus = exp(innerRadiusOfAnnulus); outerRadiusOfAnnulus = log(maxEcc) - eccRange * (1/T) * (t - T/2); outerRadiusOfAnnulus = exp(outerRadiusOfAnnulus); /* Threshold, and add 1 (pixel?) so that mask overcovers stim */ if ( outerRadiusOfAnnulus >= maxEcc) outerRadiusOfAnnulus = maxEcc + 1; /* Threshold, and subtract 1 so that mask overcovers stim */ if ( innerRadiusOfAnnulus <= minEcc) innerRadiusOfAnnulus = minEcc - 1; /*** GL calls to draw annulus ***/ glColor3f(0.5, 0.5, 0.5); gluDisk(qobj, (GLdouble) innerRadiusOfAnnulus, (GLdouble) outerRadiusOfAnnulus, 360, 1); } } /* glTranslatef( -Width/2 , -Height/2 , 0 ); */ glEndList() ; glCallList(current_list) ; /* glFlush();*/ glutSwapBuffers(); }
void Graphics::render(TrackData_t *track) { if (!initialized) { error->log(GRAPHICS, IMPORTANT, "Render function called without graphics initialization\n"); return; } if (track) { int i, j; /* load in the vertices */ Vec3f_t vert; GLUquadricObj *quadobj = gluNewQuadric(); Vec3f_t v; Segment_t *seg; int len; float ang; glColor3f(1,1,0); glBegin(GL_LINES); for (i = 0; i < track->nLanes; i++) { for (j = 0; j < track->lanes[i].nSegs; j++) { seg = &track->lanes[i].segs[j]; switch (track->lanes[i].segs[j].kind) { case LINE_SEGMENT: CopyV3f(track->verts[seg->start], vert); glVertex3f(vert[0], vert[1] + .01, vert[2]); CopyV3f(track->verts[seg->end], vert); glVertex3f(vert[0], vert[1] + .01, vert[2]); break; case ARC_SEGMENT: glEnd(); CopyV3f(track->verts[seg->center],v); glPushMatrix(); glTranslatef(v[0], v[1] + .01, v[2]); glRotatef(-90,1,0,0); SubV3f(v, track->verts[seg->start], v); len = LengthV3f(v); ang = seg->end > seg->start ? seg->angle : -seg->angle; gluPartialDisk(quadobj, len-.05, len, 40, 5, 0, ang); gluPartialDisk(quadobj, len-.05, len, 40, 5, 0, ang); glPopMatrix(); glBegin(GL_LINES); break; } } } glEnd(); gluDeleteQuadric(quadobj); /* draw finish line */ glDisable(GL_LIGHTING); glColor3f(1,0,1); glLineStipple(1, 0x0C0F); glLineWidth(4); glBegin(GL_LINES); glVertex3fv(track->verts[track->sects[0].edges[0].start]); glVertex3fv(track->verts[track->sects[0].edges[1].start]); glEnd(); glLineWidth(1); glDisable(GL_LINE_STIPPLE); glEnable(GL_LIGHTING); } }
void PsychRenderArc(unsigned int mode) { PsychColorType color; PsychRectType rect; double *startAngle, *arcAngle, *penWidth, *penHeight; PsychWindowRecordType *windowRecord; int depthValue, whiteValue, colorPlaneSize, numColorPlanes; double dotSize; boolean isArgThere; GLUquadric *diskQuadric = NULL; //get the window record from the window record argument and get info from the window record PsychAllocInWindowRecordArg(kPsychUseDefaultArgPosition, TRUE, &windowRecord); //Get the depth from the window, we need this to interpret the color argument. depthValue=PsychGetWindowDepthValueFromWindowRecord(windowRecord); numColorPlanes=PsychGetNumPlanesFromDepthValue(depthValue); colorPlaneSize=PsychGetColorSizeFromDepthValue(depthValue); //Get the color argument or use the default, then coerce to the form determened by the window depth. isArgThere=PsychCopyInColorArg(kPsychUseDefaultArgPosition, FALSE, &color); if(!isArgThere){ whiteValue=PsychGetWhiteValueFromDepthValue(depthValue); PsychLoadColorStruct(&color, kPsychIndexColor, whiteValue ); //index mode will coerce to any other. } PsychCoerceColorModeFromSizes(numColorPlanes, colorPlaneSize, &color); // Get the rect to which the object should be inscribed: Default is "full screen" PsychMakeRect(rect, 0, 0, PsychGetWidthFromRect(windowRecord->rect), PsychGetHeightFromRect(windowRecord->rect)); PsychCopyInRectArg(3, FALSE, rect); double w=PsychGetWidthFromRect(rect); double h=PsychGetHeightFromRect(rect); double cx, cy, aspect; PsychGetCenterFromRectAbsolute(rect, &cx, &cy); if (w==0 || h==0) PsychErrorExitMsg(PsychError_user, "Invalid rect (width or height equals zero) provided!"); // Get start angle: PsychAllocInDoubleArg(4, TRUE, &startAngle); PsychAllocInDoubleArg(5, TRUE, &arcAngle); if (mode==2) { // Get pen width and height: penWidth=NULL; penHeight=NULL; PsychAllocInDoubleArg(6, FALSE, &penWidth); PsychAllocInDoubleArg(7, FALSE, &penHeight); // Check if penWidth and penHeight spec'd. If so, they // need to be equal: if (penWidth && penHeight && (*penWidth!=*penHeight)) { PsychErrorExitMsg(PsychError_user, "penWidth and penHeight must be equal on OS-X if both are specified!"); } dotSize=1; if (penWidth) dotSize = *penWidth; if (penHeight) dotSize = *penHeight; } // Setup OpenGL context: PsychSetGLContext(windowRecord); PsychUpdateAlphaBlendingFactorLazily(windowRecord); PsychSetGLColor(&color, depthValue); // Backup our modelview matrix: glMatrixMode(GL_MODELVIEW); glPushMatrix(); // Position disk at center of rect: glTranslated(cx, cy, 0); // Scale in order to fit to rect in case w!=h: glScaled(1.0, -h/w, 1.0); // Draw filled partial disk: diskQuadric=gluNewQuadric(); switch (mode) { case 1: // One pixel thin arc: InnerRadius = OuterRadius - 1 gluPartialDisk(diskQuadric, (w/2) - 1.0, w/2, w, 2, *startAngle, *arcAngle); break; case 2: // dotSize thick arc: InnerRadius = OuterRadius - dotsize gluPartialDisk(diskQuadric, (dotSize < (w/2)) ? (w/2) - dotSize : 0, w/2, w, 2, *startAngle, *arcAngle); break; case 3: // Filled arc: gluPartialDisk(diskQuadric, 0, w/2, w, 1, *startAngle, *arcAngle); break; } gluDeleteQuadric(diskQuadric); // Restore old matrix: glPopMatrix(); return; }
// Funciones a definir desde Effect.h void FXmanga::perFrame(float time) { float z_depth=-0.0120f,y_desp; static float pulso=0; int i; fxradialblur->prepareFrame(); glClearColor(0.8,0,0.8,1); glClear(GL_COLOR_BUFFER_BIT); //------------ matriz de objetos/whatever glMatrixMode(GL_PROJECTION); glPushMatrix(); glColor3f(1,1,1); float z=0; cam.toOGL(); glDisable(GL_DEPTH_TEST); glEnable(GL_SMOOTH); glLineWidth(1.5); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glScalef(3,3,3); glRotatef(time * 0.15,0,1,0); glTranslatef(-1,0,0); // una k , q se me ha ocurrido for(i=1; i < 9;i++) { glMatrixMode(GL_MODELVIEW); glPushMatrix(); glTranslatef(0.1*i,0,0); glBegin(GL_LINE_STRIP); glVertex3f(0,2,z); glVertex3f(0,-2,z); glVertex3f(0.2,-2,z); glVertex3f(1.7,2,z); glVertex3f(1.9,2,z); glVertex3f(1.1,0.1,z); glVertex3f(2,-2,z); glEnd(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); } glMatrixMode(GL_MODELVIEW); glPopMatrix(); glEnable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glPopMatrix(); //------------ fin de matriz de objetos fxradialblur->postprepareFrame(); fxradialblur->perFrame(time); miDemo->ponOrtopedico(1,1);//(miDemo->getWidth(),miDemo->getHeight()); // el q debe ser es 2,2 glEnable(GL_BLEND); // ahora algunos adornos technoish //glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO); //glBlendFunc(GL_DST_COLOR, GL_SRC_ALPHA); glEnable(GL_LINE_SMOOTH); glHint(GL_LINE_SMOOTH_HINT,GL_NICEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); float c=1 ; // componente de color , es para hacer un grisaceo int slices = 64; float part1, part2; float d1; // estas distancias las usare para cambiar el radio de los discos glColor4f(c,c,c,0.3); d1=0.25*sin(time*0.005); // Varios círculos (algunos fijos y otros no) gluDisk(quad,0.02f,0.025f,slices,slices); gluDisk(quad,0.08f,0.1f,slices,slices); gluDisk(quad,0.36f+d1,0.362f+d1,slices/2,slices/2); gluDisk(quad,0.36f+d1+d1,0.362f+d1+d1,slices/2,slices/2); gluDisk(quad,0.4f,0.41f,slices,slices); // Trocitos de pizza pero en disco part1=0; // Trozos del centro part2=20; glMatrixMode(GL_MODELVIEW); glPushMatrix(); for(i=1;i<4;i++) { glRotatef(time*.1,0,0,-1); gluPartialDisk(quad,0.06f,0.08f,slices,slices,part1,part2-part1); } glMatrixMode(GL_MODELVIEW); glPopMatrix(); // Trozos intermedios part2=20; glMatrixMode(GL_MODELVIEW); glPushMatrix(); for(i=1;i<6;i++) { glRotatef(time*.05,0,0,1); gluPartialDisk(quad,0.2f,0.30f,slices,slices,part1,part2-part1); } glMatrixMode(GL_MODELVIEW); glPopMatrix(); // Trozos mas gordos part2=30; glMatrixMode(GL_MODELVIEW); glPushMatrix(); for(i=1;i<4;i++) { glRotatef(time*.0200,0,0,-1); gluPartialDisk(quad,0.5f,1.5f,slices,slices,part1,part2-part1); } glMatrixMode(GL_MODELVIEW); glPopMatrix(); // ---------fin adornos technoish //------------ Trozo de muñeco/oso cabron glColor4f(1,1,1,1); glEnable(GL_TEXTURE_2D); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); if((this->_row%8)==0) { pulso=1; fxradialblur->setTimes(16); } else { fxradialblur->setTimes(10); } if(pulso>0) { pulso=pulso - pulso*pulso*0.9; } y_desp=pulso; glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glTranslatef(0.0,-0.7,0); glBindTexture(GL_TEXTURE_2D, this->text_oso.texID); float lado=0.7; glBegin(GL_QUADS); glNormal3f( 0.0f, 0.0f, 1.0f); glTexCoord2f(0,0); glVertex3f(0,0+y_desp,z_depth); glTexCoord2f(1, 0); glVertex3f(lado,0+y_desp, z_depth); glTexCoord2f(1,1); glVertex3f(lado,lado+y_desp, z_depth); glTexCoord2f(0,1); glVertex3f(0,lado+y_desp,z_depth); glEnd(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); y_desp=-y_desp; glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); //z_depth-=0.1; glTranslatef(-0.5,.1,0); glBindTexture(GL_TEXTURE_2D, this->text_k.texID); glBegin(GL_QUADS); glNormal3f( 0.0f, 0.0f, 1.0f); glTexCoord2f(0,0); glVertex3f(0,0+y_desp,z_depth); glTexCoord2f(1, 0); glVertex3f(0.35,0+y_desp, z_depth); glTexCoord2f(1,1); glVertex3f(0.35,0.5+y_desp, z_depth); glTexCoord2f(0,1); glVertex3f(0,0.35+y_desp,z_depth); //glVertex3f(0,0,0); glEnd(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glDisable(GL_TEXTURE_2D); // fin osocabron miDemo->quitaOrtopedico(); glDisable(GL_SMOOTH); glDisable(GL_BLEND); // fade float alfa; if((_row<=16)&&(_pattern==5)) { alfa=float(16-_row)/16.0; glDisable(GL_DEPTH_TEST); fxfade->setFadeColor(1,1,1,alfa); fxfade->perFrame(_time); glEnable(GL_DEPTH_TEST); } else if((_row>=112)&&(_pattern==6)) { alfa=float(_row%16)/16.0; glDisable(GL_DEPTH_TEST); fxfade->setFadeColor(1,1,1,alfa); fxfade->perFrame(_time); glEnable(GL_DEPTH_TEST); } else if((_row%8)==0){ alfa=0.15; glDisable(GL_DEPTH_TEST); fxfade->setFadeColor(1,1,1,alfa); fxfade->perFrame(_time); glEnable(GL_DEPTH_TEST); } }
void GLAPIENTRY gluDisk(GLUquadric *qobj, GLdouble innerRadius, GLdouble outerRadius, GLint slices, GLint loops) { gluPartialDisk(qobj, innerRadius, outerRadius, slices, loops, 0.0, 360.0); }
void drawFish() { quad=gluNewQuadric(); gluQuadricNormals(quad, GLU_SMOOTH); gluQuadricTexture(quad, GL_TRUE); glDisable(GL_BLEND); //body glPushMatrix(); // set the material GLfloat material_diffuse[] = {.80, .80, .80}; glMaterialfv(GL_FRONT, GL_DIFFUSE, material_diffuse); glTranslatef(translate[0], translate[1], translate[2]); glScalef(3.0, 1, 1); glutSolidSphere(1.0, 30, 30); // recover the transform state glPopMatrix(); //eye glPushMatrix(); GLfloat material_ambient1[] = {.80, .80, .80}; GLfloat material_diffuse1[] = {.80, .80, .80}; GLfloat material_specular1[] = {.80, .80, .80}; GLfloat material_shininess1 = 25.0f; glMaterialfv(GL_FRONT, GL_AMBIENT, material_ambient1); glMaterialfv(GL_FRONT, GL_DIFFUSE, material_diffuse1); glMaterialfv(GL_FRONT, GL_SPECULAR, material_specular1); glMaterialf(GL_FRONT, GL_SHININESS, material_shininess1); //quad, base radius, top radius, height, slices, stacks glTranslatef(translate[0] + 2, translate[1] + .2, translate[2]+.8); gluDisk(quad, 0, .3, 20, 20); glPopMatrix(); glPushMatrix(); GLfloat material_diffuse2[] = {0, 0, 0}; glMaterialfv(GL_FRONT, GL_DIFFUSE, material_diffuse2); //quad, base radius, top radius, height, slices, stacks glTranslatef(translate[0] + 2, translate[1] + .2, translate[2]+.9); gluDisk(quad, 0, .15, 10, 10); glPopMatrix(); //fins glPushMatrix(); GLfloat material_diffuse3[] = {.4, .4, .4}; glMaterialfv(GL_FRONT, GL_DIFFUSE, material_diffuse3); //quad, base radius, top radius, height, slices, stacks glTranslatef(translate[0]-3.0, translate[1]+.1, translate[2]+.3); gluPartialDisk(quad, 0, 1.3, 20, 20, 0, 180); glPopMatrix(); glPushMatrix(); glMaterialfv(GL_FRONT, GL_DIFFUSE, material_diffuse3); //quad, base radius, top radius, height, slices, stacks glTranslatef(translate[0]-.8, translate[1]+.4, translate[2]+.25); gluPartialDisk(quad, 0, 1.3, 20, 20, 0, 90); glPopMatrix(); glPushMatrix(); glMaterialfv(GL_FRONT, GL_DIFFUSE, material_diffuse3); //quad, base radius, top radius, height, slices, stacks glTranslatef(translate[0]-.1, translate[1]-.3, translate[2]+.9); gluPartialDisk(quad, 0, 1, 20, 20, 90, 100); glPopMatrix(); glEnable(GL_BLEND); return; }
//------------------------------------------------------------------------------ // drawFunc() //------------------------------------------------------------------------------ void AoAIndexer::drawFunc() { // if we have components, we are going to check for a ROTARY base::PairStream* subcomponents = getComponents(); if (subcomponents != nullptr) { subcomponents->unref(); subcomponents = nullptr; return; } GLfloat currentColor[4]; GLfloat lw = 0; glGetFloatv(GL_CURRENT_COLOR, ¤tColor[0]); glGetFloatv(GL_LINE_WIDTH, &lw); // check our state and draw accordingly if (aoaState == 1) { glPushMatrix(); glColor3f(1, 0, 0); glTranslatef(0, 1.0, 0); glLineWidth(3.0); glBegin(GL_LINES); glVertex2f(-0.05f, 0.0); glVertex2f(-0.2f, 0.4f); glVertex2f(0.05f, 0.0); glVertex2f(0.2f, 0.4f); glEnd(); glPopMatrix(); } if (aoaState == -1) { glPushMatrix(); glColor3f(1, 1, 0); glLineWidth(3.0); glTranslatef(0, -1.0, 0); glBegin(GL_LINES); glVertex2f(-0.05f, 0.0); glVertex2f(-0.2f, -0.4f); glVertex2f(0.05f, 0.0); glVertex2f(0.2f, -0.4f); glEnd(); glPopMatrix(); } if (aoaState == 0) { // now draw the lines to blend out the semi-circle glLineWidth(3.0); glPushMatrix(); glColor3f(0,0,0); glBegin(GL_LINES); glVertex2f(-0.25f, 0.025f); glVertex2f(0.25f, 0.025f); glVertex2f(-0.25f, -0.025f); glVertex2f(0.25f, -0.025f); glEnd(); glPopMatrix(); // we draw two semicircles that are almost touching glPushMatrix(); glColor3f(0, 1, 0); glTranslatef(0, 0.025f, 0); GLUquadricObj * qobj = gluNewQuadric(); gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); gluPartialDisk(qobj, 0, 0.2, 1000, 1, 270, 180); gluDeleteQuadric(qobj); glPopMatrix(); glPushMatrix(); glColor3f(0, 1, 0); glTranslatef(0, -0.025f, 0); glRotatef(180, 0, 0, 1); GLUquadricObj * qobj2 = gluNewQuadric(); gluQuadricDrawStyle(qobj2, GLU_SILHOUETTE); gluPartialDisk(qobj2, 0, 0.2, 1000, 1, 270, 180); gluDeleteQuadric(qobj2); glPopMatrix(); } // if we haven't created our display list, do it now if (!isDlist) { displayList = glGenLists(1); glNewList(displayList,GL_COMPILE); // finally draw our outlines // top outline glPushMatrix(); glColor3f(0.3f, 0.3f, 0.3f); glTranslatef(0, 1.0, 0); glLineWidth(3.0); glBegin(GL_LINES); glVertex2f(-0.05f, 0.0); glVertex2f(-0.2f, 0.4f); glVertex2f(0.05f, 0.0); glVertex2f(0.2f, 0.4f); glEnd(); glPopMatrix(); // circle outlines // now draw the lines to blend out the semi-circle glLineWidth(3.0); glPushMatrix(); glColor3f(0,0,0); glBegin(GL_LINES); glVertex2f(-0.25f, 0.025f); glVertex2f(0.25f, 0.025f); glVertex2f(-0.25f, -0.025f); glVertex2f(0.25f, -0.025f); glEnd(); glPopMatrix(); // we draw two semicircles that are almost touching glPushMatrix(); glColor3f(0.3f, 0.3f, 0.3f); glTranslatef(0, 0.025f, 0); GLUquadricObj * qobj3 = gluNewQuadric(); gluQuadricDrawStyle(qobj3, GLU_SILHOUETTE); gluPartialDisk(qobj3, 0, 0.2, 1000, 1, 270, 180); gluDeleteQuadric(qobj3); glPopMatrix(); glPushMatrix(); glColor3f(0.3f, 0.3f, 0.3f); glTranslatef(0, -0.025f, 0); glRotatef(180, 0, 0, 1); GLUquadricObj * qobj4 = gluNewQuadric(); gluQuadricDrawStyle(qobj4, GLU_SILHOUETTE); gluPartialDisk(qobj4, 0, 0.2, 1000, 1, 270, 180); gluDeleteQuadric(qobj4); glPopMatrix(); // draw the bottom outline glPushMatrix(); glColor3f(0.3f, 0.3f, 0.3f); glLineWidth(3.0); glTranslatef(0, -1.0, 0); glBegin(GL_LINES); glVertex2f(-0.05f, 0.0); glVertex2f(-0.2f, -0.4f); glVertex2f(0.05f, 0.0); glVertex2f(0.2f, -0.4f); glEnd(); glPopMatrix(); // end our display list glEndList(); // set our flag isDlist = true; } // if we already have the display list, then call it else if (displayList > 0) glCallList(displayList); glColor4fv(currentColor); glLineWidth(lw); }
void ssr::QOpenGLPlotter::_draw_source(source_buffer_list_t::const_iterator& source, unsigned int index) { float scale = 1.0f; bool selected = false; bool soloed = false; if (_selected_sources_map.find(index) != _selected_sources_map.end()) { selected = true; } if (_soloed_sources.find(source->id) != _soloed_sources.end()) { soloed = true; } // check if source is selected if (selected) scale = 2.0f; // dummy id to prevend mouse action glLoadName(DUMMYINDEX); // draw shadow texture glEnable(GL_TEXTURE_2D); //glEnable(GL_ALPHA_TEST); glEnable(GL_BLEND); glBindTexture(GL_TEXTURE_2D, _source_shadow_texture); glPushMatrix(); glTranslatef(0.015f, -0.015f, 0.01f); gluQuadricTexture(_glu_quadric, GL_TRUE ); gluDisk(_glu_quadric, 0.0f, 0.163f * scale,LEVELOFDETAIL,1); glPopMatrix(); glDisable(GL_TEXTURE_2D); //glDisable(GL_ALPHA_TEST); glDisable(GL_BLEND); // make sure that source is drawn on top //if (selected) glTranslatef(0.0f, 0.0f, 0.2f); //else glTranslatef(0.0f, 0.0f, 0.1f); // TODO: make it more elegant // source id glLoadName(NAMESTACKOFFSET + index * NAMESTACKSTEP + 1); // draw source glColor3f(1.0f, 1.0f, 1.0f); // white gluDisk(_glu_quadric, 0.0f, 0.15f * scale, LEVELOFDETAIL, 1); // fill source qglColor(_color_vector[source->id%_color_vector.size()]); gluPartialDisk(_glu_quadric, 0.0f, 0.125f * scale, LEVELOFDETAIL, 1, 0.0f, 360.0f); // draw solo indication if (soloed) { gluPartialDisk(_glu_quadric, 0.2f * scale, 0.22f * scale, LEVELOFDETAIL, 1, 55.0f, 70.0f); gluPartialDisk(_glu_quadric, 0.2f * scale, 0.22f * scale, LEVELOFDETAIL, 1, 235.0f, 70.0f); } // choose color if (source->mute) glColor3f(0.5f, 0.5f, 0.5f); else qglColor(_color_vector[source->id%_color_vector.size()]); // draw ring around source gluDisk(_glu_quadric, 0.14f * scale, 0.15f * scale, LEVELOFDETAIL, 1); // volume slider id; It is accessible only when source selected if (selected) glLoadName(NAMESTACKOFFSET + index * NAMESTACKSTEP + 2); // plot level meter frame in black glBegin(GL_TRIANGLE_FAN); glVertex3f( -0.1f * scale, -0.2f * scale, 0.0f); glVertex3f( -0.1f * scale, -0.25f * scale, 0.0f); glVertex3f( 0.1f * scale, -0.25f * scale, 0.0f); glVertex3f( 0.1f * scale, -0.2f * scale, 0.0f); glEnd(); if (selected) { // plot volume slider glBegin(GL_TRIANGLES); glVertex3f((-0.09f * scale + (20.0f*log10(source->gain)+50.0f)/62.0f * 0.18f * scale ) - 0.015f * scale, -0.29f * scale, 0.0f); glVertex3f((-0.09f * scale + (20.0f*log10(source->gain)+50.0f)/62.0f * 0.18f * scale ) + 0.015f * scale, -0.29f * scale, 0.0f); glVertex3f((-0.09f * scale + (20.0f*log10(source->gain)+50.0f)/62.0f * 0.18f * scale ), -0.26f * scale, 0.0f); glEnd(); } if (source->fixed_position) { // draw cross glBegin(GL_TRIANGLES); glVertex3f( -0.02f * scale, 0.005f * scale, 0.0f); glVertex3f( -0.02f * scale, -0.005f * scale, 0.0f); glVertex3f( 0.02f * scale, 0.005f * scale, 0.0f); glVertex3f( 0.02f * scale, 0.005f * scale, 0.0f); glVertex3f( -0.02f * scale, -0.005f * scale, 0.0f); glVertex3f( 0.02f * scale, -0.005f * scale, 0.0f); glVertex3f( -0.005f * scale, -0.02f * scale, 0.0f); glVertex3f( 0.005f * scale, -0.02f * scale, 0.0f); glVertex3f( 0.005f * scale, 0.02f * scale, 0.0f); glVertex3f( 0.005f * scale, 0.02f * scale, 0.0f); glVertex3f( -0.005f * scale, 0.02f * scale, 0.0f); glVertex3f( -0.005f * scale, -0.02f * scale, 0.0f); glEnd(); } // plot level meter background white glColor3f(1.0f, 1.0f, 1.0f); glBegin(GL_TRIANGLE_FAN); glVertex3f( -0.09f * scale, -0.21f * scale, 0.0f); glVertex3f( -0.09f * scale, -0.24f * scale, 0.0f); glVertex3f( 0.09f * scale, -0.24f * scale, 0.0f); glVertex3f( 0.09f * scale, -0.21f * scale, 0.0f); glEnd(); // plot audio level in green glColor3f(0.2275f, 0.9373f, 0.2275f); // signal_level in dB float signal_level = 20.0f * log10(source->signal_level + 0.00001f); // min -100 dB // only values up to 0 dB can be shown signal_level = std::min(signal_level, 0.0f); // TODO: color glBegin(GL_TRIANGLE_FAN); glVertex3f( -0.09f * scale, -0.21f * scale, 0.0f); glVertex3f( -0.09f * scale, -0.24f * scale, 0.0f); glVertex3f( -0.09f * scale + (signal_level + 50.0f)/50.0f * 0.18f * scale, -0.24f * scale, 0.0f); glVertex3f( -0.09f * scale + (signal_level + 50.0f)/50.0f * 0.18f * scale, -0.21f * scale, 0.0f); glEnd(); // display source name if (_allow_displaying_text) { qglColor(_color_vector[source->id%_color_vector.size()]); QFont f = font(); f.setPointSize(static_cast<int>(_zoom_factor/STDZOOMFACTOR*font().pointSize() + 0.5f)); renderText(0.18f * scale, 0.13f * scale, 0.0f, source->name.c_str(), f); } // dummy id to prevend mouse action glLoadName(DUMMYINDEX); // plot orientation of plane wave if (source->model == Source::plane) { // rotate glRotatef(static_cast<GLfloat>(source->orientation.azimuth), 0.0f, 0.0f, 1.0f); if (source->mute) glColor3f(0.5f, 0.5f, 0.5f); else qglColor(_color_vector[source->id%_color_vector.size()]); // plot ring segments gluPartialDisk(_glu_quadric, 0.18f * scale, 0.19f * scale, LEVELOFDETAIL, 1, 105.0f, 75.0f); gluPartialDisk(_glu_quadric, 0.18f * scale, 0.19f * scale, LEVELOFDETAIL, 1, 0.0f, 90.0f); // plot bars glBegin(GL_TRIANGLE_FAN); glVertex3f(-0.005f * scale, -0.36f * scale, 0.0f); glVertex3f( 0.005f * scale, -0.36f * scale, 0.0f); glVertex3f( 0.005f * scale, -0.18f * scale, 0.0f); glVertex3f(-0.005f * scale, -0.18f * scale, 0.0f); glEnd(); glBegin(GL_TRIANGLE_FAN); glVertex3f( 0.005f * scale, 0.36f * scale, 0.0f); glVertex3f(-0.005f * scale, 0.36f * scale, 0.0f); glVertex3f(-0.005f * scale, 0.18f * scale, 0.0f); glVertex3f( 0.005f * scale, 0.18f * scale, 0.0f); glEnd(); // plot arrow glBegin(GL_TRIANGLE_FAN); // lower branch glVertex3f( 0.277f * scale, 0.0f, 0.0f); glVertex3f( 0.25f * scale, -0.028f * scale, 0.0f); glVertex3f( 0.25f * scale, -0.04f * scale, 0.0f); glVertex3f( 0.29f * scale, 0.0f, 0.0f); glEnd(); glBegin(GL_TRIANGLE_FAN); // upper branch glVertex3f( 0.29f * scale, 0.0f, 0.0f); glVertex3f( 0.25f * scale, 0.04f * scale, 0.0f); glVertex3f( 0.25f * scale, 0.028f * scale, 0.0f); glVertex3f( 0.277f * scale, 0.0f, 0.0f); glEnd(); glBegin(GL_TRIANGLE_FAN); // root glVertex3f( 0.18f * scale, 0.005f * scale, 0.0f); glVertex3f( 0.18f * scale, -0.005f * scale, 0.0f); glVertex3f( 0.285f * scale, -0.005f * scale, 0.0f); glVertex3f( 0.285f * scale, 0.005f * scale, 0.0f); glEnd(); } else if (source->model == Source::directional) { // rotate glRotatef((GLfloat)(source->orientation.azimuth), 0.0f, 0.0f, 1.0f); qglColor(_color_vector[source->id%_color_vector.size()]); // plot ring gluPartialDisk(_glu_quadric, 0.18f * scale, 0.19f * scale, LEVELOFDETAIL, 1, 105.0f, 346.0f); // id of direction handle glLoadName(NAMESTACKOFFSET + index * NAMESTACKSTEP + 3); // plot arrow glBegin(GL_TRIANGLE_FAN); // lower branch glVertex3f( 0.277f * scale, 0.0f, 0.0f); glVertex3f( 0.25f * scale, -0.028f * scale, 0.0f); glVertex3f( 0.25f * scale, -0.04f * scale, 0.0f); glVertex3f( 0.29f * scale, 0.0f, 0.0f); glEnd(); glBegin(GL_TRIANGLE_FAN); // upper branch glVertex3f( 0.29f * scale, 0.0f, 0.0f); glVertex3f( 0.25f * scale, 0.04f * scale, 0.0f); glVertex3f( 0.25f * scale, 0.028f * scale, 0.0f); glVertex3f( 0.277f * scale, 0.0f, 0.0f); glEnd(); glBegin(GL_TRIANGLE_FAN); // root glVertex3f( 0.18f * scale, 0.005f * scale, 0.0f); glVertex3f( 0.18f * scale, -0.005f * scale, 0.0f); glVertex3f( 0.285f * scale, -0.005f * scale, 0.0f); glVertex3f( 0.285f * scale, 0.005f * scale, 0.0f); glEnd(); } }
/* The main drawing function. */ void DrawGLScene(void) { glMatrixMode(GL_MODELVIEW); // clear all the buffers - gives OpenGL full control // OpenSG doesn't clear the background because of the PassiveBackground object glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // set the model transformation glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // set camera position from mouse movement glTranslatef(0.0f, 0.0f, -m_distance); glRotatef(m_tiltAngle, 1.0f, 0.0f, 0.0f); glRotatef(m_twistAngle, 0.0f, 0.0f, 1.0f); //glTranslatef(0.0f, 0.0f, -90.0f); glPushMatrix(); // OpenSG will overwrite OSG::Real32 proj_matrix[16], model_matrix[16]; glGetFloatv(GL_PROJECTION_MATRIX, proj_matrix); glGetFloatv(GL_MODELVIEW_MATRIX, model_matrix); // retrieve OpenGL's matrices OSG::Matrix proj, model; proj.setValue(proj_matrix); model.setValue(model_matrix); newcam->setProjectionMatrix(proj); // transform the world just like the OpenGL content // necessary since OpenSG's modelview transforms start from the unity matrix. newcam->setModelviewMatrix(model); // setup an initial transformation OSG::Matrix m1; OSG::Quaternion q1; // mind that the VRML base coordinate system has different meanings for X, Y, Z, hence the rotation for 90 degrees. // this, together with the MatrixCamera code above hooks OpenSG to OpenGL ! m1.setIdentity(); q1.setValueAsAxisDeg(1, 0, 0., 90); // rotation m1.setRotate(q1); trans->setMatrix(m1); OSG::commitChanges(); // redraw the OpenSG window content - the calls are a bit after one's own taste pwin->render(mgr->getRenderAction()); //pwin->frameInit(); //pwin->frameExit(); //mgr->redraw(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); //################ START FOR OPENGL STUFF // light attributes const GLfloat light_ambient[] = { 0.3f, 0.3f, 0.3f, 1.0f }; const GLfloat light_diffuse[] = { 0.52f, 0.5f, 0.5f, 1.0f }; const GLfloat light_specular[] = { 0.1f, 0.1f, 0.1f, 1.0f }; // setup the light attributes glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); // set the light position GLfloat lightPosition[] = { 0.0f, -10.0f, 10.0f, 0.0f }; glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); glEnable(GL_NORMALIZE); glDisable(GL_NORMALIZE); //glDisable(GL_BLEND); glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture[0]); // choose the texture to use. GLfloat TableDiffuse[] = { 0.3f, 0.0f, 1.0f, 0.5f }; GLfloat TableSpecular[] = { 0.6f, 0.0f, 0.8f, 0.5f }; glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, TableDiffuse); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, TableSpecular); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0.4f); glEnable(GL_BLEND); gluPartialDisk(quadric,0,12.0f,32,16, 0, 360); // A Disk Like The One Before #if 1 glDisable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); // X axis on table glColor3f(1,0,0); glBegin(GL_LINES); glVertex3f(0,0,0.1f); glVertex3f(120,0,0.1f); glEnd(); // Y axis on table glColor3f(0,1,0); glBegin(GL_LINES); glVertex3f(0,0,0.1f); glVertex3f(0,120,0.1f); glEnd(); glEnable(GL_LIGHTING); #endif glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); glDisable(GL_LIGHTING); // render the cursor renderCursor(); // swap the front- and back-buffer glutSwapBuffers(); }