コード例 #1
0
ファイル: cockpit.cpp プロジェクト: garywang/3dmapping
void Cockpit::drawTargetedElement ()
{
  char str [20];
  CColor color;
  CVector3 tl, n;
  CRotation r;
  color.setColor (255, 0, 0);
  color.c [3] = 255;
  tl.x = -0.35; tl.y = -0.3; tl.z = -0.5;
  gl->disableAlphaBlending ();
  glEnable (GL_DEPTH_TEST);
  if (fplayer->target != NULL)
    if (fplayer->target->active)
    {
      glEnable (GL_LIGHTING);
      fplayer->target->o->draw (&n, &tl, fplayer->target->rot, 0.05, 0.3, 0);
      glDisable (GL_LIGHTING);
      if (((AIObj *) fplayer->target)->party == fplayer->party)
        color.setColor (0, 0, 255);
      font1->drawText (-24.0, -23.0, -4.0, fplayer->target->o->name, &color);
      sprintf (str, "%d", (int) (15.0 * fplayer->distance (fplayer->target)));
      font1->drawText (-24.0, -25.0, -4.0, str, &color);
    }
  glDisable (GL_DEPTH_TEST);
}
コード例 #2
0
ファイル: CGUI.cpp プロジェクト: Valvador/PyroSpaceFork
// Reads Custom Color
void CGUI::Xeromyces_ReadColor(XMBElement Element, CXeromyces* pFile)
{
	// Read the color and stor in m_PreDefinedColors

	XMBAttributeList attributes = Element.GetAttributes();

	//IGUIObject* object = new CTooltip;
	CColor color;
	CStr name = attributes.GetNamedItem(pFile->GetAttributeID("name"));

	// Try parsing value 
	CStr value (Element.GetText());
	if (! value.empty())
	{
		// Try setting color to value
		if (!color.ParseString(value, 255.f))
		{
			LOGERROR(L"GUI: Unable to create custom color '%hs'. Invalid color syntax.", name.c_str());
		}
		else
		{
			// input color
			m_PreDefinedColors[name] = color;
		}
	}
}
コード例 #3
0
ファイル: Color.cpp プロジェクト: heguanyu/JointDetection
//********************************************
// Set
//********************************************
void CColor::Set(CColor &c)
{
	m_Red = c.r();
	m_Green = c.g();
	m_Blue = c.b();
	m_Alpha = c.a();
}
コード例 #4
0
ファイル: RenderingCore.cpp プロジェクト: vsuley/Alight
// The raytracing process
void CRenderingCore::RenderPixelBuffer()
{
    /**************************************************************
    STRATEGY:
    1. Run nested loop for the entire screen.
    **************************************************************/
    m_pcamCurrent->Describe();
    
    // 1.
    for (int y = 0; y < m_iPixelY; y++)
    {
		for (int x = 0; x < m_iPixelX; x++)
		{
			CColor colToUse;
			
            /****************************************************************
			NESTED LOOP LOGIC:
			Calculate the X fraction
			Get the pixel ray for this screen coordinate fromt the 
			camera
			Get the color for this ray.
			Plot the pixel with this color.
			****************************************************************/

			colToUse = Sample ((float)x, (float)y, 1);

			m_ppPixelBuffer[0][x][y] = ((float) (int)(colToUse.GetRed()   * 1000.0f)) / 1000.0f;
			m_ppPixelBuffer[1][x][y] = ((float) (int)(colToUse.GetGreen() * 1000.0f)) / 1000.0f;
			m_ppPixelBuffer[2][x][y] = ((float) (int)(colToUse.GetBlue()  * 1000.0f)) / 1000.0f;

		}
    }
}
コード例 #5
0
ファイル: uisearchtextfield.cpp プロジェクト: EQ4/vstgui
//----------------------------------------------------------------------------------------------------
void UISearchTextField::drawClearMark (CDrawContext* context) const
{
	if (getText ().empty ())
		return;

	SharedPointer<CGraphicsPath> path = owned (context->createGraphicsPath ());
	if (path == 0)
		return;

	CRect r = getClearMarkRect ();
	CColor color (fontColor);
	color.alpha /= 2;
	context->setFillColor (color);
	context->setDrawMode (kAntiAliasing);
	context->drawEllipse (r, kDrawFilled);
	double h,s,v;
	color.toHSV (h, s, v);
	v = 1. - v;
	color.fromHSV (h, s, v);
	context->setFrameColor (color);
	context->setLineWidth (2.);
	r.inset (r.getWidth () / (M_PI * 2.) + 1, r.getHeight () / (M_PI * 2.) + 1);
	path->beginSubpath (r.getTopLeft ());
	path->addLine (r.getBottomRight ());
	path->beginSubpath (r.getBottomLeft ());
	path->addLine (r.getTopRight ());
	context->setDrawMode (kAntiAliasing|kNonIntegralMode);
	context->drawGraphicsPath (path, CDrawContext::kPathStroked);
}
コード例 #6
0
ファイル: cockpit.cpp プロジェクト: garywang/3dmapping
void Cockpit::drawWeapon ()
{
  char str [20];
  CColor color;
  CVector3 tl, n;
  CRotation r;
  if (fplayer->missiles [fplayer->missiletype] <= 0)
    return;
  color.setColor (255, 0, 0);
  color.c [3] = 255;
  tl.x = 0.35; tl.y = -0.3; tl.z = -0.5;
  gl->disableAlphaBlending ();
  glEnable (GL_DEPTH_TEST);
  CModel *missile = NULL;
  if (fplayer->missiletype == 0) missile = &model_missile1;
  else if (fplayer->missiletype == 1) missile = &model_missile2;
  else if (fplayer->missiletype == 2) missile = &model_missile3;
  else if (fplayer->missiletype == 3) missile = &model_missile4;
  else if (fplayer->missiletype == 4) missile = &model_missile5;
  else if (fplayer->missiletype == 5) missile = &model_missile6;
  else if (fplayer->missiletype == 6) missile = &model_missile7;
  else if (fplayer->missiletype == 7) missile = &model_missile8;
  glEnable (GL_LIGHTING);
  missile->draw (&n, &tl, fplayer->rot, 0.05, 1.0, 0);
  glDisable (GL_LIGHTING);
  glDisable (GL_DEPTH_TEST);
  font1->drawText (16.0, -22.0, -4.0, missile->name, &color);
  sprintf (str, "N %d", fplayer->missiles [fplayer->missiletype]);
  font1->drawText (16.0, -24.0, -4.0, str, &color);
}
コード例 #7
0
ファイル: CColor.cpp プロジェクト: teddy-michel/OBJViewer
CColor CColor::modulate ( const CColor& color ) const
{
    unsigned char R = static_cast<unsigned char> ( getRed()   * color.getRed()   / 255 );
    unsigned char G = static_cast<unsigned char> ( getGreen() * color.getGreen() / 255 );
    unsigned char B = static_cast<unsigned char> ( getBlue()  * color.getBlue()  / 255 );
    unsigned char A = static_cast<unsigned char> ( getAlpha() * color.getAlpha() / 255 );

    return CColor ( R , G , B , A );
}
コード例 #8
0
 void CQTOpenGLUserFunctions::SetColor(const CColor& c_color) {
    const GLfloat pfColor[]     = {
       c_color.GetRed()   / 255.0f,
       c_color.GetGreen() / 255.0f,
       c_color.GetBlue()  / 255.0f
    };
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, DEFAULT_SPECULAR);
    glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, DEFAULT_SHININESS);
    glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, DEFAULT_EMISSION);
    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, pfColor);
 }
