コード例 #1
0
ファイル: project4.cpp プロジェクト: notabotanist/cg1-p4
	virtual void doRender() {
	    GlobalMaterials::setGroundMaterial();
		glColor3ub(0, 127, 0);
		glBindTexture(GL_TEXTURE_2D, TextureLoader::getGroundTex());
		glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
		resetTexParameters();

		if (solid) {
			glBegin(GL_QUADS);
		} else {
			glBegin(GL_LINE_LOOP);
		}
			glNormal3f(0,1,0); glTexCoord2i(numBuildings, numBuildings); glVertex3f(extent, 0, extent);
			glNormal3f(0,1,0); glTexCoord2i(-numBuildings, numBuildings); glVertex3f(-extent, 0, extent);
			glNormal3f(0,1,0); glTexCoord2i(-numBuildings, -numBuildings); glVertex3f(-extent, 0, -extent);
			glNormal3f(0,1,0); glTexCoord2i(numBuildings, -numBuildings); glVertex3f(extent, 0, -extent);
		glEnd();

		glBindTexture(GL_TEXTURE_2D, 0);
	}
コード例 #2
0
ファイル: bitmap.cpp プロジェクト: ignatenkobrain/psworlds
void bitmap::draw ()
{
  // rotate towards camera and draw the bitmap
  
  if (duration>=0.0)
  {
    GLuint camstate;
    
    Camera* cam = (Camera*) getcam ();
    camstate = cam->getCamstate ();

    glBindTexture (GL_TEXTURE_2D, txtid);
    glColor4f (0.7,0.7,1.0,alpha);

    // rotate the bitmap so that it´s always facing us
    glPushMatrix ();
      glTranslatef (x,y,z);
      
      if (camstate==CAM_COCKPIT||camstate==CAM_BEHIND||camstate==CAM_FLYBY)
        glMultMatrixd (cam->getInvmat ());
      else
      {
        glRotatef (cam->getyrot (), 0.0, 1.0, 0.0);
        glRotatef (cam->getzrot (), 0.0, 0.0, 1.0);
        glRotatef (cam->getxrot (), 1.0, 0.0, 0.0);
      }
      
      glBegin (GL_QUADS);
      glTexCoord2i (0,1);
      glVertex3f (-w,h,0.0);
      glTexCoord2i (0,0);
      glVertex3f (-w,-h,0.0);
      glTexCoord2i (1,0);
      glVertex3f (w,-h,0.0);
      glTexCoord2i (1,1);
      glVertex3f (w,h,0.0);
      glEnd ();
    glPopMatrix ();

  }
}
コード例 #3
0
void vsx_window_object_inspector::draw_2d() {
	vsx_widget_window::draw_2d();

  if (view_type == 1)
  {
    pos_.y = pos.y+size.y-font_size;
    size_.y = size.y-font_size-dragborder;
    pos_.x = pos.x+dragborder;
    size_.x = size.x-dragborder*2;
    //printf("size: %f\n",size_.x);
    title = filename_loaded+" "+vsx_string_helper::i2s((int)texture.texture_info->size_x)+"x"+vsx_string_helper::i2s((int)texture.texture_info->size_y);
   	texture.bind();
    glColor4f(1,1,1,1);
    if (texture.valid) {
    	glBegin(GL_QUADS);
      if (texture.texture_info->ogl_type == GL_TEXTURE_2D) {
      	glTexCoord2i(0, 1);
        glVertex3f(pos_.x,pos_.y,0);
      	glTexCoord2i(1, 1);
        glVertex3f(pos_.x+size_.x,pos_.y,0);
      	glTexCoord2i(1, 0);
        glVertex3f(pos_.x+size_.x,pos_.y-size_.y,0);
      	glTexCoord2i(0, 0);
        glVertex3f(pos_.x,pos_.y-size_.y,0);
      } else {
        glTexCoord2i(0, (int)texture.texture_info->size_y);
        glVertex3f(pos_.x,pos_.y,0);
        glTexCoord2i((int)texture.texture_info->size_x, (int)texture.texture_info->size_y);
        glVertex3f(pos_.x+size_.x,pos_.y,0);
        glTexCoord2i((int)texture.texture_info->size_x, 0);
        glVertex3f(pos_.x+size_.x,pos_.y-size_.y,0);
      	glTexCoord2i(0, 0);
        glVertex3f(pos_.x,pos_.y-size_.y,0);
      }
      glEnd();
    }
    texture._bind();
    float screenaspect = screen_x/screen_y;
    if (texture_loaded == false)
    if (texture.texture_info->size_y != 0.0) {
      texture_loaded = true;
      vsx_vector3<> aa;
      aa.x = 0.4/screenaspect*(texture.texture_info->size_x/texture.texture_info->size_y);
      aa.y = 0.4;
      aa.z = 0;
      printf("resizing to tex\n");
      resize_to(aa);
      move(1*screen_aspect-0.4/screenaspect*(texture.texture_info->size_x/texture.texture_info->size_y),1.0f-aa.y,0);
    }
  }
}
コード例 #4
0
ファイル: color-convert.c プロジェクト: snorp/color-convert
static void
draw_scene(void)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glBegin(GL_QUADS);
    {
        glTexCoord2i(0, 0);
        glVertex2i(0, 0);

        glTexCoord2i(1, 0);
        glVertex2i(WIDTH, 0);

        glTexCoord2i(1, 1);
        glVertex2i(WIDTH, HEIGHT);

        glTexCoord2i(0, 1);
        glVertex2i(0, HEIGHT);
    }
    glEnd();
}
コード例 #5
0
void DrawGround(GLuint textureID)
{
	//glEnable(GL_TEXTURE_2D);
	glColor3f(0.1f, 0.5f, 0.9f);
	//glBindTexture(GL_TEXTURE_2D, textureID);
	glBegin(GL_TRIANGLE_STRIP);
	
		glTexCoord2i(0, 0);
		glVertex3f(-SCREENWIDTH, 0, -SCREENHEIGHT);

		glTexCoord2i(1, 0);
		glVertex3f(SCREENWIDTH, 0, -SCREENHEIGHT);

		glTexCoord2i(0, 1);
		glVertex3f(-SCREENWIDTH, 0, SCREENHEIGHT);

		glTexCoord2i(1, 1);
		glVertex3f(SCREENWIDTH, 0, SCREENHEIGHT);
	glEnd();
	glDisable(GL_TEXTURE_2D);
}
コード例 #6
0
void ClusterGrenade::Draw() const
{
    glPushMatrix();

    glTranslatef(GetPosition().x, GetPosition().y, 0.0f);
    glRotatef(RadiansToDegrees(GetAngle()), 0, 0, 1);
    glBindTexture(GL_TEXTURE_2D, m_xTexture->tex);

    glBegin(GL_QUADS);
    glTexCoord2i(0, 1);
    glVertex2f(-m_fHalfWidth, -m_fHalfHeight);
    glTexCoord2i(1, 1);
    glVertex2f(m_fHalfWidth, -m_fHalfHeight);
    glTexCoord2i(1, 0);
    glVertex2f(m_fHalfWidth, m_fHalfHeight);
    glTexCoord2i(0, 0);
    glVertex2f(-m_fHalfWidth, m_fHalfHeight);
    glEnd();

    glPopMatrix();
}
コード例 #7
0
ファイル: GLwrap.cpp プロジェクト: Cinderr/game-engine-fork
void GLW::Blit2dTex(GLuint texture, int width, int height, int x, int y){
	glBindTexture(GL_TEXTURE_2D, texture);

	glBegin(GL_QUADS);

	glTexCoord2i(0, 0);
	glVertex3f(x, y, 0);

	glTexCoord2i(1, 0);
	glVertex3f(x + width, y, 0);

	glTexCoord2i(1, 1);
	glVertex3f(x + width, y + height, 0);

	glTexCoord2i(0, 1);
	glVertex3f(x, y + height, 0);

	glEnd();

	CheckError();
}
コード例 #8
0
ファイル: map.cpp プロジェクト: mzijlstra/Hover-Tank-Racer
void Map::display() {
	// This method could be optimized by calculating the part of the quad
	// that is going to be inside the clipping area, and then only drawing
	// a quad of that size, and only drawing stuff inside it
	glPushMatrix();

	// map itself is light grey
	glColor3f(0.99, 0.99, 0.99);
	glBindTexture(GL_TEXTURE_2D, texture);

	glBegin(GL_QUADS);
		// bottom left corner
		glTexCoord2i(0, 0); glVertex3f(0.0f, 0.0f, 0.0f);
		// bottom right
		glTexCoord2i(1, 0); glVertex3f(   w, 0.0f, 0.0f);
		// top right
		glTexCoord2i(1, 1); glVertex3f(   w,    h, 0.0f);
		// top left
		glTexCoord2i(0, 1); glVertex3f(0.0f,    h, 0.0f);
	glEnd();
/*
	// draw green grid lines every 64 px
	glColor3f(0.0, 1.0, 0.0);
	glBegin(GL_LINES);

	// vertical lines
	for (int i = 0; i < w; i += 64) {
		glVertex3f(i, 0, 1);
		glVertex3f(i, h, 1);
	}

	// horizontal lines
	for (int i = 0; i < h; i += 64) {
		glVertex3f(0, i, 1);
		glVertex3f(w, i, 1);
	}
	glEnd();
*/
	glPopMatrix();
}
コード例 #9
0
ファイル: ShadowFin.cpp プロジェクト: hahahahaman/ltbl
	void ShadowFin::render(float transparency)
	{
		if(m_penumbraBrightness != 1.0f)
		{
			glColor4f(1.0f, 1.0f, 1.0f, m_penumbraBrightness * transparency);

			glBlendFunc(GL_ZERO, GL_SRC_ALPHA);

			glBegin(GL_TRIANGLES);
				glTexCoord2i(0, 1); glVertex2f(m_rootPos.x, m_rootPos.y);
				glTexCoord2i(1, 0); glVertex2f(m_rootPos.x + m_penumbra.x, m_rootPos.y + m_penumbra.y);
				glTexCoord2i(0, 0); glVertex2f(m_rootPos.x + m_umbra.x, m_rootPos.y + m_umbra.y);
			glEnd();
		}
		else
		{
			if(m_umbraBrightness != 1.0f)
			{
				float brightness = (1.0f - m_umbraBrightness) * transparency;
				glColor4f(1.0f, 1.0f, 1.0f, brightness);
			}
			else
				glColor4f(1.0f, 1.0f, 1.0f, transparency);

			glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);

			glBegin(GL_TRIANGLES);
				glTexCoord2i(0, 1); glVertex2f(m_rootPos.x, m_rootPos.y);
				glTexCoord2i(0, 0); glVertex2f(m_rootPos.x + m_penumbra.x, m_rootPos.y + m_penumbra.y);
				glTexCoord2i(1, 0); glVertex2f(m_rootPos.x + m_umbra.x, m_rootPos.y + m_umbra.y);
			glEnd();
		}

		glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	}
