Example #1
0
// TODO: Make border radius true 1-point wide, even for low poly scenarios (by adjusting the inner radius intelligently, not just -1)
void DrawCircle(Vector2n Position, Vector2n Size, Color BackgroundColor, Color BorderColor)
{
	glDisable(GL_TEXTURE_2D);

	const auto TwoPi = std::atan(1) * 8;

	const uint32 x = 64;

	glBegin(GL_TRIANGLE_FAN);
		glColor3dv(BorderColor.GetComponents());
		glVertex2i(Position.X(), Position.Y());
		for (int i = 0; i <= x; ++i)
		{
			glVertex2d(Position.X() + std::sin(TwoPi * i / x) * Size.X() / 2, Position.Y() + std::cos(TwoPi * i / x) * Size.Y() / 2);
		}
	glEnd();

	glBegin(GL_TRIANGLE_FAN);
		glColor3dv(BackgroundColor.GetComponents());
		glVertex2i(Position.X(), Position.Y());
		for (int i = 0; i <= x; ++i)
		{
			glVertex2d(Position.X() + std::sin(TwoPi * i / x) * (Size.X() / 2 - 1), Position.Y() + std::cos(TwoPi * i / x) * (Size.Y() / 2 - 1));
		}
	glEnd();

	glEnable(GL_TEXTURE_2D);
}
Example #2
0
/// Malt das H"ohenfeld
void CGView::drawHeight() {

    glPushMatrix();
    glTranslated(-5.0, 0.0, -5.0);
    glScaled(10.0 / (sizeX - 1), 3.0, 10.0 / (sizeY - 1));
    glLineWidth(1);

    Vector3d c(1, 1, 1);

    if (!wire) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    else glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

    for (int i = 0; i < (sizeX - 1); i++) {
        glBegin(GL_TRIANGLE_STRIP);

        for (int j = 0; j < (sizeY); j++) {
            glColor3dv(c.ptr());
            glVertex3d(i, height_vector[i][j], j);
            glColor3dv(c.ptr());
            glVertex3d(i + 1, height_vector[i + 1][j], j);
        }

        glEnd();
    }

    glPopMatrix();
}
Example #3
0
void drawSquare( double Corner00Color[3]
					, double Corner01Color[3]
					, double Corner11Color[3]
					, double Corner10Color[3]
					, unsigned int texture
					, bool enableTextures) 
{
  ErrCheck("Before drawSquare");
	glPushMatrix(); 
	glBindTexture(GL_TEXTURE_2D,texture); 
	
	if(enableTextures)
   {
   	glEnable(GL_TEXTURE_2D);
   	glBindTexture(GL_TEXTURE_2D,texture); 
   }
   glBegin(GL_QUADS);
   glNormal3f(0,0,1); 
   glColor3dv(Corner00Color); 
	if(enableTextures)
   {
   	glTexCoord2f(0,0);
   }
   glVertex2f(0,0);
   
   glNormal3f(0,0,1); 
   glColor3dv(Corner01Color); 
	if(enableTextures)
   {
   	glTexCoord2f(0,1);
   }
   glVertex2f(0,1);
   
   glNormal3f(0,0,1); 
   glColor3dv(Corner11Color); 
	if(enableTextures)
   {
   	glTexCoord2f(1,1);
   }
   glVertex2f(1,1);
   
   glNormal3f(0,0,1); 
   glColor3dv(Corner10Color); 
	if(enableTextures)
   {
   	glTexCoord2f(1,0);
   }
   glVertex2f(1,0);

   glEnd();
   
   if(enableTextures)
	{
		glDisable(GL_TEXTURE_2D);
	}
	glPopMatrix(); 
	ErrCheck("After drawSquare");
}
Example #4
0
/**************************************************************************//**
* @author Caitlin Taggart
*
* @par Description:
* The Display function which is the callback for displaying the generated fractal
* window. 
*****************************************************************************/
void GenWindow::Display()
{
    //set the appropriate window and cleat the screen
	glutSetWindow(_windowID);
	glClear(GL_COLOR_BUFFER_BIT);

    //draw the object
    glBegin(GL_LINE_STRIP);
        glColor3dv(color);
        for (unsigned int i = 0; i < points.size(); i++)
        {
            glVertex2d(points[i].x, points[i].y);
        }
     glEnd(); 

     //draw the generated points 
     glBegin(GL_POINTS);
         for (unsigned int i = 0; i < genPoints.size(); i++)
         {
             ColorPoint pnt = genPoints[i]; 
             glColor3d(pnt.r, pnt.g, pnt.b);
             glVertex2d(pnt.x, pnt.y);
         }
     glEnd(); 

    //swap buffers 
	glutSwapBuffers();
}
Example #5
0
void display(){
    int i, j;

    // Zバッファの有効化
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glEnable(GL_DEPTH_TEST);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glPushMatrix();
    glTranslated(-0.5, -0.5, -5.0);
    glRotated(30.0, 1.0, 1.0, 0.0);

    glBegin(GL_QUADS);
    for (j = 0; j<6; j++){
        glColor3dv(col[j]);
        for (i = 0; i<4; i++){
            glVertex3dv(vertex[face[j][i]]);
        }
    }
    glEnd();

    glDisable(GL_DEPTH_TEST);
    glPopMatrix();
    glFlush();
}
Example #6
0
void MakePolygon()
{
    glClear(GL_COLOR_BUFFER_BIT);
    glClearColor(1.0,1.0,1.0,1.0);
    for(int i=0;i<=VertInd;i++)
        MakeDot(ToDraw->LocalSpaceList[i]);
    glColor3dv(ToDraw->Color);
    glBegin(GL_POLYGON);
        for(int i=0;i<=VertInd;i++)
            glVertex2dv(ToDraw->LocalSpaceList[i]);
    glEnd();
    glLineWidth(2.0);
    glColor3d(0.0,0.0,0.0);
    glBegin(GL_LINE_LOOP);
        for(int i=0;i<=VertInd;i++)
            glVertex2dv(ToDraw->LocalSpaceList[i]);
    glEnd();


    MakeDot(0,0);


    no2[0]=(ToDraw->NumVertices-VertInd)/10+'0';
    no2[1]=(ToDraw->NumVertices-VertInd)%10+'0';
    strcpy(hello3,"Vertices Left:   ");
    strcat(hello3,no2);
    text(hello3,-0.22,-0.15,1);
    text(instructions,-0.2,-0.05,0);


    glutSwapBuffers();

}
void CALLBACK vertexCallback(GLvoid *vertex)
{
	const GLdouble *pointer;
	pointer = (GLdouble *) vertex;
	glColor3dv(pointer+3);
	glVertex3dv(vertex);
}
Example #8
0
void PolygonRect::drawGL() {
  glColor3dv(material->getDif());
  glBegin(GL_LINE_LOOP);
    for (int i = 0; i < points.size(); ++i) {
      glVertex3d(points[i]->x, points[i]->y, -points[i]->z);  // OpenGL has the z-axis reversed
    }
  glEnd();
}
Example #9
0
void displaySentenceOnBand(char* str, double color[])
{
	glRasterPos2d(sqrSize*(sqrNum / 4 + frame * 0.7), sqrSize*(sqrNum + frame * 2)*1.5 / 3);
	for (; *str; str++) {
		glColor3dv(color);
		glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, *str);
	}
}
Example #10
0
void loop() {
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    glOrtho(0, WIDTH, HEIGHT, 0, -1, 1);

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

    physics_start();

    while (!glfwWindowShouldClose(window) && running) {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        if (pthread_mutex_trylock(&lock) == 0) {
            for (int i = 0; i < PARTICLES_MAX; i++) {
                struct particle *p = &array[i];
                if (!p->m) continue;
                
                glPointSize(particle_radius(p) * 2.0f);

                double x, y;
                double alpha = particle_getcoords(*p, &x, &y);

                glColor4d(p->color[0], p->color[1], p->color[2], alpha);
                
                glBegin(GL_POINTS);
                glVertex2d(x, y);
                glEnd();
            }
            pthread_mutex_unlock(&lock);
        }

        if (mouse.is_dragging) {
            double x, y;
            glfwGetCursorPos(window, &x, &y);

            glBegin(GL_LINES);
            glColor3dv(next_color);

            glVertex2d(mouse.xp, mouse.yp);
            glVertex2d(x, y);

            glEnd();
        }

        glfwSwapBuffers(window);
        glfwPollEvents();

        glfwSetWindowTitle(window, newtitle());
    }

    physics_stop();
}
Example #11
0
void
rect(pp::Color color, pp::Vec2d startPos, pp::Vec2d endPos)
{
	glDisable( GL_TEXTURE_2D );
    glColor3dv( (double*)&color );
    glRectf( startPos.x, startPos.y,
	     	 endPos.x,endPos.y );
	glEnable( GL_TEXTURE_2D );
}	
Example #12
0
void GraphicalNode::draw()
{
    glPushMatrix();
        glColor3dv(clr);
        glTranslated(pos[0],pos[1],pos[2]);
//        glRotated(0.0,0.0,0.0,0.0);
        glCallList(mListIndex);
    glPopMatrix();
}
void DisplayWidget::paintGL()
{
	timer.stop();
	dataMutex.lock();
	
	makeCurrent();
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	if(calibrationMode) gluLookAt(0,0,0,0,0,HANDLEDEPTH,0,-1,0); //Camera has opposite default orientation
	//else gluLookAt(center.X(),center.Y(),0,center.X(),center.Y(),HANDLEDEPTH,0,1,0); //Camera has opposite default orientation
	else gluLookAt(0,0,0,0,0,HANDLEDEPTH,0,1,0); //Camera has opposite default orientation
	
	//Unused area is unlit by default
	if(calibrationMode) glClearColor(deepBackgroundColor.X(), deepBackgroundColor.Y(), deepBackgroundColor.Z(),1);
	else glClearColor(backgroundColor.X(), backgroundColor.Y(), backgroundColor.Z(),1);
	glClear(GL_COLOR_BUFFER_BIT);
	
	glShadeModel(GL_FLAT);
	glEnable(GL_LINE_SMOOTH);
	glEnable(GL_POLYGON_SMOOTH);
	glEnable(GL_POINT_SMOOTH);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glDisable(GL_DEPTH_TEST);
		
	glPushMatrix();
	glTranslated(center.X(),center.Y()+.05,0);
	glScaled(min*(1.0/6.0),min*(1.0/6.0),1.0);
	glColor3d(.5,.5,.5); //Grey because...why not?
	for(int k=0;k<4;k++)
	{
		if(drawShapes[k])
		{
			glCallList(shapeList[k]);
		}
	}
	glPopMatrix();
	
	for(std::vector<Sphere>::iterator it=spheres.begin();it!=spheres.end();++it)
	{
		if(it->radius<=0) continue;
		glColor3dv(it->color);
		glPushMatrix();
		if(!calibrationMode) glTranslated(0,0,HANDLEDEPTH);
		glTranslated(it->position.X(),it->position.Y(),it->position.Z());
		glScaled(it->radius,it->radius,it->radius);
		glCallList(sphereList);
		glPopMatrix();
	}

	renderText(textLocation.X(),textLocation.Y(),textLocation.Z(),text);
	
	dataMutex.unlock();
	swapBuffers();
	glFinish();  //Get precise timing by recording time after this, blocks until swap succeeds.  Swap happens during refresh.
	timer.start(15, this); //60 Hz = 16.6 ms, guarantee a paint in each refresh and almost immediately before refresh to minimize lag.
}
Example #14
0
// マス目描画
void displayPiece(int x, int y, double color[])
{
	glColor3dv(color);
	glBegin(GL_QUADS);
	glVertex2d(sqrSize*(x + frame), sqrSize*(y + frame));
	glVertex2d(sqrSize*(x + frame + 0.95), sqrSize*(y + frame));
	glVertex2d(sqrSize*(x + frame + 0.95), sqrSize*(y + frame + 0.95));
	glVertex2d(sqrSize*(x + frame), sqrSize*(y + frame + 0.95));
	glEnd();
}
Example #15
0
// フラグマス描画
void displayFlagPiece(int x, int y)
{
	// 旗の描画
	glColor3dv(colors[Red]);
	glBegin(GL_TRIANGLES);
	glVertex2d(sqrSize*(x + frame) + sqrSize*1.5 / 5.0, sqrSize*(y + frame) + sqrSize*1.0 / 5.0);
	glVertex2d(sqrSize*(x + frame) + sqrSize*1.5 / 5.0, sqrSize*(y + frame) + sqrSize*2.6 / 5.0);
	glVertex2d(sqrSize*(x + frame) + sqrSize*4.0 / 5.0, sqrSize*(y + frame) + sqrSize*1.8 / 5.0);
	glEnd();
	
	// 棒の描画
	glColor3dv(colors[Gray]);
	glBegin(GL_QUADS);
	glVertex2d(sqrSize*(x + frame) + sqrSize*1.5 / 5.0, sqrSize*(y + frame) + sqrSize*1.0 / 5.0);
	glVertex2d(sqrSize*(x + frame) + sqrSize*1.5 / 5.0, sqrSize*(y + frame) + sqrSize*4.0 / 5.0);
	glVertex2d(sqrSize*(x + frame) + sqrSize*1.0 / 5.0, sqrSize*(y + frame) + sqrSize*4.0 / 5.0);
	glVertex2d(sqrSize*(x + frame) + sqrSize*1.0 / 5.0, sqrSize*(y + frame) + sqrSize*1.0 / 5.0);
	glEnd();
}
Example #16
0
void CALLBACK CMFCTessView::vertexCallback(GLvoid *vertex)
{
	GLdouble *pointer;

	pointer = (GLdouble *) vertex;
	glColor3dv(pointer+3);
	glVertex3dv(pointer);

	TRACE( "vertexCallback: (%f,%f,%f)\n",pointer[0],pointer[1],pointer[2] ) ;
}
Example #17
0
void displayGrayBand()
{
	glColor3dv(colors[Gray]);
	glBegin(GL_QUADS);
	glVertex2d(0, sqrSize*(sqrNum+frame*2)/3);
	glVertex2d(0, sqrSize*(sqrNum+frame*2)*2/3);
	glVertex2d(sqrSize*(sqrNum + frame * 2), sqrSize*(sqrNum + frame * 2) * 2 / 3);
	glVertex2d(sqrSize*(sqrNum + frame * 2), sqrSize*(sqrNum + frame * 2) / 3);
	glEnd();
}
Example #18
0
// 押されたマス目の描画
void displayPushedPiece(int x, int y, int num)
{
	// マス目の色をGrayにする
	displayPiece(x, y, colors[Gray]);

	// 数字描画
	glColor3dv(colors[num]);
	glRasterPos2d(sqrSize*(x + frame)+sqrSize*1.5 / 5.0, sqrSize*(y + frame)+sqrSize*4.0 / 5.0);
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, numbers[num]);
}
Example #19
0
File: main.c Project: walsvid/Lab
void cube()
{
    glColor3dv(colors[0]);
//    set_materials(&brassMaterials);
//    glNormal3fv(cubeNomals[0]);
    polygon(0, 3, 2, 1);
    glColor3dv(colors[1]);
//    set_materials(&redPlasticMaterials);
//    glNormal3fv(cubeNomals[1]);
    polygon(2, 3, 7, 6);
    glColor3dv(colors[2]);
//    set_materials(&greenPlasticMaterials);
//    glNormal3fv(cubeNomals[2]);
    polygon(3, 0, 4, 7);
    glColor3dv(colors[3]);
//    set_materials(&bluePlasticMaterials);
//    glNormal3fv(cubeNomals[3]);
    polygon(1, 2, 6, 5);
    glColor3dv(colors[4]);
//    set_materials(&whiteShinyMaterials);
//    glNormal3fv(cubeNomals[4]);
    polygon(4, 5, 6, 7);
    glColor3dv(colors[5]);
//    set_materials(&magentaMaterials);
//    glNormal3fv(cubeNomals[5]);
    polygon(5, 4, 0, 1);
}
Example #20
0
File: g_render.c Project: aosm/X11
void __glXDisp_Color3dv(GLbyte *pc)
{

#ifdef __GLX_ALIGN64
	if ((unsigned long)(pc) & 7) {
	    __GLX_MEM_COPY(pc-4, pc, 24);
	    pc -= 4;
	}
#endif
	glColor3dv( 
		(GLdouble *)(pc + 0)
	);
}
Example #21
0
// Calculations
void PolygonView::draw(const Point2& pos, real rot, int) const
{
  glPushMatrix();
    gltTranslate(pos);
    glRotated(rot, 0.0, 0.0, 1.0);

    const Polygon2& poly = collisionPolygon();
    glColor3dv(iColor);	
    glBegin(iStyle);  
      gltVertex(poly.begin(), poly.end());  
    glEnd();
  glPopMatrix(); 
}
Example #22
0
void DrawAroundBox(Vector2n Position, Vector2n Size, Color BackgroundColor, Color BorderColor)
{
	glDisable(GL_TEXTURE_2D);

	glBegin(GL_QUADS);
		glColor3dv(BorderColor.GetComponents());
		glVertex2i(-1 + Position.X(), -1 + Position.Y());
		glVertex2i(-1 + Position.X(), +1 + Position.Y() + Size.Y());
		glVertex2i(+1 + Position.X() + Size.X(), +1 + Position.Y() + Size.Y());
		glVertex2i(+1 + Position.X() + Size.X(), -1 + Position.Y());
	glEnd();

	glBegin(GL_QUADS);
		glColor3dv(BackgroundColor.GetComponents());
		glVertex2i(Position.X(), Position.Y());
		glVertex2i(Position.X(), Position.Y() + Size.Y());
		glVertex2i(Position.X() + Size.X(), Position.Y() + Size.Y());
		glVertex2i(Position.X() + Size.X(), Position.Y());
	glEnd();

	glEnable(GL_TEXTURE_2D);
}
Example #23
0
/**
 * Zeichnet einen Vertex (glVertex) mit Texturkoordinaten und gegebenfalls Farbinformationen aber ohne Normale.
 */