コード例 #9
0
buzzvm_state CBuzzController::Register(const std::string& str_key,
                                       const CColor& c_color) {
   buzzvm_pushs(m_tBuzzVM, buzzvm_string_register(m_tBuzzVM, str_key.c_str(), 1));
   buzzvm_pusht(m_tBuzzVM);
   buzzobj_t tColorTable = buzzvm_stack_at(m_tBuzzVM, 1);
   buzzvm_gstore(m_tBuzzVM);
   TablePut(tColorTable, "red", c_color.GetRed());
   TablePut(tColorTable, "green", c_color.GetGreen());
   TablePut(tColorTable, "blue", c_color.GetBlue());
   return m_tBuzzVM->state;
}
コード例 #10
0
ファイル: CColor.cpp プロジェクト: teddy-michel/OBJViewer
CColor CColor::operator * ( float k ) const
{
    int R = static_cast<int> ( getRed() * k );
    int G = static_cast<int> ( getGreen() * k );
    int B = static_cast<int> ( getBlue() * k );
    int A = static_cast<int> ( getAlpha() * k );

    CColor newc;
    newc.setInt ( R , G , B , A );

    return newc;
}
コード例 #11
0
buzzvm_state CBuzzController::TablePut(buzzobj_t t_table,
                                       SInt32 n_idx,
                                       const CColor& c_color) {
   buzzvm_push(m_tBuzzVM, t_table);
   buzzvm_pushi(m_tBuzzVM, n_idx);
   buzzvm_pusht(m_tBuzzVM);
   buzzobj_t tColorTable = buzzvm_stack_at(m_tBuzzVM, 1);
   buzzvm_tput(m_tBuzzVM);
   TablePut(tColorTable, "red", c_color.GetRed());
   TablePut(tColorTable, "green", c_color.GetGreen());
   TablePut(tColorTable, "blue", c_color.GetBlue());
   return m_tBuzzVM->state;   
}
コード例 #12
0
ファイル: BitmapColorKey.cpp プロジェクト: adan830/FKEngine
//--------------------------------------------------------------------
void FK2DEngine::UnApplyColorKey( CBitmap& p_Bitmap, CColor p_BackGround )
{
	CColor* p = p_Bitmap.Data();
	for( unsigned int i = p_Bitmap.Width() * p_Bitmap.Height(); i > 0; --i, ++p )
	{
		if( p->Alpha() == 0 )
		{
			*p = p_BackGround;
		}
		else
		{
			p->SetAlpha( 255 );
		}
	}
}
コード例 #13
0
 void CQTOpenGLUserFunctions::DrawText(const std::string& str_text,
                                       const CVector3& c_center_offset,
                                       const CColor& c_color) {
    glDisable(GL_LIGHTING);
    glDisable(GL_CULL_FACE);
    glColor3ub(c_color.GetRed(),
               c_color.GetGreen(),
               c_color.GetBlue());
    GetOpenGLWidget().renderText(c_center_offset.GetX(),
                                 c_center_offset.GetY(),
                                 c_center_offset.GetZ(),
                                 str_text.c_str());
    glEnable(GL_CULL_FACE);
    glEnable(GL_LIGHTING);
 }
