void CDirBrowserElement::_drawTexturedIcon(int tPosX,int tPosY,int sizeX,int sizeY)
{
	ogl::setBlending(true,GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); // We turn blending on!
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);

	glTexEnvf (GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
	glEnable(GL_TEXTURE_2D);
	glDisable(GL_LIGHTING);
	glBegin(GL_QUADS);
	glTexCoord2f(0.0f,0.0f);
	glVertex3i(tPosX-sizeX/2,tPosY-sizeY/2,0);
	glTexCoord2f(0.625f,0.0f); // icons themselves are 20x16, but since some gfx cards don't support that non-power of 2 res, we save them as 32x16!
	glVertex3i(tPosX+sizeX/2,tPosY-sizeY/2,0);
	glTexCoord2f(0.625f,1.0f); // icons themselves are 20x16, but since some gfx cards don't support that non-power of 2 res, we save them as 32x16!
	glVertex3i(tPosX+sizeX/2,tPosY+sizeY/2,0);
	glTexCoord2f(0.0f,1.0f);
	glVertex3i(tPosX-sizeX/2,tPosY+sizeY/2,0);
	glEnd();
	glDisable(GL_TEXTURE_2D);
	glEnable(GL_LIGHTING);
	ogl::setBlending(false);
	glDisable(GL_ALPHA_TEST);
	App::ct->globalTextureCont->endTextureDisplay();
}
Exemple #2
0
void KinematicMovementDemo::display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    gluLookAt(-53.0f, 53.0f, 0.0f,
              0.0f, -30.0f, 0.0f,
              0.0f, 1.0f, 0.0f);

    // Draw the characters.
    glColor3f(0.6f, 0.0f, 0.0f);
    renderAgent(location[0]);
    glColor3f(0.0f, 0.6f, 0.0f);
    renderAgent(location[1]);

    // Draw some scale lines
    glColor3f(0.8, 0.8, 0.8);
    glBegin(GL_LINES);
    for (int i = -WORLD_SIZE; i <= WORLD_SIZE; i += GRID_SIZE) {

        glVertex3i(-WORLD_SIZE, -1, i);
        glVertex3i(WORLD_SIZE, -1, i);

        glVertex3i(i, -1, WORLD_SIZE);
        glVertex3i(i, -1, -WORLD_SIZE);
    }
    glEnd();

    // Draw the help (the method decides if it should be displayed)
    displayHelp();
}
Exemple #3
0
  void refresh(bool smooth, unsigned inwidth, unsigned inheight, unsigned outwidth, unsigned outheight) {
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, smooth ? GL_LINEAR : GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, smooth ? GL_LINEAR : GL_NEAREST);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, outwidth, 0, outheight, -1.0, 1.0);
    glViewport(0, 0, outwidth, outheight);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glPixelStorei(GL_UNPACK_ROW_LENGTH, iwidth);
    glTexSubImage2D(GL_TEXTURE_2D,
      /* mip-map level = */ 0, /* x = */ 0, /* y = */ 0,
      inwidth, inheight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, buffer);

    //OpenGL projection sets 0,0 as *bottom-left* of screen.
    //therefore, below vertices flip image to support top-left source.
    //texture range = x1:0.0, y1:0.0, x2:1.0, y2:1.0
    //vertex range = x1:0, y1:0, x2:width, y2:height
    double w = double(inwidth)  / double(iwidth);
    double h = double(inheight) / double(iheight);
    int u = outwidth;
    int v = outheight;
    glBegin(GL_TRIANGLE_STRIP);
    glTexCoord2f(0, 0); glVertex3i(0, v, 0);
    glTexCoord2f(w, 0); glVertex3i(u, v, 0);
    glTexCoord2f(0, h); glVertex3i(0, 0, 0);
    glTexCoord2f(w, h); glVertex3i(u, 0, 0);
    glEnd();

    glFlush();
  }