void SGLVektor::DrawVertex()
{
/*
	Setzt wenn gegeben Texturkoordinaten für alle Texturrenderer vom der aktiven bis zu  GL_TEXTURE0_ARB herunter.
	(Aber immer nur die Selben)
 */
	std::stringstream buff;
	bool texOK=false;
#ifndef WIN32
	if(SGLTextur::TexLoaded)
	{
		short coord=texKoord.size();
		if(coord<SGLTextur::TexLoaded)
		{
			buff << *this;
			SGLprintWarning("Die geladene Textur hat %d Dimensionen, die Texturkoordinaten des Vertex \"%s\" sind aber nur %d-Dimensional",SGLTextur::TexLoaded,buff.str().c_str(),coord);
		}
		int i=GL_TEXTURE0_ARB+SGLTextur::multitex_layer ;//@todo dirty Hack
		switch(SGLTextur::TexLoaded > coord ? coord:SGLTextur::TexLoaded )
		{
		case 1:
			for(;i>=GL_TEXTURE0_ARB;i--)
				glMultiTexCoord1f(i,texKoord[0]);
			break;
		case 2:
			for(;i>=GL_TEXTURE0_ARB;i--)
				glMultiTexCoord2f(i,texKoord[0], texKoord[1]);
			break;
		case 3:
			for(;i>=GL_TEXTURE0_ARB;i--)
				glMultiTexCoord3f(i,texKoord[0], texKoord[1],texKoord[2]);
			break;
		default:{
			buff << *this;
			SGLprintError("Texturtyp (%d) passt nicht zu den verfügbaren Texturkoordinaten beim Zeichnen des Vertex \"%s\"",SGLTextur::TexLoaded, coord,buff.str().c_str());}break;
		}
		texOK=true;//@todo naja nich immer
	}
#else
// "Texture loading is currently not supportet for Windows"
#endif
	if(!SGLMaterial::MatLoaded && !texOK)
	{
		if(SGLV_R>=0 || SGLV_G>=0 || SGLV_B>=0)glColor3dv(Color);
		else{
			buff << *this;
			SGLprintWarning("Keine Farbinformationen verfgbar beim Zeichnen des Vertex \"%s\"",buff.str().c_str());
		}
	}
	DrawPureVertex();
}
Example #24
0
void DrawInnerBox(Vector2n Position, Vector2n Size, Color BackgroundColor, Color BorderColor)
{
	if (   0 == Size.X()
		|| 0 == Size.Y())
	{
		return;
	}

	glDisable(GL_TEXTURE_2D);

	const auto OuterDistance = 1.5;
	glBegin(GL_POLYGON);
		glColor3dv(BorderColor.GetComponents());
		glVertex2d(Position.X() + OuterDistance, Position.Y());
		glVertex2d(Position.X(), Position.Y() + OuterDistance);
		glVertex2d(Position.X(), Position.Y() - OuterDistance + Size.Y());
		glVertex2d(Position.X() + OuterDistance, Position.Y() + Size.Y());
		glVertex2d(Position.X() - OuterDistance + Size.X(), Position.Y() + Size.Y());
		glVertex2d(Position.X() + Size.X(), Position.Y() - OuterDistance + Size.Y());
		glVertex2d(Position.X() + Size.X(), Position.Y() + OuterDistance);
		glVertex2d(Position.X() - OuterDistance + Size.X(), Position.Y());
	glEnd();

	const auto InnerDistance = sqrt(2.0) + 0.5;
	glBegin(GL_POLYGON);
		glColor3dv(BackgroundColor.GetComponents());
		glVertex2d(Position.X() + InnerDistance, Position.Y() + 1);
		glVertex2d(Position.X() + 1, Position.Y() + InnerDistance);
		glVertex2d(Position.X() + 1, Position.Y() - InnerDistance + Size.Y());
		glVertex2d(Position.X() + InnerDistance, Position.Y() - 1 + Size.Y());
		glVertex2d(Position.X() - InnerDistance + Size.X(), Position.Y() - 1 + Size.Y());
		glVertex2d(Position.X() - 1 + Size.X(), Position.Y() - InnerDistance + Size.Y());
		glVertex2d(Position.X() - 1 + Size.X(), Position.Y() + InnerDistance);
		glVertex2d(Position.X() - InnerDistance + Size.X(), Position.Y() + 1);
	glEnd();

	glEnable(GL_TEXTURE_2D);
}
Example #25
0
	void Particle::draw()
	{
		cg::Vector3d min = _position - _size/100.0;
		cg::Vector3d max = _position + _size/100.0;
		glColor3dv(_color.get());
		//glLineWidth(1.5);
		glBegin(GL_POLYGON);
			glVertex3d(min[0], min[1], -400);
			glVertex3d(max[0], min[1], -400);
			glVertex3d(max[0], max[1], -400);
			glVertex3d(min[0], max[1], -400);
		//	glVertex3d(min[0], max[1]*2, 10);
		glEnd();
	}