コード例 #14
0
   void CQTOpenGLUserFunctions::DrawPoint(const CVector3& c_position,
                                          const CColor& c_color,
                                          const Real f_point_diameter) {
      glDisable(GL_LIGHTING);
      glColor3ub(c_color.GetRed(),
                 c_color.GetGreen(),
                 c_color.GetBlue());
      glPointSize(f_point_diameter);
      glBegin(GL_POINTS);
      glVertex3f(c_position.GetX(), c_position.GetY(), c_position.GetZ());
      glEnd();
      glPointSize(1.0);
      glEnable(GL_LIGHTING);

   }
コード例 #15
0
   void CQTOpenGLUserFunctions::DrawTriangle(const CVector3& c_center_offset,
                                             const CColor& c_color,
                                             const bool b_fill,
                                             const CQuaternion& c_orientation,
                                             Real f_base,
                                             Real f_height) {

	    glDisable(GL_LIGHTING);
	    glDisable(GL_CULL_FACE);

	    glColor3ub(c_color.GetRed(),
                 c_color.GetGreen(),
                 c_color.GetBlue());

      if(b_fill) {
         glBegin(GL_POLYGON);
      }
      else {
         glBegin(GL_LINE_LOOP);
      }
      CVector3 cNormalDirection(0.0f, 0.0f, 1.0f);
      cNormalDirection.Rotate(c_orientation);
      glNormal3f(cNormalDirection.GetX(),
                 cNormalDirection.GetY(),
                 cNormalDirection.GetZ());

      CVector3 cVertex(f_height * 0.5f, 0.0f, 0.0f);
      cVertex.Rotate(c_orientation);
      glVertex3f(cVertex.GetX() + c_center_offset.GetX(),
                 cVertex.GetY() + c_center_offset.GetY(),
                 cVertex.GetZ() + c_center_offset.GetZ());

      cVertex.Set(-f_height * 0.5f, f_base * 0.5f, 0.0f);
      cVertex.Rotate(c_orientation);
      glVertex3f(cVertex.GetX() + c_center_offset.GetX(),
                 cVertex.GetY() + c_center_offset.GetY(),
                 cVertex.GetZ() + c_center_offset.GetZ());

      cVertex.Set(-f_height * 0.5f, -f_base * 0.5f, 0.0f);
      cVertex.Rotate(c_orientation);
      glVertex3f(cVertex.GetX() + c_center_offset.GetX(),
                 cVertex.GetY() + c_center_offset.GetY(),
                 cVertex.GetZ() + c_center_offset.GetZ());
      glEnd();

      glEnable(GL_CULL_FACE);
      glEnable(GL_LIGHTING);
   }
