Example #1
0
void  twarz() {
  glLineWidth(5);

    // obrys buzki:
  glColor3d(CZARN);
  glBegin(GL_LINE_LOOP);
    odcinek_okregu(8, 0, 2*M_PI);
  glEnd();

    // wypelnienie buzki:
  glColor3d(SZARY);
  glBegin(GL_POLYGON);
    odcinek_okregu(8, 0, 2*M_PI);
  glEnd();

    // lewe oko:
  glPushMatrix(); glTranslated(-3, 0, 0);
  glColor4d(NIEBI,0);
  glBegin(GL_LINE_STRIP);
    odcinek_okregu(1.414*2, M_PI/4, 3*M_PI/4);
  glEnd();
  glPopMatrix();
  glPushMatrix(); glTranslated(-3, 4, 0);
  glColor4d(NIEBI,0);
  glBegin(GL_LINE_STRIP);
    odcinek_okregu(1.414*2, 5*M_PI/4, 7*M_PI/4);
  glEnd();
  glPopMatrix();

    // prawe oko:
  glPushMatrix(); glTranslated(3, 0, 0);
  glColor4d(NIEBI,0);
  glBegin(GL_LINE_STRIP);
    odcinek_okregu(1.414*2, M_PI/4, 3*M_PI/4);
  glEnd();
  glPopMatrix();
  glPushMatrix(); glTranslated(3, 4, 0);
  glColor4d(NIEBI,0);
  glBegin(GL_LINE_STRIP);
    odcinek_okregu(1.414*2, 5*M_PI/4, 7*M_PI/4);
  glEnd();
  glPopMatrix();

    // usta:
  glColor3d(CZERW);
  glBegin(GL_POLYGON);
    odcinek_okregu(1.414*4, 5*M_PI/4, 7*M_PI/4);
  glEnd();

    // nos:
  glColor3d(ZIELO);
  glPushMatrix(); glTranslated(0,-1, 1.5);
    glutSolidSphere(2, 20, 16);
  glPopMatrix();
}
Example #2
0
int WoodBall::Draw(){
	pdColor c;
	if(mystate==0){
		return 0;
	}else if(mystate==1){
		c=myfscol;
//		DrawBall(mypos,myfscol,r);
	}else if(mystate==-1){
		c=mysccol;
//		DrawBall(mypos,mysccol,r);
	}else{
		assert(false);
	}

	glPushMatrix();

//	glEnable(GL_TEXTURE_2D);
//	glBindTexture( GL_TEXTURE_2D, myTex->texture );

	if(atr==0){
		glColor4d(c.r,c.g,c.b,c.a);
		GLfloat material[] = {(float)c.r,(float)c.g,(float)c.b,(float)c.a};
		glMaterialfv(GL_FRONT_AND_BACK , GL_AMBIENT_AND_DIFFUSE , material); 
	}else{
		colphase+=0.03;
		glColor4d(c.r,c.g,c.b,0.6+0.4*sin(colphase));
		GLfloat material[] = {(float)c.r,(float)c.g,(float)c.b,(float)(0.6+0.4*sin(colphase))};
		glMaterialfv(GL_FRONT_AND_BACK , GL_AMBIENT_AND_DIFFUSE , material); 
	}


	glTranslated(mypos.x,mypos.y,mypos.z);

//	glEnable(GL_TEXTURE_GEN_S);
//	glEnable(GL_TEXTURE_GEN_T);

	if(IniManager::ReadInt("Graphic","WireFrame",0)==1){
		if(mystate==-1){
			glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
			glutSolidSphere(r,10,10);
			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		}else if(mystate==1){
			glutSolidSphere(r,10,10);
		}
	}else{
		glutSolidSphere(r,50,50);
	}
//	glDisable(GL_TEXTURE_GEN_S);
//	glDisable(GL_TEXTURE_GEN_T);

//	glDisable(GL_TEXTURE_2D);
	glPopMatrix();

	return 0;
}
Example #3
0
void CVX_Sim::DrawGeometry(int Selected, bool ViewSection, int SectionLayer)
{
	bool DrawInputVoxel = false;
	Vec3D<> Center;
	Vec3D<> tmp(0,0,0);

	int iT = NumVox();
	int x, y, z;
	CColor ThisColor;
	for (int i = 0; i<iT; i++) //go through all the voxels...
	{
		pEnv->pObj->GetXYZNom(&x, &y, &z, StoXIndexMap[i]);
		if (ViewSection && z>SectionLayer) continue; //exit if obscured in a section view!


		Center = VoxArray[i].GetCurPos();

		ThisColor = GetCurVoxColor(i, Selected);
		glColor4d(ThisColor.r, ThisColor.g, ThisColor.b, ThisColor.a);
		

		glPushMatrix();
		glTranslated(Center.x, Center.y, Center.z);

		glLoadName (StoXIndexMap[i]); //to enable picking

		//generate rotation matrix here!!! (from quaternion)
		Vec3D<> Axis;
		vfloat AngleAmt;
		CQuat<>(VoxArray[i].GetCurAngle()).AngleAxis(AngleAmt, Axis);
		glRotated(AngleAmt*180/3.1415926, Axis.x, Axis.y, Axis.z);
	
		Vec3D<> Scale = VoxArray[i].GetCurScale(); //show deformed voxel size
		glScaled(Scale.x, Scale.y, Scale.z);

		//LocalVXC.Voxel.DrawVoxel(&tmp, LocalVXC.Lattice.Lattice_Dim*(1+0.5*CurTemp * pMaterials[CVoxelArray[i].MatIndex].CTE), LocalVXC.Lattice.Z_Dim_Adj);
		LocalVXC.Voxel.DrawVoxel(&tmp, 1); //LocalVXC.GetLatticeDim()); //[i].CurSize.x); //, LocalVXC.Lattice.Z_Dim_Adj);
		
		glPopMatrix();
	}

	if (DrawInputVoxel){
		Vec3D<> tmp(0,0,0);
		Center = VoxArray[NumVox()].GetCurPos();
		glColor4d(1.0, 0.2, 0.2, 1.0);
		glPushMatrix();
		glTranslated(Center.x, Center.y, Center.z);	
		Vec3D<> Scale = LocalVXC.GetLatDimEnv();
		glScaled(Scale.x, Scale.y, Scale.z);

		LocalVXC.Voxel.DrawVoxel(&tmp, 1); //LocalVXC.GetLatticeDim()); //[i].CurSize.x); //, LocalVXC.Lattice.Z_Dim_Adj);
		
		glPopMatrix();
	}
}
Example #4
0
void Viewer::paintGL()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Setup 2D
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadIdentity();

    // Zoom
    glScaled(0.75,0.75,0.75);

    auto drawPolygon = [&](std::vector<Mesh::Vertex> & vertices, double alpha, QColor c)
    {
        alpha = std::max(0.1, alpha);

        // Lines
        glColor4d(0.4,0.4,0.4,alpha * 0.5);
        glLineWidth(2);
        glBegin(GL_LINE_STRIP);
        for(auto & v : vertices) glVertex3dv(v.data());
        glVertex3dv(vertices.front().data());
        glEnd();

        // Points
        glColor4d(c.redF(),c.greenF(),c.blueF(),alpha);
        glPointSize(4);
        glBegin(GL_POINTS);
        for(auto & v : vertices) glVertex3dv(v.data());
        glEnd();

        // Feature points
        glColor4d(0,0,1,1);
        glPointSize(6);
        glBegin(GL_POINTS);
        glVertex3dv(vertices[0].data());
        glVertex3dv(vertices[vertices.size() * 0.75].data());
        glVertex3dv(vertices[vertices.size() * 0.5].data());
        glVertex3dv(vertices[vertices.size() * 0.25].data());
        glEnd();
    };

    drawPolygon(flow->mesh->flow_vertices[0], 1.0, Qt::yellow);

    for(int i = 0; i < flow->mesh->flow_vertices.size()-1; i++)
    {
        double alpha = double(i) / (flow->mesh->flow_vertices.size()-1);
        drawPolygon(flow->mesh->flow_vertices[i], alpha, QColor(128,0,128));
    }

    drawPolygon(flow->mesh->vertices, 1.0, Qt::red);
}
Example #5
0
void hoa_meter_paint(t_hoa_meter *x, double w, double h)
{
	glEnable(GL_DEPTH_TEST);
	glShadeModel(GL_SMOOTH);
    glLoadIdentity();
    glRotated(180., 0., 1., 0.);
    glRotated(-x->f_camera[0] / CICM_2PI * 360., 0., 1., 0.);
    glRotated(x->f_camera[1] / CICM_2PI * 360., 1., 0., 0.);
	glPointSize(1.0f);
    
    int led_index;
    
    glBegin(GL_TRIANGLE_FAN);
    for(int i = 0; i < 100; i++)
    {
        for(int j = 0; j < 199; j++)
        {
            led_index = (1. + Hoa3D::clip_minmax(x->f_meter->getSphereEnergy(i, j), -90., 0.) / 90.) * (x->f_number_of_leds - 1);
            if(led_index < 3)
                glColor4d(x->f_color_cold.red, x->f_color_cold.green, x->f_color_cold.blue, x->f_color_cold.alpha);
            else if(led_index < 6)
                glColor4d(x->f_color_tepid.red, x->f_color_tepid.green, x->f_color_tepid.blue, x->f_color_tepid.alpha);
            else if(led_index < 9)
                glColor4d(x->f_color_warm.red, x->f_color_warm.green, x->f_color_warm.blue, x->f_color_warm.alpha);
            else if(led_index < 12)
                glColor4d(x->f_color_hot.red, x->f_color_hot.green, x->f_color_hot.blue, x->f_color_hot.alpha);
            else
                glColor4d(x->f_color_over.red, x->f_color_over.green, x->f_color_over.blue, x->f_color_over.alpha);
            glVertex3d(x->f_leds_coordinates[i][j][led_index][0], x->f_leds_coordinates[i][j][led_index][1], x->f_leds_coordinates[i][j][led_index][2]);
        }
    }
    glEnd();
    
    glBegin(GL_TRIANGLE_FAN);
    for(int j = 0; j < 199; j++)
    {
        for(int i = 0; i < 100; i++)
        {
            led_index = (1. + Hoa3D::clip_minmax(x->f_meter->getSphereEnergy(i, j), -90., 0.) / 90.) * (x->f_number_of_leds - 1);
            if(led_index < 3)
                glColor4d(x->f_color_cold.red, x->f_color_cold.green, x->f_color_cold.blue, x->f_color_cold.alpha);
            else if(led_index < 6)
                glColor4d(x->f_color_tepid.red, x->f_color_tepid.green, x->f_color_tepid.blue, x->f_color_tepid.alpha);
            else if(led_index < 9)
                glColor4d(x->f_color_warm.red, x->f_color_warm.green, x->f_color_warm.blue, x->f_color_warm.alpha);
            else if(led_index < 12)
                glColor4d(x->f_color_hot.red, x->f_color_hot.green, x->f_color_hot.blue, x->f_color_hot.alpha);
            else
                glColor4d(x->f_color_over.red, x->f_color_over.green, x->f_color_over.blue, x->f_color_over.alpha);
            glVertex3d(x->f_leds_coordinates[i][j][led_index][0], x->f_leds_coordinates[i][j][led_index][1], x->f_leds_coordinates[i][j][led_index][2]);
        }
    }
    glEnd();
}
Example #6
0
 void teleop_gui_t::render_xform_arrows(Eigen::Isometry3d xform, double alpha)
 {
     glPushMatrix();
     glMultMatrixd(xform.data());
     Eigen::Vector3d base = Eigen::Vector3d::Zero();
     glColor4d(1,0,0,alpha);
     yui::drawArrow3D(base, Eigen::Vector3d::UnitX(), 0.2, 0.01, 0.02);
     glColor4d(0,1,0,alpha);
     yui::drawArrow3D(base, Eigen::Vector3d::UnitY(), 0.2, 0.01, 0.02);
     glColor4d(0,0,1,alpha);
     yui::drawArrow3D(base, Eigen::Vector3d::UnitZ(), 0.2, 0.01, 0.02);
     glPopMatrix();
 }