コード例 #10
0
void SolarPanel::RenderAlphas( float _predictionTime )
{
    PowerBuilding::RenderAlphas( _predictionTime );

    float fractionOccupied = (float) GetNumPortsOccupied() / (float) GetNumPorts();

    if( fractionOccupied > 0.0f )
    {
        Matrix34 mat( m_front, m_up, m_pos );
        float glowWidth = 60.0f;
        float glowHeight = 40.0f;
        float alphaValue = fabs(sinf(g_gameTime)) * fractionOccupied;

        glColor4f       ( 0.2f, 0.4f, 0.9f, alphaValue );
        glEnable        ( GL_BLEND );
        glBlendFunc     ( GL_SRC_ALPHA, GL_ONE );
        glEnable        ( GL_TEXTURE_2D );
        glBindTexture   ( GL_TEXTURE_2D, g_app->m_resource->GetTexture( "textures/glow.bmp" ) );
        glDepthMask     ( false );
        glDisable       ( GL_CULL_FACE );

        for( int i = 0; i < SOLARPANEL_NUMGLOWS; ++i )
        {
            Matrix34 thisGlow = m_glowMarker[i]->GetWorldMatrix( mat );

            glBegin( GL_QUADS );
                glTexCoord2i( 0, 0 );   glVertex3fv( (thisGlow.pos - thisGlow.r * glowHeight + thisGlow.f * glowWidth).GetData() );
                glTexCoord2i( 0, 1 );   glVertex3fv( (thisGlow.pos + thisGlow.r * glowHeight + thisGlow.f * glowWidth).GetData() );
                glTexCoord2i( 1, 1 );   glVertex3fv( (thisGlow.pos + thisGlow.r * glowHeight - thisGlow.f * glowWidth).GetData() );
                glTexCoord2i( 1, 0 );   glVertex3fv( (thisGlow.pos - thisGlow.r * glowHeight - thisGlow.f * glowWidth).GetData() );
            glEnd();
        }

        glEnable        ( GL_CULL_FACE );
        glDepthMask     ( true );
        glDisable       ( GL_TEXTURE_2D );
        glBlendFunc     ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
        glDisable       ( GL_BLEND );
    }
}
コード例 #11
0
ファイル: gl_fbo.c プロジェクト: infernuslord/uqe-quake
void R_FrameBuffer_End(void)
{
	int p;
	GLint loc;

	if(framebuffer_ext == false)
		return;

	if(!gl_framebuffer.value)
		return;

	if(!framebuffer_initialized)
		return;

	R_FrameBuffer_Process();
	R_Bloom_Process();


	// draw to original window surface
	phBindSurface(&window, false);
	glBegin(GL_QUADS);
	glTexCoord2i(0, 1); glVertex2i(0, 0);
    glTexCoord2i(1, 1); glVertex2i(scenebase.width, 0);
    glTexCoord2i(1, 0); glVertex2i(scenebase.width, scenebase.height);
    glTexCoord2i(0, 0); glVertex2i(0, scenebase.height);
    glEnd();


	glUseProgram(0);

	R_Bloom_Clear();
	
	// back to normal window-system-provided framebuffer (unbind)
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

    glActiveTexture(GL_TEXTURE0);
	glEnable(GL_TEXTURE_2D);

	//we probably need to delete the framebuffers somewhere using the glDeleteFramebuffersEXT function
}
コード例 #12
0
ファイル: safeopenglgraphics.cpp プロジェクト: koo5/manaplus
static inline void drawRescaledQuad(const Image *const image,
                                    const int srcX, const int srcY,
                                    const int dstX, const int dstY,
                                    const int width, const int height,
                                    const int desiredWidth,
                                    const int desiredHeight)
{
    if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
    {
        // Find OpenGL normalized texture coordinates.
        const float texX1 = static_cast<float>(srcX)
            / static_cast<float>(image->mTexWidth);
        const float texY1 = static_cast<float>(srcY)
            / static_cast<float>(image->mTexHeight);
        const float texX2 = static_cast<float>(srcX + width)
            / static_cast<float>(image->mTexWidth);
        const float texY2 = static_cast<float>(srcY + height)
            / static_cast<float>(image->mTexHeight);

        glTexCoord2f(texX1, texY1);
        glVertex2i(dstX, dstY);
        glTexCoord2f(texX2, texY1);
        glVertex2i(dstX + desiredWidth, dstY);
        glTexCoord2f(texX2, texY2);
        glVertex2i(dstX + desiredWidth, dstY + desiredHeight);
        glTexCoord2f(texX1, texY2);
        glVertex2i(dstX, dstY + desiredHeight);
    }
    else
    {
        glTexCoord2i(srcX, srcY);
        glVertex2i(dstX, dstY);
        glTexCoord2i(srcX + width, srcY);
        glVertex2i(dstX + desiredWidth, dstY);
        glTexCoord2i(srcX + width, srcY + height);
        glVertex2i(dstX + desiredWidth, dstY + desiredHeight);
        glTexCoord2i(srcX, srcY + height);
        glVertex2i(dstX, dstY + desiredHeight);
    }
}
コード例 #13
0
ファイル: TextInput.c プロジェクト: GedasTheEvil/GameTest
void DrawSave()
{
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		// Clear The Screen And The Depth Buffer
     glLoadIdentity();
     
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     glEnable(GL_BLEND);
     glMatrixMode(GL_PROJECTION);					// Select The Projection Matrix
     glPushMatrix();							// Store The Projection Matrix
     glLoadIdentity();						// Reset The Projection Matrix
     glOrtho(0,800,0,600,-1,1);					// Set Up An Ortho Screen
     glMatrixMode(GL_MODELVIEW);					// Select The Modelview Matrix
     
     glBindTexture(GL_TEXTURE_2D,Btn[0].texID);
     
     glBegin(GL_QUADS);// bg		
     {
	  glTexCoord2i(0, 1); 	  glVertex2i(0,0);	// Texture / Vertex Coord (Bottom Left)
	  glTexCoord2i(1, 1); 	  glVertex2i(800,0);	// Texutre / Vertex Coord (Bottom Right)
	  glTexCoord2i(1, 0);	  glVertex2i(800,600);	// Texture / Vertex Coord (Top Right)
	  glTexCoord2i(0, 0);	  glVertex2i(0,600);	// Texture / Vertex Coord (Top Left)
     }
     glEnd();
     
     if(inputSw)glColor3f(0.0,0.4,0.8);
     else glColor3f(1.0,1.0,1.0);
     glPrint(200,200,"Created by Gedas [%s]", TextKey);
     glColor3f(1.0,1.0,1.0);
     
     glMatrixMode(GL_PROJECTION);				// Select The Projection Matrix
     glPopMatrix();						// Restore The Old Projection Matrix
     glMatrixMode(GL_MODELVIEW);				// Select The Modelview Matrix
     
     glFlush();	
     glDisable(GL_BLEND);
     glBlendFunc(GL_DST_COLOR, GL_ZERO);
     
     glutSwapBuffers();
     
}
コード例 #14
0
ファイル: Screen.cpp プロジェクト: HelloYym/SceneRoam
void Screen::draw(){
    
    float color[4] = {199/255.0f, 255/255.0f, 236/255.0f, 1.0f};
    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color);
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, color);
    glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0.0f);
    
    glEnable(GL_COLOR_MATERIAL);
    glEnable(GL_TEXTURE_2D);
    GLuint texture = videoFrames[curFrame];
    glBindTexture(GL_TEXTURE_2D, texture);
    
    glPushMatrix();
    glBegin(GL_QUADS);
    glTexCoord2i(0, 1);
    glVertex3f(0, 0, 0);
    glTexCoord2i(1, 1);
    glVertex3f(1.85f, 0, 0);
    glTexCoord2i(1, 0);
    glVertex3f(1.85f, 1, 0);
    glTexCoord2i(0, 0);
    glVertex3f(0, 1, 0);
    glEnd();
    glPopMatrix();
    
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_COLOR_MATERIAL);
    
    count++;
    if (count == 5)
        count = 0;
    
    if (count == 1 || count == 3){
        curFrame++;
        if (curFrame == videoFrames.size()) {
            curFrame = 0;
        }
    }
    
}
コード例 #15
0
ファイル: glut.cpp プロジェクト: dk00/old-stuff
void background()
{
    glBindTexture( GL_TEXTURE_2D, texture ); 

    orthogonalStart();

    // texture width/height
    const int iw = 500;
    const int ih = 500;

    glPushMatrix();
    glTranslatef( -iw/2, -ih/2, 0 );
    glBegin(GL_QUADS);
        glTexCoord2i(0,0); glVertex2i(0, 0);
        glTexCoord2i(1,0); glVertex2i(iw, 0);
        glTexCoord2i(1,1); glVertex2i(iw, ih);
        glTexCoord2i(0,1); glVertex2i(0, ih);
    glEnd();
    glPopMatrix();

    orthogonalEnd();
}
コード例 #16
0
void QCVMatWidget::paintGL()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glDisable(GL_DEPTH_TEST);

    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, texture);

    // Draw the textured quad
    glBegin(GL_QUADS);
        glTexCoord2i(0, 0); glVertex2f(-1.0f,  1.0f);
        glTexCoord2i(0, 1); glVertex2f(-1.0f, -1.0f);
        glTexCoord2i(1, 1); glVertex2f( 1.0f, -1.0f);
        glTexCoord2i(1, 0); glVertex2f( 1.0f,  1.0f);
    glEnd();

    // Unbind the texture
    glBindTexture(GL_TEXTURE_2D, 0);
    glFlush();
    glDisable(GL_TEXTURE_2D);
    glEnable(GL_DEPTH_TEST);
}
コード例 #17
0
ファイル: tekst.cpp プロジェクト: grochmal/uj-fizyka
void Display(void)
{
	glClear(GL_COLOR_BUFFER_BIT);

	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glScalef(0.5,0.5,0.5);
	
	glBegin(GL_QUAD_STRIP);
		// pierwszy czworok¹t
		glTexCoord2i(0,1);
		glVertex3i(-600,-300,-600);
		glTexCoord2i(1,1);
		glVertex3i(-600, 300,-600);
		glTexCoord2i(0,0);
		glVertex3i( 600,-300,-600);
		glTexCoord2i(1,0);
		glVertex3i( 600, 300,-600);
		// drugi czworok¹t
		glTexCoord2i(0,2);
		glVertex3i( 600,-300, 600);
		glTexCoord2i(2,2);
		glVertex3i( 600, 300, 600);
		// trzeci czworok¹t
		glTexCoord2i(0,0);
		glVertex3i(-600,-300, 600);
		glTexCoord2i(2,0);
		glVertex3i(-600, 300, 600);
		// czwarty czworok¹t
		glTexCoord2i(0,2);
		glVertex3i(-600,-300,-600);
		glTexCoord2i(2,2);
		glVertex3i(-600, 300,-600);
	glEnd();
	glPopMatrix();

	glFlush();
}
コード例 #18
0
  foreach( it, effects )
  {
    // Bind default framebuffer and draw contents of our framebuffer
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _framebuffer2 );
    glLoadIdentity();
    glMatrixMode(GL_MODELVIEW);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  // black screen

    float x0 =0;
    float x1 = x0+_size.width();
    float y0 = 0;
    float y1 = y0+_size.height();

    glBindTexture(GL_TEXTURE_2D, _framebuffer);

    (*it)->begin();
    (*it)->bindTexture();

    glBegin( GL_QUADS );

    glTexCoord2i( 0, 1 );
    glVertex2f( x0, y0 );

    glTexCoord2i( 0, 0 );
    glVertex2f( x0, y1 );

    glTexCoord2i( 1, 0 );
    glVertex2f( x1, y1 );

    glTexCoord2i( 1, 1 );
    glVertex2f( x1, y0 );

    glEnd();

    (*it)->end();

    std::swap( _framebuffer, _framebuffer2 );
  }