コード例 #16
0
void TerrainOverlay::RenderTileOutline(const CColor& colour, int line_width, bool draw_hidden, ssize_t i, ssize_t j)
{
	if (draw_hidden)
	{
		glDisable(GL_DEPTH_TEST);
		glDisable(GL_CULL_FACE);
	}
	else
	{
		glEnable(GL_DEPTH_TEST);
		glEnable(GL_CULL_FACE);
	}

	glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

	if (line_width != 1)
		glLineWidth((float)line_width);

	CVector3D pos;
	glBegin(GL_QUADS);
		glColor4fv(colour.FloatArray());
		m_Terrain->CalcPosition(i,   j,   pos); glVertex3fv(pos.GetFloatArray());
		m_Terrain->CalcPosition(i+1, j,   pos); glVertex3fv(pos.GetFloatArray());
		m_Terrain->CalcPosition(i+1, j+1, pos); glVertex3fv(pos.GetFloatArray());
		m_Terrain->CalcPosition(i,   j+1, pos); glVertex3fv(pos.GetFloatArray());
	glEnd();

	if (line_width != 1)
		glLineWidth(1.0f);
}
コード例 #17
0
   void CQTOpenGLUserFunctions::DrawCircle(Real f_radius,
                                           const CVector3& c_center_offset,
                                           const CColor& c_color,
                                           const bool b_fill,
                                           const CQuaternion& c_orientation,
                                           GLuint un_vertices) {

	    glDisable(GL_LIGHTING);
	    glDisable(GL_CULL_FACE);

	    glColor3ub(c_color.GetRed(),
                 c_color.GetGreen(),
                 c_color.GetBlue());

	    CVector3 cVertex(f_radius, 0.0f, 0.0f);
	    CRadians cAngle(CRadians::TWO_PI / un_vertices);

      if(b_fill) {
         glBegin(GL_POLYGON);
      }
      else {
         glBegin(GL_LINE_LOOP);
      }
      CVector3 cNormalDirection(0.0f, 0.0f, 1.0f);
      cNormalDirection.Rotate(c_orientation);
      glNormal3f(cNormalDirection.GetX(),
                 cNormalDirection.GetY(),
                 cNormalDirection.GetZ());

      /* Compute the quaternion defining the rotation of the vertices used to draw the circle. */
      CQuaternion cVertexRotation;
      CVector3 cVertexRotationAxis(0.0f, 0.0f, 1.0f);
      cVertexRotationAxis.Rotate(c_orientation);
      cVertexRotation.FromAngleAxis(cAngle, cVertexRotationAxis);

	    cVertex.Rotate(c_orientation);
      for(GLuint i = 0; i <= un_vertices; i++) {
         glVertex3f(cVertex.GetX() + c_center_offset.GetX(),
                    cVertex.GetY() + c_center_offset.GetY(),
                    cVertex.GetZ() + c_center_offset.GetZ());
         cVertex.Rotate(cVertexRotation);
      }
      glEnd();

      glEnable(GL_CULL_FACE);
      glEnable(GL_LIGHTING);
   }