Example #7
0
void GLViewer::paintGL()
{
    Eigen::Vector4d eye=cameraparameters.transform*Eigen::Vector4d(0,0,0,1);
    Eigen::Vector4d center=cameraparameters.transform*Eigen::Vector4d(0,0,-1,1);
    Eigen::Vector4d up=cameraparameters.transform*Eigen::Vector4d(0,1,0,0);
    makeCurrent();
    cameraparameters.eye[0]=eye(0);
    cameraparameters.eye[1]=eye(1);
    cameraparameters.eye[2]=eye(2);
    cameraparameters.eye[3]=eye(3);
    glLightfv(GL_LIGHT0, GL_POSITION,cameraparameters.eye);
    glLightfv(GL_LIGHT0, GL_AMBIENT, cameraparameters.lightambient);
    glLightfv(GL_LIGHT0, GL_DIFFUSE,cameraparameters.lightambient);
    glLightfv(GL_LIGHT0, GL_SPECULAR,cameraparameters.lightambient);
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, cameraparameters.lightambient);
	glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,GL_TRUE);
	glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glClearColor(cameraparameters.background(0),cameraparameters.background(1),cameraparameters.background(2),0.0);
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
    gluLookAt(eye(0),eye(1),eye(2),center(0),center(1),center(2),up(0),up(1),up(2));
	glPushMatrix();
    int i,n=displaylist.size();
    glPointSize(cameraparameters.pointsize);
    for(i=0;i<n;i++)
    {
        if(displaylist[i].show)
        {
			glPushMatrix();
			Eigen::Matrix4d matrix=displaylist[i].scale*displaylist[i].transform;
			glMultMatrixd(matrix.data());
            glCallList(displaylist[i].listid);
			glPopMatrix();
        }
    }
	glPopMatrix();
    glBegin(GL_LINES);
    glColor4d(1,0,0,1);
    glVertex3d(0,0,0);glVertex3d(1,0,0);
    glColor4d(0,1,0,1);
    glVertex3d(0,0,0);glVertex3d(0,1,0);
    glColor4d(0,0,1,1);
    glVertex3d(0,0,0);glVertex3d(0,0,1);
    glEnd();
    return;
}
Example #8
0
void Particle::Draw()
{
	// enable point
	glPushMatrix();
	glDepthMask( false );
	glEnable( GL_POINT_SMOOTH );
	glEnable( GL_BLEND );
	glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

	// set up size of point
	double maxSize = 0.0;
	glGetDoublev( GL_POINT_SIZE_MAX, &maxSize );
	glPointSize( mSize );
	glPointParameterf( GL_POINT_FADE_THRESHOLD_SIZE, 100.0 ); // ???
	glPointParameterf( GL_POINT_SIZE_MIN, 1.0 );
	glPointParameterf( GL_POINT_SIZE_MAX, maxSize );

	// size of points decreases
	//GLfloat constant[1] = {1.0};
	//GLfloat quadratic[3] = {1.0, 0.0, 0.1};
	//glPointParameterfv(GL_POINT_DISTANCE_ATTENUATION, constant);

	// draw particle
	glBegin( GL_POINTS );
	glColor4d( mColour.R(), mColour.G(), mColour.B(), 0.5 );
	glVertex3d( mPosition[0], mPosition[1], mPosition[2] );
	glEnd();

	// disable stuff
	glDisable( GL_POINT_SMOOTH );
	glDisable( GL_BLEND );
	glDepthMask( true );
	glPopMatrix();
}
Example #9
0
void Capgl::myDrawScene()
{
	glClearColor(0.0f,0.0f,0.0f,1.0f);//设置背景颜色为黑色 
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); 
	//glPushMatrix(); 
	glLoadIdentity();
	glTranslated(0.0f,0.0f,-2.0f);//把物体沿(0,0,-1)方向平移 
	//以便投影时可见。因为缺省的视点在(0,0,0),只有移开 
	//物体才能可见。  

	for(int i=0;i<m_plots.size();i++)
	{
		if(m_plots[i].m_type==PLOT_TYPE_LINE)glBegin(GL_LINE_STRIP); //画出连线段
		else glBegin(GL_POINTS);//画出点

		glColor4d(m_plots[i].m_r,m_plots[i].m_g,m_plots[i].m_b,m_plots[i].m_alf);
		for(int j=0;j<m_plots[i].m_points.size()/2;j++)
		{
			glVertex2d(m_plots[i].m_points[2*j],m_plots[i].m_points[2*j+1]);
		}
		glEnd();//结束画连线段
	}
 
	glFlush(); //结束 RC 绘图 
}
void CP_Mesh::Draw(Vec3D<>* Envelope)
{
	glPushMatrix();
//	glScalef(MaxVal,MaxVal, MaxVal);

	glColor4d(R, G, B, alpha);
	Vec3D<> Min = ThisMesh.GetBBMin();
	Vec3D<> Size = ThisMesh.GetBBSize();
	Vec3D<> v1(X, Y, Z);
	
	if (Envelope){
		Vec3D<> ScaleFacV = Vec3D<>(dX, dY, dZ).Scale(Envelope->ScaleInv(Size)); //= WS/Size
		vfloat MinScaleFac = ScaleFacV.Min();
		v1 = v1.Scale(*Envelope);

		glTranslated(v1.x, v1.y, v1.z);
		glScaled(MinScaleFac, MinScaleFac, MinScaleFac);
	}
	else {
		glTranslated(v1.x, v1.y, v1.z);
		glScaled(dX/Size.x, dY/Size.y, dZ/Size.z);
	}
	glTranslated(-Min.x, -Min.y, -Min.z);

	ThisMesh.Draw(false, true, true, true);

	glPopMatrix();
}
Example #11
0
File: Star.cpp Project: rohrmann/CG
void Star::draw(){
	glBegin(GL_POINT);
	Vector4<double> color = calcColor();
	glColor4d(color.getX(),color.getY(),color.getZ(),color.getA());
	glVertex2d(pos.getX(),pos.getY());
	glEnd();
}
Example #12
0
void drawHelicopter() {
	glPushMatrix();
			glEnable(GL_BLEND);
			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);	
			glColor4d(0.6, 0.6, 1.0, 0.5);
				m.drawCockpit();
			glDisable(GL_BLEND);


			glBindTexture(GL_TEXTURE_2D, _textureId[0]);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
			glColor4f(1.0f, 1.0f, 1.0f,0.6);
			m.drawHelicopter();


			glBindTexture(GL_TEXTURE_2D, _textureId[1]);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
			glColor4f(1.0f, 1.0f, 1.0f,0.6);

			m.drawLanding();

			glBindTexture(GL_TEXTURE_2D, _textureId[2]);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
			glColor4f(1.0f, 1.0f, 1.0f,0.6);

			m.drawHelis();
	glPopMatrix();
}
Example #13
0
void    MG_poseReader::drawText(const MString &text,const double* color, const MPoint &position,M3dView &view){

		glColor4d(color[0],color[1],color[2],1.0f);
		
		view.drawText( text, position, M3dView::kLeft );

}
Example #14
0
void MG_poseReader::drawSphere(const double r, const int lats, const int longs,const MVector position,const double* color)
 {
     int i, j;
        for(i = 0; i <= lats; i++) {
            double lat0 = M_PI * (-0.5 + (double) (i - 1) / lats);
           double z0  = sin(lat0);
           double zr0 =  cos(lat0);
    
           double lat1 = M_PI * (-0.5 + (double) i / lats);
           double z1 = sin(lat1);
           double zr1 = cos(lat1);
		   glColor4d(color[0],color[1],color[2],color[3]);
           glBegin(GL_QUAD_STRIP);
           for(j = 0; j <= longs; j++) {
               double lng = 2 * M_PI * (double) (j - 1) / longs;
               double x = cos(lng);
               double y = sin(lng);
    
			   glNormal3d((x * zr0*r)+position.x,( y * zr0*r)+position.y, (z0*r)+position.z);
               glVertex3d((x * zr0*r)+position.x, (y * zr0*r)+position.y, (z0*r)+position.z);
               glNormal3d((x * zr1*r)+position.x, (y * zr1*r)+position.y, (z1*r)+position.z);
               glVertex3d((x * zr1*r)+position.x, (y * zr1*r)+position.y, (z1*r)+position.z);
           }
           glEnd();
       }
   }