Example #26
0
void DrawBoxBorderless(Vector2n Position, Vector2n Size, Color Color)
{
	glDisable(GL_TEXTURE_2D);

	glBegin(GL_QUADS);
		glColor3dv(Color.GetComponents());
		glVertex2i(Position.X(), Position.Y());
		glVertex2i(Position.X(), Position.Y() + Size.Y());
		glVertex2i(Position.X() + Size.X(), Position.Y() + Size.Y());
		glVertex2i(Position.X() + Size.X(), Position.Y());
	glEnd();

	glEnable(GL_TEXTURE_2D);
}
	void operator()(DM::System *s, const DM::View& v, DM::Component* cmp, DM::Vector3* point, DM::Vector3* color, iterator_pos pos) 
	{
		if (pos == in_between)
		{
			double current_tex = 0;
			if (attr_span != 0)
			{
				const ViewMetaData &vmd = l.getViewMetaData();
				Attribute *a = cmp->getAttribute(l.getAttribute());
				if (a)
				{
					if (a->getType() == Attribute::DOUBLEVECTOR || a->getType() == Attribute::TIMESERIES)
						current_tex = (a->getDoubleVector()[l.getAttributeVectorName()] - vmd.attr_min) / attr_span;
					else
						current_tex = (a->getDouble() - vmd.attr_min) / attr_span;
				}
			}
			else
				current_tex = 0.0;

			current_tex *= 255;

			if (color)
				glColor3dv(&color->x);
			else if (current_tex <= 0)
				glColor3f(0, 0, 0);
			else
			{
				float r = l.LayerColor[(int)current_tex][0] / 255.;
				float g = l.LayerColor[(int)current_tex][1] / 255.;
				float b = l.LayerColor[(int)current_tex][2] / 255.;
				//float a = l.LayerColor[(int)current_tex][3]/255.;
				glColor3f(r, g, b);
			}

			glVertex3dv(&point->x);
		}
		else if (pos == before) 
		{
			glPushName(name_start);
			glBegin(SD_GL_PRIMITIVE);
		} 
		else if (pos == after) 
		{
			glEnd();
			glPopName();
			name_start++;
		}
	}