コード例 #18
0
ファイル: GUIutil.cpp プロジェクト: Rektosauros/0ad
bool __ParseString<CColor>(const CStrW& Value, CColor& Output)
{
	// First, check our database in g_GUI for pre-defined colors
	// If it fails, it won't do anything with Output
	if (g_GUI->GetPreDefinedColor(Value.ToUTF8(), Output))
		return true;

	return Output.ParseString(Value.ToUTF8());
}
コード例 #19
0
ファイル: GUIutil.cpp プロジェクト: Rektosauros/0ad
bool GUI<int>::ParseColor(const CStrW& Value, CColor& Output, int DefaultAlpha)
{
	// First, check our database in g_GUI for pre-defined colors
	//  If we find anything, we'll ignore DefaultAlpha
	// If it fails, it won't do anything with Output
	if (g_GUI->GetPreDefinedColor(Value.ToUTF8(), Output))
		return true;

	return Output.ParseString(Value.ToUTF8(), DefaultAlpha);
}
コード例 #20
0
bool CTexture::FillTextureWithColor (unsigned int width, unsigned int height, const CColor& color)
{
  if (m_Texture==NULL)
  {
    LOGGER->AddNewLog(ELL_ERROR,"CTexture::FillTextureWithColor-> m_Texture no ha sido creado aun ");
    return false;
  }

  HRESULT hr;
  D3DLOCKED_RECT lock;
  hr=m_Texture->LockRect(0, &lock, NULL, D3DLOCK_DISCARD);
  if(hr==D3D_OK)
  {
    uint8 *pTxtBuffer; // Bitmap buffer, texture buffer
    pTxtBuffer = (uint8*)lock.pBits;

		
    uint32 j = 0;
    for( uint32 cont = 0; cont< width * height; cont++)
    {
      //BLUE
      pTxtBuffer[cont*4 + 0] = (uint8)(color.GetBlue()*255);
      //GREEN
      pTxtBuffer[cont*4 + 1] = (uint8)(color.GetGreen()*255);
      //RED
      pTxtBuffer[cont*4 + 2] = (uint8)(color.GetRed()*255);
      //ALPHA
      pTxtBuffer[cont*4 + 3] = (uint8)(color.GetAlpha()*255);
    }
    hr=m_Texture->UnlockRect(0);
  }
  else
  {
    LOGGER->AddNewLog(ELL_ERROR,"CTexture::FillTextureWithColor->Error en la llamada lockRect");
    return false;
  }

	m_Width	= width;
	m_Height	= height;

  return true;
}
コード例 #21
0
void BoxObject::load ( trObjectParserBlock &parserBlock )
{
	depthWrites = true;
	// scan elements
	tvStringPairList::iterator itr = parserBlock.elements.begin();

	std::string grimeTexture;
	float				grimeZ = 1;
	while (  itr != parserBlock.elements.end() )
	{
		if ( !basicElement(*itr) )
		{
			std::string tag = string_util::toupper(itr->first);

			if ( tag == "COLOR" )
				color.parseColor(itr->second);
			if ( tag == "DEPTHWRITE" )
				depthWrites = atoi(itr->second.c_str()) != 0;
			if ( tag == "NOTOP" )
				noTop = atoi(itr->second.c_str()) != 0;
			if ( tag == "GRIMETEXTURE" )
				grimeTexture = itr->second.c_str();
			if ( tag == "GRIMEZ" )
				grimeZ = (float)atof(itr->second.c_str());
		}
		itr++;
	}

	glList = DisplayListManager::instance().newList(this);

	if ( grimeTexture.size() )
	{
		// we need to make a child grim object
		// we copy the elements so it gets all the same stuff
		// but we DON'T do the sub blocks
		trObjectParserBlock	miniBlock;
		miniBlock.name = parserBlock.name;
		miniBlock.elements.push_back(tpStringPair(std::string("SIZE"),string_util::format("%f,%f,%f",size.X(),size.Y(),grimeZ*0.5f)));

		float localCenter = -(size.Z()-grimeZ/2.0f);
		miniBlock.elements.push_back(tpStringPair(std::string("POSITION"),string_util::format("%f,%f,%f",0.0f,0.0f,localCenter)));
		miniBlock.elements.push_back(tpStringPair(std::string("DEPTHWRITE"),std::string("0")));
		miniBlock.elements.push_back(tpStringPair(std::string("NOTOP"),std::string("1")));
		miniBlock.elements.push_back(tpStringPair(std::string("TEXTURE"),grimeTexture));
	
		C3DVertex uvScale(1,1,1);
		if ((int)uvScales.size())
			uvScale = uvScales[(int)uvScales.size()-1];
		miniBlock.elements.push_back(tpStringPair(std::string("UVSCALE"),string_util::format("%f,%f,%f",uvScale.X(),uvScale.Y(),uvScale.Z()*(grimeZ/size.Z()))));

		world->AddObject("BOX",miniBlock,this);
	}
	MapBaseObject::load(parserBlock);
}
コード例 #22
0
   void CQTOpenGLUserFunctions::DrawSegment(const CVector3& c_end_point,
                                            const CVector3& c_start_point,
                                            const CColor& c_segment_color,
                                            const Real& f_line_width,
                                            bool b_draw_end_point,
                                            bool b_draw_start_point,
                                            const CColor& c_end_point_color,
                                            const CColor& c_start_point_color) {

      /* Draw the segment */

      glDisable(GL_LIGHTING);
      glColor3ub(c_segment_color.GetRed(),
                 c_segment_color.GetGreen(),
                 c_segment_color.GetBlue());

      glEnable (GL_LINE_SMOOTH);
      glLineWidth(f_line_width);

      glBegin(GL_LINES);
      glVertex3f(c_start_point.GetX(),
                 c_start_point.GetY(),
                 c_start_point.GetZ() );
      glVertex3f(c_end_point.GetX(),
                 c_end_point.GetY(),
                 c_end_point.GetZ() );
      glEnd();

      /* Draw the end and start points if necessary */

      if(b_draw_end_point) {
         DrawPoint(c_end_point, c_end_point_color, 5.0);
      }

      if(b_draw_start_point) {
         DrawPoint(c_start_point, c_start_point_color, 5.0);
      }

      glPointSize(1.0);
      glEnable(GL_LIGHTING);
   }