コード例 #19
0
void Zombie::Render( double _predictionTime )
{
    Vector3 predictedPos = m_pos + m_vel * _predictionTime;
    predictedPos += m_hover * _predictionTime;

    Vector3 predictedFront = m_front;
    Vector3 predictedUp = m_up;
    Vector3 predictedRight = predictedFront ^ predictedUp;

    double size = 5.0;

    double alpha = 1.0 - (m_life/10.0);
    alpha = max( 0.1, alpha );
    alpha = min( 0.7, alpha );

    double outerAlpha = (0.7-alpha) * 0.1;

    double timeRemaining = 600.0 - m_life;
    if( timeRemaining < 100.0 )
    {
        alpha *= timeRemaining * 0.01;
        outerAlpha *= timeRemaining * 0.01;
    }

    glDisable       ( GL_CULL_FACE );
    glColor4f       ( 0.9, 0.9, 1.0, alpha );
    glEnable        ( GL_TEXTURE_2D );
    glBindTexture   ( GL_TEXTURE_2D, g_app->m_resource->GetTexture( "sprites/ghost.bmp" ) );

    glBegin( GL_QUADS );
        glTexCoord2i(0,0);      glVertex3dv( (predictedPos - size*predictedRight - size*predictedUp).GetData() );
        glTexCoord2i(1,0);      glVertex3dv( (predictedPos + size*predictedRight - size*predictedUp).GetData() );
        glTexCoord2i(1,1);      glVertex3dv( (predictedPos + size*predictedRight + size*predictedUp).GetData() );
        glTexCoord2i(0,1);      glVertex3dv( (predictedPos - size*predictedRight + size*predictedUp).GetData() );
    glEnd();

    size *= 2.0;
    glColor4f       ( 0.9, 0.9, 1.0, outerAlpha );
    glBegin( GL_QUADS );
        glTexCoord2i(0,0);      glVertex3dv( (predictedPos - size*predictedRight - size*predictedUp).GetData() );
        glTexCoord2i(1,0);      glVertex3dv( (predictedPos + size*predictedRight - size*predictedUp).GetData() );
        glTexCoord2i(1,1);      glVertex3dv( (predictedPos + size*predictedRight + size*predictedUp).GetData() );
        glTexCoord2i(0,1);      glVertex3dv( (predictedPos - size*predictedRight + size*predictedUp).GetData() );
    glEnd();

    glDisable       ( GL_TEXTURE_2D );
    glEnable        ( GL_CULL_FACE );
}
コード例 #20
0
ファイル: gl_image_area.c プロジェクト: PennPanda/libbot2
static gboolean 
on_gl_expose (GtkWidget * widget, GdkEventExpose * event, void* user_data)
{
    BotGtkGlImageArea *self = BOT_GTK_GL_IMAGE_AREA (user_data);

    // activate the opengl context
    bot_gtk_gl_drawing_area_set_context (BOT_GTK_GL_DRAWING_AREA (self));

    // setup opengl view and model matrices, and clear the opengl buffers
    glMatrixMode (GL_PROJECTION);
    glLoadIdentity ();
    glOrtho (0, self->width, self->height, 0, -1, 1);
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode (GL_MODELVIEW);
    glLoadIdentity ();

    // abort if nothing to draw
    if (self->width <= 0 || self->height <= 0 || !self->texname) return FALSE;

    // draw the image
    glEnable (self->target);
    glBindTexture (self->target, self->texname);
    glBegin (GL_QUADS);
    glColor3f (1.0, 1.0, 1.0);
    glTexCoord2i (0, 0);
    glVertex2i (0, 0);
    glTexCoord2i (0, self->texc_height);
    glVertex2i (0, self->height);
    glTexCoord2i (self->texc_width, self->texc_height);
    glVertex2i (self->width, self->height);
    glTexCoord2i (self->texc_width, 0);
    glVertex2i (self->width, 0);
    glEnd ();
    glBindTexture (self->target, 0);
    glDisable (self->target);

    return FALSE;
}
コード例 #21
0
/**
 * \brief Tile image on the screen.
 * \param[in] x x-coordinate.
 * \param[in] y y-coordinate.
 * \param[in] w Width of region.
 * \param[in] h Height of region.
 * \param[in] pic File name of texture to draw.
 * \return
 * \note This repeats a tile graphic to fill a region on the screen.
 */