bool ScreenAreaGl::on_expose_event(GdkEventExpose * _pstEvent)
{
  if (!m_bEnableRender)
    return true;

  Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
  if (!glwindow->gl_begin(get_gl_context()))
    return false;

    glClear( GL_COLOR_BUFFER_BIT );
    glPixelStorei(GL_UNPACK_ROW_LENGTH, m_iScaledWidth + 1);
    glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_iScaledWidth + 1, m_iScaledHeight,
                      GL_RGBA, GL_UNSIGNED_BYTE, m_puiPixels);

    glBegin(GL_TRIANGLE_STRIP);
      glTexCoord2f(0.0f, 0.0f);
      glVertex3i(0, 0, 0);
      glTexCoord2f(m_iScaledWidth / (GLfloat) m_iTextureSize, 0.0f);
      glVertex3i(1, 0, 0);
      glTexCoord2f(0.0f, m_iScaledHeight / (GLfloat) m_iTextureSize);
      glVertex3i(0, 1, 0);
      glTexCoord2f(m_iScaledWidth / (GLfloat) m_iTextureSize,
                  m_iScaledHeight / (GLfloat) m_iTextureSize);
      glVertex3i(1, 1, 0);
    glEnd();

    glwindow->swap_buffers();

  glwindow->gl_end();

  return true;
}
//=========================================================//
//=========================================================//
GLvoid DrawGround()
{
	// enable blending for anti-aliased lines
	glEnable(GL_BLEND);

	// set the color to a bright blue
	glColor3f(0.5f, 0.7f, 1.0f);

	// draw the lines
	glBegin(GL_LINES);
	for (int x = -WORLD_SIZE; x < WORLD_SIZE; x += 6)
	{
		glVertex3i(x, 0, -WORLD_SIZE);
		glVertex3i(x, 0, WORLD_SIZE);
	}
	// set the color to a bright red
	glColor3f(1.0f, 0.7f, 0.5f);

	for (int z = -WORLD_SIZE; z < WORLD_SIZE; z += 6)
	{
		glVertex3i(-WORLD_SIZE, 0, z);
		glVertex3i(WORLD_SIZE, 0, z);
	}
	glEnd();

	// turn blending off
	glDisable(GL_BLEND);
} // end DrawGround()
void drawXZGrid(int size, float yPos)
{
	glPushMatrix();
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glTranslatef(0.0f, yPos, 0.0f);

	glLineWidth(3.0f);
	glColor4f(1.0f, 1.0f, 1.0f, 0.8f);

	glBegin( GL_LINES );
	for(int x = -(size/2); x < (size/2); x++)
	{
		glVertex3i(x, 0, -(size/2));
		glVertex3i(x, 0, (size/2));
	}

	for(int z = -(size/2); z < (size/2); z++)
	{
		glVertex3i(-(size/2), 0, z);
		glVertex3i((size/2), 0, z);
	}
	glEnd();

	glDisable(GL_BLEND);
	glPopMatrix();
}
void Decypher::ProgressDraw ( Button *button, bool highlighted, bool clicked )
{

	UplinkAssert ( button );

	float scale = (float) button->width / 100.0f;
	if ( highlighted ) scale *= 2;

	glBegin ( GL_QUADS );

		glColor4f ( 0.0f, 1.5f - scale, scale, 0.6f );
		glVertex3i ( button->x, button->y, 0 );

		glColor4f ( 0.0f, 1.5f - scale, scale, 0.6f );
		glVertex3i ( button->x + button->width, button->y, 0 );

		glColor4f ( 0.0f, 1.5f - scale, scale, 0.6f );
		glVertex3i ( button->x + button->width, button->y + button->height, 0 );

		glColor4f ( 0.0f, 1.5f - scale, scale, 0.6f );
		glVertex3i ( button->x, button->y + button->height, 0 );

	glEnd ();

	int xpos = button->x + 5;
	int ypos = (button->y + button->height / 2) + 3;
		
	glColor4f ( 1.0f, 1.0f, 1.0f, 1.0f );    
    GciDrawText ( xpos, ypos, button->caption, HELVETICA_10 );

}
static int test03(int size, int num)
{
    int x, y, z;

    glBegin(GL_TRIANGLES);
#if 0
    if (errChk)
	printError("glBegin(GL_TRIANGLES)");
#endif
    if (verbose)
	crDebug("glBegin( GL_TRIANGLES )");
    for (y = 0; y < num; y++)
	for (x = 0; x < size; x += 5) {
	    z = num * size - (y * size + x);
	    glColor3f(0.0, 1.0, 0.0);
	    glVertex3i(0, x, z);

	    glColor3f(1.0, 0.0, x / (float) size);
	    glVertex3i(size - 1 - x, 0, z);

	    glColor3f(1.0, x / (float) size, 0.0);
	    glVertex3i(x, size - 1 - x, z);
	}
    glEnd();

    return size * num / 5;
}
void DrawLimb(XnUserID player, XnSkeletonJoint eJoint1, XnSkeletonJoint eJoint2)
{
	if (!g_UserGenerator.GetSkeletonCap().IsCalibrated(player))
	{
		printf("not calibrated!\n");
		return;
	}
	if (!g_UserGenerator.GetSkeletonCap().IsTracking(player))
	{
		printf("not tracked!\n");
		return;
	}

	XnSkeletonJointPosition joint1, joint2;
	g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(player, eJoint1, joint1);
	g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(player, eJoint2, joint2);

	if (joint1.fConfidence < 0.75 || joint2.fConfidence < 0.75)
	{
		return;
	}

	XnPoint3D pt[2];
	pt[0] = joint1.position;bool isCalibrated = false;
	pt[1] = joint2.position;

	g_DepthGenerator.ConvertRealWorldToProjective(2, pt, pt);
	glVertex3i(pt[0].X, pt[0].Y, 0);
	glVertex3i(pt[1].X, pt[1].Y, 0);
//	printf("Points: %f, %f, %f \n");
}
Exemple #10
0
void PlayerPawn::ShadowVolume(float *lightdir)
{
	//draw shadow volume
	int slices = 12;
	double angle = (2.0*M_PI)/slices;
	double radius = 200;
	
	glTranslated(self.pos.x,self.pos.y,self.pos.z);
	glBegin(GL_QUAD_STRIP);
		for(double k = 0.0;k<(slices+1)*angle;k+=angle)
		{
			glVertex3i((int)(sin(k)*radius),-90,(int)(cos(k)*radius));
			glVertex3i((int)(sin(k)*radius+lightdir[0]*10000),(int)(lightdir[1]*10000),(int)(cos(k)*radius+lightdir[2]*10000));
		}
	glEnd();

	glBegin(GL_POLYGON);
		for(double k = 0.0;k<(slices+1)*angle;k+=angle)
		{
			glVertex3i((int)(sin(k)*radius),-90,(int)(cos(k)*radius));
		}
	glEnd();
	glTranslated(-self.pos.x,-self.pos.y,-self.pos.z);

}
void PhGraphicTexturedRect::draw()
{
    PhGraphicRect::draw();

    glBindTexture(GL_TEXTURE_2D, _currentTexture);

    glEnable(GL_TEXTURE_2D);

    //        (0,0) ------ (1,0)
    //          |            |
    //          |            |
    //        (0,1) ------ (1,1)

    glBegin(GL_QUADS);  //Begining the cube's drawing
    {
        glTexCoord3f(0, 0, 1);
        glVertex3i(this->x(),      this->y(), this->z());
        glTexCoord3f(_tu, 0, 1);
        glVertex3i(this->x() + this->width(), this->y(), this->z());
        glTexCoord3f(_tu, _tv, 1);
        glVertex3i(this->x() + this->width(), this->y() + this->height(),  this->z());
        glTexCoord3f(0, _tv, 1);
        glVertex3i(this->x(),      this->y() + this->height(),  this->z());
    }
    glEnd();


    glDisable(GL_TEXTURE_2D);
}
enum piglit_result
piglit_display(void)
{
	static const float red[3] = {1, 0, 0},
		green[3] = {0, 1, 0},
		blue[3] = {0, 0, 1},
		yellow[3] = {1, 1, 0},
		cyan[3] = {0, 1, 1};

	bool pass = true;

	glClear(GL_COLOR_BUFFER_BIT);
	glProvokingVertexEXT(GL_LAST_VERTEX_CONVENTION_EXT);

	const int y1 = piglit_height / 3;

	glBegin(GL_TRIANGLE_STRIP);
		glColor3fv(cyan);
		glVertex3i(piglit_width + 1, y1, 0);
		glColor3fv(yellow);
		glVertex3i(piglit_width + 2, y1, 0);
		glColor3fv(blue);
		glVertex3i(piglit_width + 3, y1, 0);
		glColor3fv(green);
		glVertex3i(piglit_width / 2, y1 * 2, 0);
		glColor3fv(red);
		glVertex3i(piglit_width - 1, y1 * 2, 0);
	glEnd();

	pass = pass && piglit_probe_pixel_rgb(piglit_width - 2, y1 * 3 / 2, red);

	piglit_present_results();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
/** Draw recangular volume projection
 *
 **/
void TileLoadBalancer::drawVolumes(Window *win)
{
    glPushMatrix();
    glLoadIdentity();
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    glViewport(0,0,win->getWidth(),win->getHeight());
    gluOrtho2D(0,win->getWidth(),
               0,win->getHeight());
    glDisable(GL_DEPTH_TEST);
    glEnable(GL_COLOR_MATERIAL);
    for(TileGeometryLoadLstT::iterator l=_tileGeometryLoad.begin() ; l!=_tileGeometryLoad.end() ; ++l)
    {
        if(l->isVisible())
        {
            glBegin(GL_LINE_LOOP);
            glColor3f(0, 1, 0);
            glVertex3i(l->getMin()[0],l->getMin()[1],0);
            glVertex3i(l->getMax()[0],l->getMin()[1],0);
            glVertex3i(l->getMax()[0],l->getMax()[1],0);
            glVertex3i(l->getMin()[0],l->getMax()[1],0);
            glEnd();
        }
    }
    glDisable(GL_COLOR_MATERIAL);
    glEnable(GL_DEPTH_TEST);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();
}
void Checkerboard::Render(RenderOptions& /*options*/)
{
   glDisable(GL_TEXTURE_2D);

   glColor3f(1.0f, 1.0f, 1.0f);

   // render checkerboard
   glBegin(GL_QUADS);

   for(int x=m_xMin; x<m_xMax; x++)
   for(int y=m_yMin; y<m_yMax; y++)
   {
      if ((x + y) & 1)
         glColor3f(1.0f, 1.0f, 1.0f);
      else
         glColor3f(0.2f, 0.2f, 0.2f);
      glVertex3i(x,   int(m_fHeight), y);
      glVertex3i(x,   int(m_fHeight), y+1);
      glVertex3i(x+1, int(m_fHeight), y+1);
      glVertex3i(x+1, int(m_fHeight), y);
   }
   glEnd();

   OpenGL::CountPolygons((m_xMax-m_xMin)*(m_yMax-m_yMin)*2);
}
Exemple #15
0
void draw3Dscene()
{
	float yellow[] = {1,1,0,1};
	float white[] = {1,1,1,1};
	glMaterialfv (GL_FRONT, GL_DIFFUSE, yellow);
	glMaterialfv (GL_FRONT, GL_SPECULAR, white);
	glMateriali (GL_FRONT, GL_SHININESS, 40);
	float lpos[4] = {lightpos[0][0], lightpos[0][1], lightpos[0][2], 1.0};
	glLightfv (GL_LIGHT0, GL_POSITION, lpos);    // point light

	glEnable (GL_NORMALIZE);
	glPushMatrix ();
		glScalef (2., 1., 1.);
		glutSolidSphere (1.0, 20,20);
	glPopMatrix();

	float grey[] = {.2,.2,.2};
	float purple[] = {.5,0,.5};
	float green[] = {0,.7,0};
	glMaterialfv (GL_FRONT, GL_AMBIENT, grey); 
	glMaterialfv (GL_FRONT, GL_DIFFUSE, purple);
	glMaterialfv (GL_FRONT, GL_SPECULAR, green);
	glMateriali (GL_FRONT, GL_SHININESS, 10);

	glBegin (GL_QUADS);
		glNormal3f(0,1,0);
		glVertex3i (-4,-2,4);
		glVertex3i (4,-2,4);
		glVertex3i (4,-2,-4);
		glVertex3i (-4,-2,-4);
	glEnd();
}
Exemple #16
0
void Renderer::drawMirrorOverlay(){
	glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
	glColor4f(GetRValue(cfgPanelBg)/255.0f, GetGValue(cfgPanelBg)/255.0f, GetBValue(cfgPanelBg)/255.0f, 0.60f);
	
	glShadeModel(GL_FLAT);
	glDisable(GL_TEXTURE_2D);
	glDisable(GL_DEPTH_TEST);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glPushMatrix();
		glLoadIdentity();
		glMatrixMode(GL_PROJECTION);
		glPushMatrix();
			glLoadIdentity();
			glBegin(GL_QUADS);
				glVertex3i (-1, -1, -1);
				glVertex3i (1, -1, -1);
				glVertex3i (1, 1, -1); 
				glVertex3i (-1, 1, -1);
			glEnd();
		glPopMatrix();
		glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	glDisable(GL_BLEND);
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_TEXTURE_2D);
	glShadeModel(GL_SMOOTH);
}
Exemple #17
0
void GraphicOpenGL::display() const
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    camera();

    glBegin(GL_QUADS);
    glColor3d(1, 1, 1);
    glVertex3i(0, 0, 0);        // plan
    glVertex3i(0, _width, 0);
    glVertex3i(_height, _width, 0);
    glVertex3i(_height, 0, 0);
    glEnd();

    if (_map != NULL)
    {
        for (int y = 0; y < _height; ++y)
        {
            for (int x = 0; x < _width; ++x)
            {
                if (_map[y][x] != NONE)
                    this->drawCube(y, x, _map[y][x]);
            }
        }
    }
    glFlush();
    SDL_GL_SwapBuffers();
}
Exemple #18
0
static int
test04(int size, int num)
{
   int x, y, z;

   glBegin(GL_TRIANGLES);
   for (y = 0; y < num; y++)
      for (x = 0; x < size; x += 5) {
	 z = num * size - (y * size + x);
	 glTexCoord2f(1.0, 1.0);
	 glColor3f(1.0, 0.0, 0.0);
	 glVertex3i(0, x, z);

	 glTexCoord2f(0.0, 1.0);
	 glColor3f(0.0, 1.0, 0.0);
	 glVertex3i(size - 1 - x, 0, z);

	 glTexCoord2f(1.0, 0.0);
	 glColor3f(0.0, 0.0, 1.0);
	 glVertex3i(x, size - 1 - x, z);
      }
   glEnd();

   return num * size / 5;
}
Exemple #19
0
void DrawIMG(Textura *textura, int dstX, int dstY, int width, int height, int srcX, int srcY) {
  if ((textura->w < width) || (textura->h < height)) printf("tamanho errado\n");

  trocarTextura(textura->id);

  if (!textura->alpha)
    glDisable(GL_BLEND);

  //glLoadIdentity();

  float texX1 = srcX / (float)textura->w;
  float texY1 = srcY / (float)textura->h;
  float texX2 = (srcX+width) / (float)textura->w;
  float texY2 = (srcY+height) / (float)textura->h;

  glBegin(GL_QUADS);
    glTexCoord2f(texX1, texY1);
    glVertex3i(dstX, dstY, 0);

    glTexCoord2f(texX1, texY2);
    glVertex3i(dstX, dstY + height, 0);

    glTexCoord2f(texX2, texY2);
    glVertex3i(dstX + width, dstY + height, 0);

    glTexCoord2f(texX2, texY1);
    glVertex3i(dstX + width, dstY, 0);
  glEnd();

  if (!textura->alpha)
    glEnable(GL_BLEND);
}
Exemple #20
0
void VideoPlayer::display()
{
    GLuint tex = makeTexture();
    glClearColor( 0.0, 0.4, 0.0, 0.0 );
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    glEnable( GL_TEXTURE_2D );
    glDisable(GL_LIGHTING);

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

    glBindTexture( GL_TEXTURE_2D, tex );
    glBegin (GL_QUADS);
    glColor3f(1, 1, 1);
    glTexCoord2f(0, 1);
    glVertex3i(-1, -1, 1);
    glTexCoord2f(1, 1);
    glVertex3i(1, -1, 1);
    glTexCoord2f(1, 0);
    glVertex3i(1, 1, 1);
    glTexCoord2f(0, 0);
    glVertex3i(-1, 1, 1);
    glEnd();

    glPopMatrix ();
    glMatrixMode (GL_MODELVIEW);
    glPopMatrix ();
    glDeleteTextures(1, &tex);
    glEnable(GL_LIGHTING);
}
//	Funcao para desenhar os suportes do abajur.
void drawBlackAxis(void)
{
	//	Eixo dos zz
	glColor4f(BLACK);
	glBegin(GL_LINES);
	glVertex3i( 0, 125, -29.9); 
	glVertex3i(0, 125, 29.9); 
	glEnd();
	//	Eixo dos zz  rodado 45graus
	glPushMatrix();
		glRotatef(45, 0, 1, 0);
		glBegin(GL_LINES);
		glVertex3i( 0, 125, -29.9); 
		glVertex3i(0, 125, 29.9); 
		glEnd();
	// Eixo dos xx rodado 45graus
		glBegin(GL_LINES);
		glVertex3i( -29.9, 125, 0); 
		glVertex3i( 29.9, 125, 0); 
		glEnd();	
	glPopMatrix();
	//	Eixo dos yy
	glBegin(GL_LINES);
	glVertex3i(0,  125, 0); 
	glVertex3i(0, 170, 0); 
	glEnd();
	// Eixo dos xx
	glBegin(GL_LINES);
	glVertex3i( -29.9, 125, 0); 
	glVertex3i( 29.9, 125, 0); 
	glEnd();
}
Exemple #22
0
void blit_texture(const texture& tex, int x, int y, GLfloat rotate)
{
	if(!tex.valid()) {
		return;
	}

	int h = tex.height();
	int w = tex.width();
	const int w_odd = w % 2;
	const int h_odd = h % 2;
	h /= 2;
	w /= 2;

	glPushMatrix();

	glTranslatef(x+w,y+h,0.0);
	glRotatef(rotate,0.0,0.0,1.0);

	tex.set_as_current_texture();

	glBegin(GL_QUADS);
	graphics::texture::set_coord(0.0,0.0);
	glVertex3i(-w,-h,0);
	graphics::texture::set_coord(0.0,1.0);
	glVertex3i(-w,h+h_odd,0);
	graphics::texture::set_coord(1.0,1.0);
	glVertex3i(w+w_odd,h+h_odd,0);
	graphics::texture::set_coord(1.0,0.0);
	glVertex3i(w+w_odd,-h,0);
	glEnd();

	glPopMatrix();
}
Exemple #23
0
//----------------------------------------------------------
void ofTextureBak::draw(float x, float y, float w, float h){

	glEnable(textureTarget);

	// bind the texture
	glBindTexture( textureTarget, (GLuint)textureName[0] );

		GLint px0 = 0;		// up to you to get the aspect ratio right
		GLint py0 = 0;
		GLint px1 = (GLint)w;
		GLint py1 = (GLint)h;

		if (bFlipTexture == true){
			GLint temp = py0;
			py0 = py1;
			py1 = temp;
		}

		// for rect mode center, let's do this:
		if (ofGetRectMode() == OF_RECTMODE_CENTER){
			px0 = (GLint)-w/2;
			py0 = (GLint)-h/2;
			px1 = (GLint)+w/2;
			py1 = (GLint)+h/2;
		}

		// -------------------------------------------------
		// complete hack to remove border artifacts.
		// slightly, slightly alters an image, scaling...
		// to remove the border.
		// we need a better solution for this, but
		// to constantly add a 2 pixel border on all uploaded images
		// is insane..

		GLfloat offsetw = 0;
		GLfloat offseth = 0;

		if (textureTarget == GL_TEXTURE_2D){
			offsetw = 1.0f/(tex_w);
			offseth = 1.0f/(tex_h);
		}
		// -------------------------------------------------

		GLfloat tx0 = 0+offsetw;
		GLfloat ty0 = 0+offseth;
		GLfloat tx1 = tex_t - offsetw;
		GLfloat ty1 = tex_u - offseth;

		glPushMatrix();
		glTranslated(x, y, 0);
		glBegin( GL_QUADS );
			glTexCoord2f(tx0,ty0);			glVertex3i(px0, py0,0);
			glTexCoord2f(tx1,ty0);			glVertex3i(px1, py0,0);
			glTexCoord2f(tx1,ty1);			glVertex3i(px1, py1,0);
			glTexCoord2f(tx0,ty1);			glVertex3i(px0, py1,0);
		glEnd();
		glPopMatrix();

	glDisable(textureTarget);
}
Exemple #24
0
void blit_texture(const texture& tex, int x, int y, int w, int h, GLfloat rotate, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
{
	if(!tex.valid()) {
		return;
	}

	const int w_odd = w % 2;
	const int h_odd = h % 2;

	w /= 2;
	h /= 2;
	glPushMatrix();
	tex.set_as_current_texture();
	glTranslatef(x+abs(w),y+abs(h),0.0);
	glRotatef(rotate,0.0,0.0,1.0);
	glBegin(GL_QUADS);
	graphics::texture::set_coord(x1,y1);
	glVertex3i(-w,-h,0);
	graphics::texture::set_coord(x1,y2);
	glVertex3i(-w,h+h_odd,0);
	graphics::texture::set_coord(x2,y2);
	glVertex3i(w+w_odd,h+h_odd,0);
	graphics::texture::set_coord(x2,y1);
	glVertex3i(w+w_odd,-h,0);
	glEnd();
	glPopMatrix();
}
Exemple #25
0
void DrawLimb(XnUserID player, XnSkeletonJoint eJoint1, XnSkeletonJoint eJoint2)
{
	if (!g_UserGenerator.GetSkeletonCap().IsTracking(player))
	{
		printf("not tracked!\n");
		return;
	}

	XnSkeletonJointPosition joint1, joint2;
	g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(player, eJoint1, joint1);
	g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(player, eJoint2, joint2);

	if (joint1.fConfidence < 0.5 || joint2.fConfidence < 0.5)
	{
		return;
	}

	XnPoint3D pt[2];
	pt[0] = joint1.position;
	pt[1] = joint2.position;

	g_DepthGenerator.ConvertRealWorldToProjective(2, pt, pt);
#ifndef USE_GLES
	glVertex3i(pt[0].X, pt[0].Y, 0);
	glVertex3i(pt[1].X, pt[1].Y, 0);
#else
	GLfloat verts[4] = {pt[0].X, pt[0].Y, pt[1].X, pt[1].Y};
	glVertexPointer(2, GL_FLOAT, 0, verts);
	glDrawArrays(GL_LINES, 0, 2);
	glFlush();
#endif
}
Exemple #26
0
void SimpleHouse1::draw(DrawingState*)
{
  glColor3fv(&color.r);
  fetchTexture("simpleHouse1-front.png");
  glBegin(GL_POLYGON);
  glNormal3f(0,0,-1);
  glTexCoord2f(0,0); glVertex3i(-20, 0, -25);
  glTexCoord2f(0,1); glVertex3i(-20,30, -25);
  glTexCoord2f(.5,1.5); glVertex3i(  0,45,-25);
  glTexCoord2f(1,1); glVertex3i( 20,30,-25);
  glTexCoord2f(1,0); glVertex3i( 20, 0,-25);
  glEnd();
  glBegin(GL_POLYGON);
  glNormal3f(0,0,1);
  glTexCoord2f(0,0); glVertex3i(-20, 0,   25);
  glTexCoord2f(1,0); glVertex3i( 20, 0,   25);
  glTexCoord2f(1,1); glVertex3i( 20,30,   25);
  glTexCoord2f(.5,1.5); glVertex3i(  0,45,25);
  glTexCoord2f(0,1); glVertex3i(-20,30,   25);
  glEnd();
  
  fetchTexture("roof3.png");
  //  polygoni( 5, -20,0,-25,  20,0,-25,   20, 30,-25,   0,45,-25, -20,30,-25);
  //polygoni( 5, -20,0, 25,  20,0, 25,   20, 30, 25,   0,45, 25, -20,30, 25);
  polygoni( 4, 20,30,-25,  20,30, 25,   0, 45, 25,   0, 45, -25);
  polygoni(-4, -20,30,-25, -20,30, 25,   0, 45, 25,   0, 45, -25);
  glBindTexture(GL_TEXTURE_2D,0);
  
  polygoni( 4, 20, 0,-25,  20, 0, 25,  20, 30, 25,  20, 30, -25);
  polygoni(-4,-20, 0,-25, -20, 0, 25, -20, 30, 25, -20, 30, -25);
}
Exemple #27
0
//draws one limb
void DrawLimb(XnUserID player, XnSkeletonJoint eJoint1, XnSkeletonJoint eJoint2)
{
	if (!g_UserGenerator.GetSkeletonCap().IsTracking(player))
	{
		printf("not tracked!\n");
		return;
	}

	XnSkeletonJointPosition joint1, joint2;
	g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(player, eJoint1, joint1);
	g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(player, eJoint2, joint2);

	if (joint1.fConfidence < 0.5 || joint2.fConfidence < 0.5)
	{
		return;
	}

	XnPoint3D pt[2];
	pt[0] = joint1.position;
	pt[1] = joint2.position;

	g_DepthGenerator.ConvertRealWorldToProjective(2, pt, pt);

	glVertex3i(pt[0].X, pt[0].Y, 0);
	glVertex3i(pt[1].X, pt[1].Y, 0);
	//std::cout << pt[0].X << " ," << pt[0].Y << std::endl;
}
Exemple #28
0
void Application::draw_coordinates() {

  glDisable(GL_DEPTH_TEST);
  glDisable(GL_LIGHTING);

  glBegin(GL_LINES);
  glColor4f(1.0f, 0.0f, 0.0f, 0.5f);
  glVertex3i(0,0,0);
  glVertex3i(1,0,0);

  glColor4f(0.0f, 1.0f, 0.0f, 0.5f);
  glVertex3i(0,0,0);
  glVertex3i(0,1,0);

  glColor4f(0.0f, 0.0f, 1.0f, 0.5f);
  glVertex3i(0,0,0);
  glVertex3i(0,0,1);

  glColor4f(0.5f, 0.5f, 0.5f, 0.5f);
  for (int x = 0; x <= 8; ++x) {
    glVertex3i(x - 4, 0, -4);
    glVertex3i(x - 4, 0,  4);
  }
  for (int z = 0; z <= 8; ++z) {
    glVertex3i(-4, 0, z - 4);
    glVertex3i( 4, 0, z - 4);
  }
  glEnd();

  glEnable(GL_LIGHTING);
  glEnable(GL_DEPTH_TEST);

}
Exemple #29
0
void GLTools::drawTriangle() {
	glBegin (GL_TRIANGLES); 
	glVertex3i(-1, 3, 0);
	glVertex3i(-1, -1, 0);
	glVertex3i(3, -1, 0);
	glEnd ();
}
Exemple #30
0
static int BuildStatsBG()
{
  int   bgtex,cl;
  float a,b;

  // I use these values to slightly tweak the textures positions.
  a = 0.0f;
  b = 1.0f;

  // I guess we can load this here..
  bgtex = LoadTexture("data/bmp/StatsBG.bmp"); 

  // Start a list
  glNewList(cl=glGenLists(1),GL_COMPILE);

  // Draw cloth BG.
  glColor3f(0.5f,0.5f,0.5f);
  glBindTexture(GL_TEXTURE_2D,bgtex);
  glBegin(GL_QUADS);
  glTexCoord2f(a,b); glVertex3i(0.0, 1.0, 1.0);
  glTexCoord2f(a,a); glVertex3i(0.0, 0.0, 1.0);
  glTexCoord2f(b,a); glVertex3i(1.0, 0.0, 1.0);
  glTexCoord2f(b,b); glVertex3i(1.0, 1.0, 1.0);
  glEnd();

  // End the list.
  glEndList();

  // Return the new call list
  return cl;
}