コード例 #23
0
ファイル: CGUI.cpp プロジェクト: 2asoft/0ad
void CGUI::Xeromyces_ReadColor(XMBElement Element, CXeromyces* pFile)
{
	XMBAttributeList attributes = Element.GetAttributes();

	CColor color;
	CStr name = attributes.GetNamedItem(pFile->GetAttributeID("name"));

	// Try parsing value
	CStr value(Element.GetText());
	if (value.empty())
		return;

	// Try setting color to value
	if (!color.ParseString(value))
	{
		LOGERROR("GUI: Unable to create custom color '%s'. Invalid color syntax.", name.c_str());
		return;
	}

	m_PreDefinedColors[name] = color;
}
コード例 #24
0
 virtual void SaveAsImage(const std::string& str_path) {
    fipImage cImage(FIT_BITMAP, m_unPixelsPerMeter * m_cHalfArenaSize.GetX()*2, m_unPixelsPerMeter * m_cHalfArenaSize.GetY()*2, 24);
    Real fFactor = 1.0f / static_cast<Real>(m_unPixelsPerMeter);
    CVector2 cFloorPos;
    CColor cARGoSPixel;
    RGBQUAD tFIPPixel;
    for(UInt32 y = 0; y < cImage.getHeight(); ++y) {
       for(UInt32 x = 0; x < cImage.getWidth(); ++x) {
          cFloorPos.Set(x * fFactor, y * fFactor);
          cFloorPos -= m_cHalfArenaSize;
          cARGoSPixel = m_cLoopFunctions.GetFloorColor(cFloorPos);
          tFIPPixel.rgbRed = cARGoSPixel.GetRed();
          tFIPPixel.rgbGreen = cARGoSPixel.GetGreen();
          tFIPPixel.rgbBlue = cARGoSPixel.GetBlue();
          cImage.setPixelColor(x, y, &tFIPPixel);
       }
    }
    if(!cImage.save(str_path.c_str())) {
       THROW_ARGOSEXCEPTION("Cannot save image \"" << str_path << "\" for floor entity.");
    }
 }