void R_Draw_Tile (int x, int y, int w, int h, const char *pic)
{
    Texture *tex;

    if (!(tex = texture_get_picture(pic)))
        return;

    texture_use(tex->id);

    glBegin (GL_QUADS);
        glTexCoord2i (x / tex->width, y / tex->height);
        glVertex2i (x, y);

        glTexCoord2i ((x + w) / tex->width, y / tex->height);
        glVertex2i (x + w, y);

        glTexCoord2i ((x + w) / tex->width, (y + h) / tex->height);
        glVertex2i (x + w, y + h);

        glTexCoord2i (x / tex->width, (y + h) / tex->height);
        glVertex2i (x, y + h);
    glEnd();
}
コード例 #22
0
ファイル: Class.cpp プロジェクト: DragonL/Hackson
void PlayerPlane::draw()
{
	if(life>0){
		glPushMatrix();
		glTranslatef(x, y, 0.0f);
		glEnable(GL_TEXTURE_2D);
		glBindTexture(GL_TEXTURE_2D, playertex[planeTexture].texID);
		
		if(life>50)
			glColor3f(1.0f, 1.0f, 1.0f);
		else
			glColor3f(0.7f, 0.7f, 0.7f);
		glBegin(GL_QUADS);
			glTexCoord2i(0.0f, 0.0f);glVertex2i(-20,-20);
			glTexCoord2i(1.0f, 0.0f);glVertex2i( 20,-20);
			glTexCoord2i(1.0f, 1.0f);glVertex2i( 20, 20);
			glTexCoord2i(0.0f, 1.0f);glVertex2i(-20, 20);
		glEnd();
		glColor3f(1.0f, 1.0f, 1.0f);
		glDisable(GL_TEXTURE_2D);
		glPopMatrix();
	}
}
コード例 #23
0
void drawTexture(int pixelPosX, int pixelPosY, int width,int height)
{
	glEnable(GL_TEXTURE_2D);
    //glBindTexture(GL_TEXTURE_2D, (GLuint)textureId );

    glMatrixMode(GL_MODELVIEW);

	glBegin(GL_POLYGON);

    glTexCoord2i(1, 1);//1,0
	glVertex2i(pixelPosX+width, pixelPosY+height);

    glTexCoord2i(0, 1);//0,0
	glVertex2i(pixelPosX, pixelPosY+height);

    glTexCoord2i(0, 0);//0,1
	glVertex2i(pixelPosX, pixelPosY);

    glTexCoord2i(1, 0);//1,1
	glVertex2i(pixelPosX+width, pixelPosY);

	glEnd();
}
コード例 #24
0
ファイル: glimageview.cpp プロジェクト: Jailander/gazetool
void GLImageView::paintGL() {
	GLfloat offset_x = 0;
	GLfloat offset_y = 0;
	GLfloat gl_width = this->width();
	GLfloat gl_height = this->height();

	float ratioImg = float(cv_frame.cols) / (float) cv_frame.rows;
	float ratioScreen = this->width() / (float) this->height();

	if (ratioImg > ratioScreen)
		gl_height = gl_width / ratioImg;
	else
		gl_width = gl_height * ratioImg;
    offset_x = (this->width() - gl_width) * .5f;
    //offset_y = (this->height() - gl_height) * .5f;

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glDisable (GL_DEPTH_TEST);
	glMatrixMode (GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0.0f, this->width(), this->height(), 0.0f, 0.0f, 1.0f);
	glMatrixMode (GL_MODELVIEW);
	glLoadIdentity();
	glEnable (GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, texture);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, cv_frame.cols, cv_frame.rows, 0, format, depth, cv_frame.ptr());
	glBegin (GL_QUADS);
	glTexCoord2i(0, 1);
	glVertex2i(offset_x, gl_height + offset_y);
	glTexCoord2i(0, 0);
	glVertex2i(offset_x, offset_y);
	glTexCoord2i(1, 0);
	glVertex2i(gl_width + offset_x, offset_y);
	glTexCoord2i(1, 1);
	glVertex2i(gl_width + offset_x, gl_height + offset_y);
	glEnd();
}
コード例 #25
0
ファイル: JetBar.cpp プロジェクト: aidanhs/cruelhessian
void JetBar::Draw(float jet_amount) const
{

    if (type == BAR_TEXT)
    {
        Fonts.printText(Fonts.font[1], Fonts.FontConsole, IntToString(100 * jet_amount) + "%", Fonts.textCol[3], x, y);
    }
    else
    {
        int cur_width = static_cast<int>(m_iOriginalWidth * jet_amount);


        glEnable(GL_TEXTURE_2D);

        glPushMatrix();

        glLoadIdentity();
        glTranslatef(x, y, 0.0f);
        glRotatef(-angle, 0, 0, 1);
        glBindTexture(GL_TEXTURE_2D, texture.tex);

        glBegin(GL_QUADS);
        glTexCoord2i(0, 1);
        glVertex2i(0, 0);
        glTexCoord2i(1, 1);
        glVertex2i(cur_width, 0);
        glTexCoord2i(1, 0);
        glVertex2i(cur_width, height);
        glTexCoord2i(0, 0);
        glVertex2i(0, height);
        glEnd();

        glPopMatrix();

        glDisable(GL_TEXTURE_2D);
    }
}
コード例 #26
0
ファイル: Graphics.cpp プロジェクト: bennybroseph/SolarSystem
	void DrawImage(GLuint glTexture)
	{
		glColor3f(1.0f, 1.0f, 1.0f);

		glBindTexture(GL_TEXTURE_2D, Surface.Surface);
		glBegin(GL_QUADS);
		//Bottom-left vertex (corner)
		glColor3b(127, 127, 127);
		glTexCoord2i(0, 0); //Position on texture to begin interpolation
		glVertex3f(x, y, 0.f); //Vertex Coords

							   //Bottom-right vertex (corner)
		glTexCoord2i(1, 0);
		glVertex3f(x + Surface.w, y, 0.f);

		//Top-right vertex (corner)
		glTexCoord2i(1, 1);
		glVertex3f(x + Surface.w, y + Surface.h, 0.f);

		//Top-left vertex (corner)
		glTexCoord2i(0, 1);
		glVertex3f(x, y + Surface.h, 0.f);
		glEnd();
	}