Example #28
0
/**
 * Zeichnet ein dreidimensionales Kreuz an den Positionskoordinaten des Vektors.
 * @param size die Große des Kreuzes.
 */
void SGLVektor::DrawPkt(double size)
{
	glBegin(GL_LINES);
		if(SGLV_R>=0 || SGLV_G>=0 || SGLV_B>=0)
			glColor3dv(Color);
		glVertex3d(SGLV_X-size/2,SGLV_Y,SGLV_Z);
		glVertex3d(SGLV_X+size/2,SGLV_Y,SGLV_Z);

		glVertex3d(SGLV_X,SGLV_Y-size/2,SGLV_Z);
		glVertex3d(SGLV_X,SGLV_Y+size/2,SGLV_Z);

		glVertex3d(SGLV_X,SGLV_Y,SGLV_Z-size/2);
		glVertex3d(SGLV_X,SGLV_Y,SGLV_Z+size/2);
	glEnd();
}
Example #29
0
void GeomRenderer::sendColor(GLuint colorIndex)
{
    assert(colorData.size == 3 || colorData.size == 4);

    switch(colorData.type)
    {
        case GL_BYTE:
            if (colorData.size == 3) glColor3bv((const GLbyte*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            if (colorData.size == 4) glColor4bv((const GLbyte*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            break;

        case GL_UNSIGNED_BYTE:
            if (colorData.size == 3) glColor3ubv((const GLubyte*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            if (colorData.size == 4) glColor4ubv((const GLubyte*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            break;

        case GL_SHORT:
            if (colorData.size == 3) glColor3sv((const GLshort*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            if (colorData.size == 4) glColor4sv((const GLshort*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            break;

        case GL_UNSIGNED_SHORT:
            if (colorData.size == 3) glColor3usv((const GLushort*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            if (colorData.size == 4) glColor4usv((const GLushort*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            break;

        case GL_INT:
            if (colorData.size == 3) glColor3iv((const GLint*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            if (colorData.size == 4) glColor4iv((const GLint*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            break;

        case GL_UNSIGNED_INT:
            if (colorData.size == 3) glColor3uiv((const GLuint*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            if (colorData.size == 4) glColor4uiv((const GLuint*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            break;

        case GL_FLOAT:
            if (colorData.size == 3) glColor3fv((const GLfloat*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            if (colorData.size == 4) glColor4fv((const GLfloat*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            break;

        case GL_DOUBLE:
            if (colorData.size == 3) glColor3dv((const GLdouble*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            if (colorData.size == 4) glColor4dv((const GLdouble*)((const char*)colorData.pointer + colorIndex*colorData.stride));
            break;
    }
}
void RenderController::render_string(int x, int y, std::string curr_string, std::vector< GLdouble >* color) {
	glPushMatrix();
		glMatrixMode(GL_PROJECTION);
		glPushMatrix();
			glLoadIdentity();
			glOrtho(0, this->curr_rend_ctrl->width, 0, this->curr_rend_ctrl->height, -1.0, 1.0);
			glMatrixMode(GL_MODELVIEW);
			glPushMatrix();
				glLoadIdentity();
				glColor3dv(color->data());
				glRasterPos2i(x, this->curr_rend_ctrl->height - y);
				glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_24, (const unsigned char*)curr_string.data());
				glMatrixMode(GL_PROJECTION);
			glPopMatrix();
			glMatrixMode(GL_MODELVIEW);
		glPopMatrix();
	glPopMatrix();
}