コード例 #25
0
 void CQTOpenGLUserFunctions::DrawText(const CVector3& c_position,
                                       const std::string& str_text,
                                       const CColor& c_color) {
    /* Save attributes */
    glPushAttrib(GL_ENABLE_BIT);
    /* Disable lighting to make text color unaffected by light */
    glDisable(GL_LIGHTING);
    /* Disable culling to make text visibile from any angle */
    glDisable(GL_CULL_FACE);
    /* Set color */
    glColor3ub(c_color.GetRed(),
               c_color.GetGreen(),
               c_color.GetBlue());
    GetMainWindow().
       GetOpenGLWidget().
       renderText(c_position.GetX(),
                  c_position.GetY(),
                  c_position.GetZ(),
                  str_text.c_str());
    /* Restore saved attributes */
    glPopAttrib();
 }
コード例 #26
0
ファイル: TerrainOverlay.cpp プロジェクト: TiriliPiitPiit/0ad
void TerrainOverlay::RenderTile(const CColor& colour, bool draw_hidden, ssize_t i, ssize_t j)
{
	// TODO: if this is unpleasantly slow, make it much more efficient
	// (e.g. buffering data and making a single draw call? or at least
	// far fewer calls than it makes now)

	if (draw_hidden)
	{
		glDisable(GL_DEPTH_TEST);
		glDisable(GL_CULL_FACE);
	}
	else
	{
		glEnable(GL_DEPTH_TEST);
		glEnable(GL_CULL_FACE);
	}
	
#if CONFIG2_GLES
#warning TODO: implement TerrainOverlay::RenderTile for GLES
#else

	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

	CVector3D pos;
	glBegin(GL_TRIANGLES);
		glColor4fv(colour.FloatArray());
		if (m_Terrain->GetTriangulationDir(i, j))
		{
			m_Terrain->CalcPosition(i,   j,   pos); glVertex3fv(pos.GetFloatArray());
			m_Terrain->CalcPosition(i+1, j,   pos); glVertex3fv(pos.GetFloatArray());
			m_Terrain->CalcPosition(i,   j+1, pos); glVertex3fv(pos.GetFloatArray());

			m_Terrain->CalcPosition(i+1, j,   pos); glVertex3fv(pos.GetFloatArray());
			m_Terrain->CalcPosition(i+1, j+1, pos); glVertex3fv(pos.GetFloatArray());
			m_Terrain->CalcPosition(i,   j+1, pos); glVertex3fv(pos.GetFloatArray());
		}
		else
		{
			m_Terrain->CalcPosition(i,   j,   pos); glVertex3fv(pos.GetFloatArray());
			m_Terrain->CalcPosition(i+1, j,   pos); glVertex3fv(pos.GetFloatArray());
			m_Terrain->CalcPosition(i+1, j+1, pos); glVertex3fv(pos.GetFloatArray());

			m_Terrain->CalcPosition(i+1, j+1, pos); glVertex3fv(pos.GetFloatArray());
			m_Terrain->CalcPosition(i,   j+1, pos); glVertex3fv(pos.GetFloatArray());
			m_Terrain->CalcPosition(i,   j,   pos); glVertex3fv(pos.GetFloatArray());
		}
	glEnd();

#endif
}
コード例 #27
0
ファイル: colordifference.C プロジェクト: anilkunwar/OOF2
bool DeltaRGB::contains(const CColor &c1, const CColor &c2) const {
  double rdiff = fabs(c1.getRed()-c2.getRed());
  double gdiff = fabs(c1.getGreen()-c2.getGreen());
  double bdiff = fabs(c1.getBlue()-c2.getBlue());
  
  if (rdiff <= delta_red && gdiff <= delta_green && bdiff <= delta_blue)
    return true;
  return false;
}
コード例 #28
0
   void CQTOpenGLUserFunctions::DrawPolygon(const std::vector<CVector3>& vec_points,
                                            const CColor& c_color) {
      if (vec_points.size() > 2)
      {
         glDisable(GL_LIGHTING);
         glDisable(GL_CULL_FACE);

         glColor3ub(c_color.GetRed(),
                    c_color.GetGreen(),
                    c_color.GetBlue());

         glBegin(GL_POLYGON);
         for (UInt32 i = 0; i < vec_points.size(); ++i)
         {
            glVertex3f(vec_points[i].GetX(),
                       vec_points[i].GetY(),
                       vec_points[i].GetZ());
         }
         glEnd();

         glEnable(GL_CULL_FACE);
         glEnable(GL_LIGHTING);
      }
   }