コード例 #27
0
/**
    \fn render
*/
bool openGlBenchmark::render(ADMImage *image,ADM_PLANE plane,QGLFramebufferObject *fbo)
{
    int width=image->GetWidth(plane);
    int height=image->GetHeight(plane);

    glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
	glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, width, 0, height, -1, 1);

    //
    glBegin(GL_QUADS);
	glTexCoord2i(0, 0);
	glVertex2i(0, 0);
	glTexCoord2i(width, 0);
	glVertex2i(width, 0);
	glTexCoord2i(width, height);
	glVertex2i(width ,height);
	glTexCoord2i(0, height);
	glVertex2i(0, height);
	glEnd();	// draw cube background
    return true;
}
コード例 #28
0
ファイル: Objet.cpp プロジェクト: Babouchot/Epoch
// Fonction d'affichage
void Objet::affiche()
{
	glEnable(GL_TEXTURE_2D);
    if(type == CERCLE)
    {
	   glBindTexture(GL_TEXTURE_2D, txtballe);
    }
    else
    {
	   glBindTexture(GL_TEXTURE_2D, txtbarre);
    }
	glColor3f(r,g,b);   
	glBegin(GL_QUADS);
    	glTexCoord2i(0,1);
    	glVertex3f(pos.getX(),pos.getY(),0);            
    	glTexCoord2i(1,1);
    	glVertex3f(pos.getX()+taille.getX(),pos.getY(),0);
    	glTexCoord2i(1,0);
    	glVertex3f(pos.getX()+taille.getX(),pos.getY()+taille.getY(),0);
    	glTexCoord2i(0,0);
    	glVertex3f(pos.getX(),pos.getY()+taille.getY(),0);      
	glEnd();
	glDisable(GL_TEXTURE_2D);
}
コード例 #29
0
ファイル: cSprite.cpp プロジェクト: BigBearGCU/GP1
void cSprite::render()
{
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, texture->getTexture()); // Binding of GLtexture name 

	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadMatrixf(glm::value_ptr(transform));

	glBegin(GL_QUADS);
		glColor3f(255.0f, 255.0f, 255.0f); //flush with white
		glTexCoord2i(0, 0); //providing uv mapping
		glVertex2i(-textureWidth / 2,  -textureHeight / 2);
		glTexCoord2i(1, 0);
		glVertex2i(textureWidth / 2, -textureHeight / 2);
		glTexCoord2i(1, 1);
		glVertex2i(textureWidth / 2, textureHeight / 2);
		glTexCoord2i(0, 1);
		glVertex2i(-textureWidth / 2, textureHeight / 2);
	glEnd();
	glPopMatrix();

	glDisable(GL_TEXTURE_2D);
}
コード例 #30
0
ファイル: PlanetSign.cpp プロジェクト: AlohaWu/M.A.R.S.
void PlanetSign::draw() const {
    glPushMatrix();
    glLoadIdentity();

    glTranslatef(location_.x_, location_.y_, 0.f);
    glRotatef(rotation_, 0.f, 0.f, 1.f);
    glScalef(scale_, scale_, 1.f);

    glEnable(GL_TEXTURE_2D);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glBindTexture(GL_TEXTURE_2D, texture::getTexture(texture_));
    glColor3f(1,1,1);

    glBegin(GL_QUADS);
        glTexCoord2i(0, 0); glVertex2f(-100.f, -150.f);
        glTexCoord2i(0, 1); glVertex2f(-100.f,  50.f);
        glTexCoord2i(1, 1); glVertex2f( 100.f,  50.f);
        glTexCoord2i(1, 0); glVertex2f( 100.f, -150.f);
    glEnd();

    glDisable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, 0);
    glPopMatrix();
}