Example #15
0
void 
ShellContent::drawEntry()
{ 
    glPushMatrix();

    glLineWidth ( 1.2f );
    bufferFont->scale ( _fontScale, _fontAspect );

    glColor4dv( _fontColor.data() );
	glPushMatrix();
    bufferFont->draw_sub( _prompt ); // we lose kerning from one to the next, but otherwise this is pretty legal. 
    bufferFont->draw_sub( _entry.str() );
    glPopMatrix();


	double ll = bufferFont->length( _prompt + _entry.substr( 0 , _loc.chr ) );
	glColor4d( 0.0, 0.6, 0.1, 1.0 );
	glLineWidth( 2.0f );
	glBegin(GL_LINES);
	glVertex3d( ll , -0.25 * bufferFont->height() , 0 );
	glVertex3d( ll ,  1.25 * bufferFont->height() , 0 );
	glEnd();
	glPopMatrix();

}
Example #16
0
void viseur(Game * game){
	if(SDL_GetMouseState( NULL, NULL )&SDL_BUTTON(1)
		||SDL_GetMouseState( NULL, NULL )&SDL_BUTTON(3)
		||SDL_GetKeyState(NULL)[SDLK_LALT]
		||SDL_GetKeyState(NULL)[SDLK_LCTRL]){
		precision=1;
	}else{
		precision=0;
	}

	/////////////////////////////////////////////////////////////////////
	glPushMatrix();
		glColor4d(1,0,0,1);
		glPointSize(2.);

		glRotated(game->player->rho*(-2),1,0,0);
		glRotated(game->player->theta*(.5-precision*.8), 0.0, 1.0, 0.0);

		// glEnable(GL_POINT_SMOOTH);
		glPointSize(6.);

		glBegin(GL_POINTS);
			glVertex3d(.05,.003,0);
			glVertex3d(.05,-.003,0);	glVertex3d(.05,0,0);	glVertex3d(.05,0,.003);
			glVertex3d(.05,0,-.003);
		glEnd();
		// glDisable(GL_POINT_SMOOTH);

	glPopMatrix();
}
Example #17
0
void SimpleDraw::IdentifyPoints(const StdVector<Vec3d > & points, Vec4d c, float pointSize)
{
	glDisable(GL_LIGHTING);

	glEnable(GL_BLEND); 
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	// Colored dot
	glColor4dv(c);
	glPointSize(pointSize);
	glBegin(GL_POINTS);
	for(unsigned int i = 0; i < points.size(); i++)
		glVertex3dv(points[i]);
	glEnd();

	// White Border
	glPointSize(pointSize + 2);
	glColor4d(1, 1, 1, c[3]);

	glBegin(GL_POINTS);
	for(unsigned int i = 0; i < points.size(); i++)
		glVertex3dv(points[i]);
	glEnd();

	glEnable(GL_LIGHTING);
}
void ModelRenderInstance::Render(RenderOptions& renderOptions)
{
   m_spDisplayState->Tick();

   OpenGL::PushedAttributes attrib(GL_POLYGON_BIT | GL_ENABLE_BIT | GL_CURRENT_BIT);

   if (renderOptions.Get(RenderOptions::optionModelFilled))
      glPolygonMode(GL_FRONT, GL_FILL);
   else
      glPolygonMode(GL_FRONT, GL_LINE);

   glPushMatrix();

   // position model
   Vector3d vPos = CalculatedPos();
   glTranslated(vPos.X(), vPos.Y(), vPos.Z());

   glRotated(m_dViewAngle, 0.0, 1.0, 0.0);

   double dTransparency = CalcPlayerTransparency();

   // blend model
   if (dTransparency < 1.0)
   {
      glEnable(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   }

   double dLuminance = m_bSelected ? 1.2 : 1.0;
   glColor4d(dLuminance, dLuminance, dLuminance, dTransparency);

   m_spDisplayState->Render(renderOptions);

   glPopMatrix();
}
static DMDrawOption CheckTexDM(MTFace *tface, const bool has_mcol, int matnr)
{

	// index is the original face index, retrieve the polygon
	if (matnr == current_blmat_nr &&
		(tface == NULL || tface->tpage == current_image)) {
		// must handle color.
		if (current_wireframe)
			return DM_DRAW_OPTION_NO_MCOL;
		if (current_ms->m_bObjectColor) {
			MT_Vector4& rgba = current_ms->m_RGBAcolor;
			glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]);
			// don't use mcol
			return DM_DRAW_OPTION_NO_MCOL;
		}
		if (!has_mcol) {
			// we have to set the color from the material
			unsigned char rgba[4];
			current_polymat->GetMaterialRGBAColor(rgba);
			glColor4ubv((const GLubyte *)rgba);
			return DM_DRAW_OPTION_NO_MCOL;
		}
		return DM_DRAW_OPTION_NORMAL;
	}
	return DM_DRAW_OPTION_SKIP;
}
Example #20
0
void Edist::Draw()
{
	glColor4fv(&mesh.color.x);
	for(int ff=0;ff<2;ff++)
	{
		if(!ff)			glCullFace(GL_FRONT);		else 			glCullFace(GL_BACK);
		mesh.Draw2();

	}
		
	



	vec3 l1=center-axis0*4;
	vec3 l2=center+axis0*4;
	glDisable(GL_LIGHTING);
	glColor4d(0,0,0,1);
	glBegin(GL_LINES);
	glLineWidth(4);
	glVertex3fv(&l1.x);
	glVertex3fv(&l2.x);
	glEnd();
	glLineWidth(1);
	glEnable(GL_LIGHTING);
}
Example #21
0
void RaytracerApplication::render()
{
    int width, height;

    get_dimension( &width, &height );
    glViewport( 0, 0, width, height );

    Camera& camera = scene.camera;
    camera.aspect = real_t( width ) / real_t( height );

    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();

    if ( raytracing ) {
        assert( buffer );
        glColor4d( 1.0, 1.0, 1.0, 1.0 );
        glRasterPos2f( -1.0f, -1.0f );
        glDrawPixels( buf_width, buf_height, GL_RGBA, GL_UNSIGNED_BYTE, &buffer[0] );

    } else {
        glPushAttrib( GL_ALL_ATTRIB_BITS );
        render_scene( scene );
        glPopAttrib();
    }
}
void Player::DrawBomb()
{
	
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
	glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
	glColor4d(1.0,1.0,1.0,1.0);

	glBindTexture(GL_TEXTURE_2D,draw_bomb);
	glEnable(GL_TEXTURE_2D);


	glBegin(GL_QUADS);

	glTexCoord2d(0.0,0.0);
	glVertex2d(bomb_x-50,bomb_y-50);

	glTexCoord2d(1.0,0.0);
	glVertex2d(bomb_x+50,bomb_y-50);

	glTexCoord2d(1.0,1.0);
	glVertex2d(bomb_x+50,bomb_y+50);

	glTexCoord2d(0.0,1.0);
	glVertex2d(bomb_x-50,bomb_y+50);

	glEnd();
	glDisable(GL_BLEND);
}
Example #23
0
void Image::draw(int x, int y, int x1, int y1, int w, int h, Scalar ScaleX, Scalar ScaleY, Scalar Rot, Color c)
{
    glPushMatrix();

        glTranslated(x+(Scalar)w/2,y+(Scalar)h/2,0);
        //DrawStuff
        glRotated(Rot,0,0,-1);

        glBindTexture(GL_TEXTURE_2D, imageTag);
        glBegin(GL_QUADS);
            glColor4d(c.GetR(),c.GetG(),c.GetB(),c.GetA());
            //tex((Scalar)x1/width,(Scalar)y1/height);
            glTexCoord2d((Scalar)(x1+0.375f)/texSize,Scalar(y1+0.375f)/texSize);
            glVertex2d(-.5*w*ScaleX,-.5*h*ScaleY);
            //tex((Scalar)x1/width,(Scalar)(y1+h)/height);
            glTexCoord2d((Scalar)(x1+0.357f)/texSize,(Scalar)(y1+h-0.625f)/texSize);
            glVertex2d(-.5*w*ScaleX,.5*h*ScaleY);
            //tex((Scalar)(x1+w)/width,(Scalar)(y1+h)/height);
            glTexCoord2d(((Scalar)x1+w-0.625f)/texSize,(Scalar)(y1+h-0.625f)/texSize);
            glVertex2d(.5*w*ScaleX,.5*h*ScaleY);
            //tex((Scalar)(x1+w)/width,(Scalar)y1/height);
            glTexCoord2d(((Scalar)x1+w-0.625f)/texSize,(Scalar)(y1+0.375f)/texSize);
            glVertex2d(.5*w*ScaleX,-.5*h*ScaleY);
        glEnd();

    glPopMatrix();
}
static void DisplayNoDrawInit(void)
{
    printf("Setting tile.");
    icetResetTiles();
    icetAddTile(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0);

    icetGLDrawCallback(draw);

    icetSetColorFormat(ICET_IMAGE_COLOR_RGBA_UBYTE);
    icetSetDepthFormat(ICET_IMAGE_DEPTH_FLOAT);

    if (global_rank == 0) {
        icetBoundingBoxd(100.0, 101.0, 100.0, 101.0, 100.0, 101.0);
    } else {
        icetBoundingBoxd(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
    }

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glDisable(GL_LIGHTING);
    glColor4d(1.0, 1.0, 1.0, 1.0);
}
Example #25
0
// Draw a particular frame
void AnimatedImage::DrawFrame(int frame, int x, int y, double rotate, double scale,
                              double alpha, double white) const
{
   assert(frame >= 0 && frame < frameCount);

   int frameX = frame % FramesPerRow();
   int frameY = frame / FramesPerRow();
   
   int width = Image::GetWidth();
   int height = Image::GetHeight();

   glEnable(GL_TEXTURE_2D);
   glEnable(GL_BLEND);
   glBindTexture(GL_TEXTURE_2D, GetTexture()->GetGLTexture());
   glLoadIdentity();
   glTranslated((double)(x + frameWidth/2), (double)(y + frameHeight/2), 0.0);
   glScaled(scale, scale, 0);
   glRotated(rotate, 0.0, 0.0, 1.0);
   glColor4d(white, white, white, alpha);

   double tex_l = ((double)(frameX * frameWidth))/(double)width;
   double tex_r = tex_l + (double)frameWidth/(double)width;

   double tex_t = ((double)(frameY * frameHeight))/(double)height;
   double tex_b = tex_t + (double)frameHeight/(double)height;
   
   glBegin(GL_QUADS);
   glTexCoord2d(tex_l, tex_t); glVertex2i(-(frameWidth/2), -(frameHeight/2));
   glTexCoord2d(tex_l, tex_b); glVertex2i(-(frameWidth/2), frameHeight/2);
   glTexCoord2d(tex_r, tex_b); glVertex2i(frameWidth/2, frameHeight/2);
   glTexCoord2d(tex_r, tex_t); glVertex2i(frameWidth/2, -(frameHeight/2));
   glEnd();
}
Example #26
0
void bSyncVideoLayer::draw()
{
    int w = GetConfig.screen_w, h = GetConfig.screen_h;
    glPushMatrix();
        glColor4d( 0.1, 0.1, 0.2, 1.0 );
        bSystem::video_sys.set_matrix_2d();
        glBegin( GL_TRIANGLE_STRIP );
            glVertex2i( 0, 0 );
            glVertex2i( 0, 600 );
            glVertex2i( 800, 0 );
            glVertex2i( 800, 600 );
        glEnd();
        glColor4d( 1.0, 1.0, 1.0, 1.0 );
        PRINTB( 250, 300, B_FONT_LIGHT, "...SYNCHRONIZING FPS TIMER..." );
    glPopMatrix();
}
Example #27
0
void 
CMagic120Cell::render( const CVector3D & lookFrom, bool forPicking ) 
{
	__super::render( lookFrom, forPicking );

	// Draw hypercube cells?
	if( 1 == m_settings.m_symmetry && 
		m_settings.m_visibility[9] && !forPicking )
	{
		ambientOnly();
		CColor & c = m_settings.m_colors[9];
		glColor4d( c.m_r, c.m_g, c.m_b, c.m_a );
		draw4Cube( m_hypercubePoints );
	}

	/* Draw our axes.
	glPointSize( 5.0 );
	glBegin( GL_POINTS );
		glColor4d( 1,1,1,1 );
		vertex( CVector4D( 0,0,0,0 ) );
		glColor4d( 1,0,0,1 );
		vertex( CVector4D( 3,0,0,0 ) );
		glColor4d( 0,1,0,1 );
		vertex( CVector4D( 0,3,0,0 ) );
		glColor4d( 0,0,1,1 );
		vertex( CVector4D( 0,0,3,0 ) );
	glEnd();
	*/
}
Example #28
0
int DrawString(const char *str,Vec2d p,pdColor c){
	glPushMatrix();
	glLoadIdentity();
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glDisable(GL_LIGHTING);

	glLoadIdentity();
	gluOrtho2D(0,glutGet(GLUT_WINDOW_WIDTH), 0, glutGet(GLUT_WINDOW_HEIGHT));
	glPushAttrib(GL_CURRENT_BIT|GL_DEPTH_BUFFER_BIT);
	glDisable(GL_DEPTH_TEST);

	glColor4d(c.r,c.g,c.b,c.a);
	glRasterPos2d(glutGet(GLUT_WINDOW_WIDTH)/2+p.x,glutGet(GLUT_WINDOW_HEIGHT)/2-p.y); //�¶‰º‚ªŒ´“_
	while(*str){
		glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, *str);
//		glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, *str);
//		glutBitmapCharacter(GLUT_STROKE_ROMAN, *str);
//		glutBitmapCharacter(GLUT_BITMAP_9_BY_15, *str);
		str++;
	}

	glPopAttrib();			
	glEnable(GL_LIGHTING);
	glPopMatrix(); 
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	return 0;
};
Example #29
0
void EntPellet::draw() {
	TextureHandler* texh = TextureHandler::getInstance();

	glColor3d(1,1,1);
	if (texh->getTexture()) {
		texh->use("pellet");
	}

        GLfloat specular1[4] = { 1, 1, 1, 1 };
        GLfloat specular0[4] = { 0, 0, 0, 1 };
        const double PI = 3.141592654;

        glMaterialfv(GL_FRONT, GL_SPECULAR, specular1);

        GLUquadric* q = TextureHandler::getInstance()->getQuadric();
        gluSphere(q, 2, 8, 8);

        glMaterialfv(GL_FRONT, GL_SPECULAR, specular0);

        // shadow
        glPushMatrix();
        TextureHandler::getInstance()->use("none");
        glColor4d(0,0,0,0.5);
        glTranslated(0,0,-14);
        gluDisk(TextureHandler::getInstance()->getQuadric(), 0, 2, 16, 1);
        glPopMatrix();


}
  void MapPainterOpenGL::DrawPath(const Projection& /*projection*/,
                                  const MapParameter& /*parameter*/,
                                  const Color& color,
                                  double width,
                                  const std::vector<double>& /*dash*/,
                                  LineStyle::CapStyle /*startCap*/,
                                  LineStyle::CapStyle /*endCap*/,
                                  size_t transStart, size_t transEnd)
  {
    // TODO:
    // There is a limit in the OpenGL lineWidth, we need to
    // fallback to using quads instead of lines for this.

    glColor4d(color.GetR(),
              color.GetG(),
              color.GetB(),
              color.GetA());

    glLineWidth(width);

    glBegin(GL_LINE_STRIP);

    for (size_t i=transStart; i<=transEnd; i++) {
      glVertex3d(coordBuffer->buffer[i].GetX(),
                 coordBuffer->buffer[i].GetY(),
                 0.0);
    }

    glEnd();
  }