コード例 #29
0
ファイル: ccolor.cpp プロジェクト: DaniM/lyngo
__attribute__((__constructor__)) void testHSVtoRGBAndBack ()
{
	CColor color (10, 10, 255, 255);
	CColor color2 = color;
	double h,s,v;
	color.toHSV (h,s,v);
	double th,ts,tv;
	for (double i = 0; i < 360; i+= 0.01)
	{
		color.fromHSV (i, s, v);
		color.toHSV (th, ts, tv);
		color2.fromHSV (th, ts, tv);
		if (color != color2)
		{
			DebugPrint ("issue\n");
		}
		color.toHSL (th, ts, tv);
		color2.fromHSL (th, ts, tv);
		if (color != color2)
		{
			DebugPrint ("issue\n");
		}
	}
	for (double i = 0.; i < 1.; i += 0.0001)
	{
		color.fromHSV (h, i, v);
		color.toHSV (th, ts, tv);
		color2.fromHSV (th, ts, tv);
		if (color != color2)
		{
			DebugPrint ("issue\n");
		}
		color.fromHSV (h, s, i);
		color.toHSV (th, ts, tv);
		color2.fromHSV (th, ts, tv);
		if (color != color2)
		{
			DebugPrint ("issue\n");
		}
	}
}
コード例 #30
0
void DX9SpriteBatch::Draw(
	ITextureBase *Texture2D, CRectangle &PositionInTexture, 
	Vector2I &Origin, Vector2F &Position, 
	float Rotation, Vector2F &Scale, CColor &Color, 
	float ZOrder, eSpriteEffects SpriteEffect )
{
	CDX9Texture *tex = dynamic_cast<CDX9Texture *>(Texture2D);
	RECT src;
	src.left = PositionInTexture.Left();
	src.right = PositionInTexture.Right();
	src.top = PositionInTexture.Top();
	src.bottom = PositionInTexture.Bottom();
	D3DXVECTOR2 center(static_cast<float>(Origin.x), static_cast<float>(Origin.y));
	D3DXVECTOR2 pos(Position.x - Origin.x, Position.y - Origin.y);

	D3DXMATRIX transform;
	DXCheck(D3DXMatrixTransformation2D(&transform, NULL, NULL, &D3DXVECTOR2(Scale.x, Scale.y), &center, Rotation, &pos));

	if (SUCCEEDED(DXCheck(m_D3DSprite->SetTransform(&transform))))
	{
		DXCheck(m_D3DSprite->Draw( tex->GetDxTexture(), &src, NULL, NULL,
				D3DCOLOR_RGBA(Color.GetRed(), Color.GetGreen(), Color.GetBlue(), Color.GetAlpha()) ));
	}	
}