Exemplo n.º 1
0
// Test that flipping the Y component works correctly
TEST_P(CopyTextureTest, FlipY)
{
    if (!checkExtensions())
    {
        return;
    }

    GLColor rgbaPixels[4] = {GLColor(255u, 255u, 255u, 255u), GLColor(127u, 127u, 127u, 127u),
                             GLColor(63u, 63u, 63u, 127u), GLColor(255u, 255u, 255u, 0u)};

    glBindTexture(GL_TEXTURE_2D, mTextures[0]);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbaPixels);

    glCopyTextureCHROMIUM(mTextures[0], mTextures[1], GL_RGBA, GL_UNSIGNED_BYTE, GL_TRUE, GL_FALSE,
                          GL_FALSE);
    EXPECT_GL_NO_ERROR();

    // Check that FB is complete.
    EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));

    EXPECT_PIXEL_COLOR_EQ(0, 0, rgbaPixels[2]);
    EXPECT_PIXEL_COLOR_EQ(1, 0, rgbaPixels[3]);
    EXPECT_PIXEL_COLOR_EQ(0, 1, rgbaPixels[0]);
    EXPECT_PIXEL_COLOR_EQ(1, 1, rgbaPixels[1]);
    EXPECT_GL_NO_ERROR();
}
Exemplo n.º 2
0
namespace angle
{

const GLColor GLColor::red   = GLColor(255u, 0u, 0u, 255u);
const GLColor GLColor::green = GLColor(0u, 255u, 0u, 255u);
const GLColor GLColor::blue  = GLColor(0u, 0u, 255u, 255u);
const GLColor GLColor::cyan  = GLColor(0u, 255u, 255u, 255u);
const GLColor GLColor::black = GLColor(0u, 0u, 0u, 255u);

namespace
{
float ColorNorm(GLubyte channelValue)
{
    return static_cast<float>(channelValue) / 255.0f;
}
}  // anonymous namespace

GLColor::GLColor() : R(0), G(0), B(0), A(0)
{
}

GLColor::GLColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a) : R(r), G(g), B(b), A(a)
{
}

GLColor::GLColor(GLuint colorValue) : R(0), G(0), B(0), A(0)
{
    memcpy(&R, &colorValue, sizeof(GLuint));
}

Vector4 GLColor::toNormalizedVector() const
{
    return Vector4(ColorNorm(R), ColorNorm(G), ColorNorm(B), ColorNorm(A));
}

GLColor ReadColor(GLint x, GLint y)
{
    GLColor actual;
    glReadPixels((x), (y), 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &actual.R);
    EXPECT_GL_NO_ERROR();
    return actual;
}

bool operator==(const GLColor &a, const GLColor &b)
{
    return a.R == b.R && a.G == b.G && a.B == b.B && a.A == b.A;
}

std::ostream &operator<<(std::ostream &ostream, const GLColor &color)
{
    ostream << "(" << static_cast<unsigned int>(color.R) << ", "
            << static_cast<unsigned int>(color.G) << ", " << static_cast<unsigned int>(color.B)
            << ", " << static_cast<unsigned int>(color.A) << ")";
    return ostream;
}

}  // namespace angle
Exemplo n.º 3
0
void InstrumentRenderer::resetColors() {
  auto sharedWorkspace = m_actor.getWorkspace();
  const double vmin(m_actor.minValue()), vmax(m_actor.maxValue());
  // Reset all colors to 0 and resize m_colors to the appropriate size
  const auto zero = m_colorMap.rgb(vmin, vmax, 0);
  const auto &compInfo = m_actor.componentInfo();
  m_colors.assign(compInfo.size(),
                  GLColor(qRed(zero), qGreen(zero), qBlue(zero), 1));
  // No data/masked colors
  static const auto invalidColor = GLColor(80, 80, 80, 1);
  static const auto maskedColor = GLColor(100, 100, 100, 1);

  // Compute required colors for the detectors in a single shot to avoid
  // repeated calls to python and back in the matplotlib-based implementation
  const auto &detInfo = m_actor.detectorInfo();
  std::vector<double> counts(detInfo.size());
  for (size_t det = 0; det < detInfo.size(); ++det) {
    counts[det] = m_actor.getIntegratedCounts(det);
  }
  auto rgba = m_colorMap.rgb(vmin, vmax, counts);

  // Now apply colors taking into account detectors with bad counts and detector
  // masking
  Mantid::API::IMaskWorkspace_sptr maskWS = m_actor.getMaskWorkspaceIfExists();
  const auto &detectorIDs = detInfo.detectorIDs();
  // Defines a mask checker lambda dependent on if we have a mask workspace or
  // not. Done once outside the loop to avoid repeated if branches in the loop
  std::function<bool(size_t)> isMasked;
  if (maskWS) {
    isMasked = [&detInfo, &detectorIDs, &maskWS](size_t index) {
      return maskWS->isMasked(detectorIDs[index]) || detInfo.isMasked(index);
    };
  } else {
    isMasked = [&detInfo](size_t index) { return detInfo.isMasked(index); };
  }
  for (size_t det = 0; det < counts.size(); ++det) {
    if (!isMasked(det)) {
      const double integratedValue(counts[det]);
      if (integratedValue > -1) {
        const auto &color = rgba[det];
        m_colors[det] =
            GLColor(qRed(color), qGreen(color), qBlue(color),
                    static_cast<int>(255 * (integratedValue / vmax)));
      } else
        m_colors[det] = invalidColor;
    } else {
      m_colors[det] = maskedColor;
    }
  }
  // finish off rest of the components with the mask color
  for (const auto comp : m_actor.components())
    m_colors[comp] = maskedColor;
}
Exemplo n.º 4
0
void GLLight::SetParams( GLfloat* ambient, GLfloat* diffuse, GLfloat* specular, GLfloat* position )
{
	ambient_  = GLColor   ( ambient [ 0 ], ambient [ 1 ], ambient [ 2 ], ambient [ 3 ] );
	diffuse_  = GLColor   ( diffuse [ 0 ], diffuse [ 1 ], diffuse [ 2 ], diffuse [ 3 ] );
	specular_ = GLColor   ( specular[ 0 ], specular[ 1 ], specular[ 2 ], specular[ 3 ] );
	position_ = GLPosition( position[ 0 ], position[ 1 ], position[ 2 ], position[ 3 ] );

	glLightfv( lightNum_, GL_AMBIENT , ambient_ .pointer() );
	glLightfv( lightNum_, GL_DIFFUSE , diffuse_ .pointer() );
	glLightfv( lightNum_, GL_SPECULAR, specular_.pointer() );
	glLightfv( lightNum_, GL_POSITION, position_.pointer() );
}
Exemplo n.º 5
0
ListMenuStyle::ListMenuStyle() :
    _background(GLColor(0xFF000000)),
    _shadow(GLColor(0xF7FFFFFF)),
    _header_text(0xFF9FFFFF),
    _paint_first_line(false),
    _paint_last_line(false),

    _list_r(0, 0, 230, 300),
    _size(10, 60, 230, 300)
{


}
Exemplo n.º 6
0
GLColor InstrumentRenderer::makePickColor(size_t pickID) {
  pickID += 1;
  unsigned char r, g, b;
  r = static_cast<unsigned char>(pickID / 65536);
  g = static_cast<unsigned char>((pickID % 65536) / 256);
  b = static_cast<unsigned char>((pickID % 65536) % 256);
  return GLColor(r, g, b);
}
Exemplo n.º 7
0
void skelpath::draw3dNurbs(){

	//draw 3d nurbs using member variable"disNurbsss3d"
	if( disNurbsss3d.size() > 0){

		for( int i=0; i<disNurbsss3d[0].size(); ++i )
			if( i != activeTmpId )
				GlobalFun::draw3dCurves(std::vector<Curve3D>(1,disNurbsss3d[0][i]) , GLColor( 0.8,0, 0, 1), true, false, ReconstructorPara::nurbsDisplaySize ) ;

	}

}
Exemplo n.º 8
0
Explosion::Explosion(void)
{
	if(!initialised_)
	{
		InitialiseGraphics();
		initialised_ = true;
	}
	fill_.GetFillVerts() = Datastore::Instance().GetVerts(fill_verts_index_);
	fill_.SetDisplayList(fill_dl_);

	if(Random::RandomChance(0.2f))
	{
		fill_.SetFillColor(GLColor(255, 255, 0));
	}
	else
	{
		fill_.SetFillColor(GLColor(255, static_cast<unsigned char>(Random::RandomQuantity(20,120)), static_cast<unsigned char>(Random::RandomQuantity(0,20))));
	}

	lifetime_ = ExplosionLifetime;
	ltv_transform_ = Matrix4f::createScale(0);
}
Exemplo n.º 9
0
GLVector * GLVector::fromXml(const QDomElement &object)
{

    if (object.isNull() || object.attribute("type","") != "vector")
        return NULL;

    QString id = object.attribute("id","");

    GLdouble sx = 0.0;
    GLdouble sy = 0.0;
    GLdouble sz = 0.0;

    GLdouble ex = 0.0;
    GLdouble ey = 0.0;
    GLdouble ez = 0.0;

    QDomNodeList points = object.elementsByTagName("point");
    if (points.count() == 2)
    {
        QDomElement point = points.at(0).toElement();
        sx = point.attribute("x","0").toDouble();
        sy = point.attribute("y","0").toDouble();
        sz = point.attribute("z","0").toDouble();
        point = points.at(1).toElement();
        ex = point.attribute("x","0").toDouble();
        ey = point.attribute("y","0").toDouble();
        ez = point.attribute("z","0").toDouble();
    }

    uchar r=0,g=0,b=0,a=255;

    QDomNodeList colors = object.elementsByTagName("color");
    if (!colors.isEmpty())
    {
        QDomElement colorNode = colors.at(0).toElement();
        r = (uchar)colorNode.attribute("r","0").toUShort(NULL, 16);
        g = (uchar)colorNode.attribute("g","0").toUShort(NULL, 16);
        b = (uchar)colorNode.attribute("b","0").toUShort(NULL, 16);
        a = (uchar)colorNode.attribute("a","ff").toUShort(NULL, 16);
    }

    int time = 0;
    QDomNodeList times = object.elementsByTagName("time");
    if (!times.isEmpty())
    {
        QDomElement timeNode = times.at(0).toElement();
        time = timeNode.text().toInt();
    }

    return new GLVector(sx,sy,sz,ex,ey,ez,GLColor(r,g,b,a),id,time);
}
Exemplo n.º 10
0
BeamCharge::BeamCharge(void)
{
	if(!initialised_)
	{
		InitialiseGraphics();
		initialised_ = true;
	}
	fill_.GetFillVerts() = Datastore::Instance().GetVerts(fill_verts_index_);
	fill_.SetDisplayList(fill_dl_);
	fill_.SetFillColor(GLColor(255, 255, 255));
	lifetime_ = 1;
	ltv_transform_ = Matrix4f::createScale(0);
	angle_ = Random::RandomRange(0,360);
}
Exemplo n.º 11
0
Sparks::Sparks(void)
{
	if(!initialised_)
	{
		InitialiseGraphics();
		initialised_ = true;
	}
	fill_.GetFillVerts() = Datastore::Instance().GetVerts(fill_verts_index_);
	fill_.SetDisplayList(fill_dl_);
	fill_.SetFillColor(GLColor(255, static_cast<unsigned char>(Random::RandomRange(200,255)), static_cast<unsigned char>(Random::RandomRange(200,255))));

	lifetime_ = SPARKS_LIFETIME;
	ltv_transform_ = Matrix4f::createScale(0);
}
Exemplo n.º 12
0
void LabelDecoration::Tick(float _timespan, Matrix4f _transform, std::vector<Decoration_ptr>& _decoration_spawn)
{
	if(source_!=NULL)
	{
		source_location_ = source_->GetGlobalPosition();
	}
	else
	{
		if(lifetime_ > 1.0f)
			lifetime_ = 1.0f;
	}

	float alpha = 0;
	if(full_lifetime_ - lifetime_ < 0.1f)
	{
		alpha = (full_lifetime_ - lifetime_) / 0.1f;
	}else if(lifetime_ < 1.0f && lifetime_ > 0.0f)
	{
		alpha = lifetime_;
	} else if(lifetime_ < 0.0f)
	{
		alpha = 0.0f;
	} else
	{
		alpha = 1.0f;
	}
	fill_.SetFillColor(GLColor(255, 255, 255, alpha));

	SetPosition(Camera::Instance().ScreenToWorld(screen_position_));
	Decoration::Tick(_timespan, _transform, _decoration_spawn);

	for(std::vector<Billboard*>::iterator it = labels_.begin(); it != labels_.end(); ++it)
	{
		(*it)->SetColor(GLColor(255, 255, 255, alpha));
	}
}
Exemplo n.º 13
0
PhotonPulse::PhotonPulse(Vector3f _position)
:Projectile()
{
	if(!initialised_)
	{
		InitialiseGraphics();
		initialised_ = true;
	}
	fill_.GetFillVerts() = Datastore::Instance().GetVerts(fill_verts_index_);
	fill_.SetDisplayList(fill_dl_);
	fill_.SetFillColor(GLColor(150, 159, 255));
	damage_ = 45;
	lifetime_ = 3.0;
	velocity_.y = 750;
	position_ = _position;
	mass_ = 0;
}
Exemplo n.º 14
0
PlasmaRound::PlasmaRound(Vector3f _position)
:Projectile()
{
	if(!initialised_)
	{
		InitialiseGraphics();
		initialised_ = true;
	}
	fill_.GetFillVerts() = Datastore::Instance().GetVerts(fill_verts_index_);
	fill_.SetDisplayList(fill_dl_);
	fill_.SetFillColor(GLColor(255, 255, 255));
	damage_ = 45.0;
	lifetime_ = 4.0;
	velocity_.y = 450;
	position_ = _position;
	mass_ = 25;
}
Exemplo n.º 15
0
GLPoint * GLPoint::fromXml(const QDomElement &object)
{
    if (object.isNull() || object.attribute("type","") != "point")
        return NULL;

    QString id = object.attribute("id","");

    GLdouble x = 0.0;
    GLdouble y = 0.0;
    GLdouble z = 0.0;

    QDomNodeList points = object.elementsByTagName("point");
    if (!points.isEmpty())
    {
        QDomElement point = points.at(0).toElement();
        x = point.attribute("x","0").toDouble();
        y = point.attribute("y","0").toDouble();
        z = point.attribute("z","0").toDouble();
    }

    uchar r=0,g=0,b=0,a=255;

    QDomNodeList colors = object.elementsByTagName("color");
    if (!colors.isEmpty())
    {
        QDomElement colorNode = colors.at(0).toElement();
        r = (uchar)colorNode.attribute("r","0").toUShort(NULL, 16);
        g = (uchar)colorNode.attribute("g","0").toUShort(NULL, 16);
        b = (uchar)colorNode.attribute("b","0").toUShort(NULL, 16);
        a = (uchar)colorNode.attribute("a","ff").toUShort(NULL, 16);
    }

    int time = 0;
    QDomNodeList times = object.elementsByTagName("time");
    if (!times.isEmpty())
    {
        QDomElement timeNode = times.at(0).toElement();
        time = timeNode.text().toInt();
    }

    return new GLPoint(x,y,z, GLColor(r,g,b,a), id, time);
}
Exemplo n.º 16
0
SwarmMissile::SwarmMissile(Vector3f _position, BaseEntity* _target)
: HomingProjectile(_target)
{
	if(!initialised_)
	{
		 InitialiseGraphics();
		 initialised_ = true;
	}
	fill_.GetFillVerts() = Datastore::Instance().GetVerts(fill_verts_index_);
	fill_.SetDisplayList(fill_dl_);
	fill_.SetFillColor(GLColor(255,255,0));
	fill_.GetFillColor().a = 127;
	lifetime_ = 5;
	damage_ = 70;
	turn_rate_ = 150;
	scalar_speed_ = 200;
	velocity_.y = scalar_speed_;
	position_ = _position;
	mass_ = 25;
}
void FusionForeverWidget::DrawSection(Section_ptr section, std::string name, std::vector<std::pair<std::string, QPixmap*> >& icons)
{
	if(section)
	{
		float radius = section->GetRadius();
		
		Camera::Instance().SetSmallestDimension(40);

		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		Camera::Instance().SetupCamera();
		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();

		//Draw Section
		section->DeathTick();
		section->SetOutlineColor(GLColor(0,0,0));
		section->DrawSelf();
		
		glFlush();


		QImage icon = grabFrameBuffer();
		if(height() > width())
		{
			int top = (height() - width()) / 2;
			QImage icon2 = icon.copy(0, top, width(), width());
			QPixmap pm = QPixmap::fromImage(icon2);
			icons.push_back(std::pair<std::string, QPixmap*>(name, new QPixmap(pm.pixmapData())));
		} else
		{
			int left = (width() - height()) / 2;
			QImage icon2 = icon.copy(left, 0, height(), height());
			QPixmap pm = QPixmap::fromImage(icon2);
			icons.push_back(std::pair<std::string, QPixmap*>(name, new QPixmap(pm.pixmapData())));
		}

		delete section;
	}
}
Exemplo n.º 18
0
void StandardInputProcessor::Hover(int mx,int my)
{
  if(move) changed = true;
  useSpaceball = false;
  move = false;
  Ray3D ray;
  GetClickRay(mx, my, ray);
  
  int link;
  Vector3 localPos;
  RobotInfo* rob = world->ClickRobot( ray, link, localPos);
  Robot* robot = GetRobot();
  if (rob) {
    currentLink = link;
    currentPoint = localPos;
    currentDestination = robot->links[currentLink].T_World*localPos;
    rob->view.SetGrey();
    rob->view.SetColor(currentLink,GLColor(1, 1, 0));
  } else {
    world->robots[0].view.SetGrey();
    currentLink = -1;
  }
}
Exemplo n.º 19
0
wxImage ColorInfoData::UIImage(const ColorType type, const wxSize &size)
{
    wxASSERT((0 <= type) && (CR_SIZE > type));

    checkColors();

    //now fill it with the color requested
    wxColour color = UIColor(type);
    wxColour border = GLColor(type);

    // Create a transparent border so it's not just a blob of color.
    wxColour transparent = SKIN.Element(shIconTransparent);

    // The easiest way to do this is to just create a memory bitmap and draw
    // into it.
    wxBitmap bitmap(size.x, size.y);
    wxMemoryDC dc;
    dc.SelectObject(bitmap);

    // Transparent outline.
    dc.SetBrush(wxBrush(transparent));
    dc.SetPen(wxPen(transparent));
    dc.DrawRectangle(0, 0, size.x, size.y);

    // Border.
    dc.SetBrush(wxBrush(border));
    dc.SetPen(wxPen(border));
    dc.DrawRectangle(1, 1, size.x - 2, size.y - 2);

    // Color.
    dc.SetBrush(wxBrush(color));
    dc.SetPen(wxPen(color));
    dc.DrawRectangle(2, 2, size.x - 4, size.y - 4);

    dc.SelectObject(wxNullBitmap);
    return bitmap.ConvertToImage();
}
Exemplo n.º 20
0
void GLLight::SetSpecular( float r, float g, float b, float a )
{
	specular_ = GLColor( r, g, b, a );
	glLightfv( lightNum_, GL_SPECULAR, specular_.pointer() );
}
Exemplo n.º 21
0
Outlined::Outlined(void)
{
	outline_color_ = GLColor(255,255,255);
	outline_display_list_ = -1;
}
Exemplo n.º 22
0
namespace angle
{

const GLColorRGB GLColorRGB::black(0u, 0u, 0u);
const GLColorRGB GLColorRGB::blue(0u, 0u, 255u);
const GLColorRGB GLColorRGB::green(0u, 255u, 0u);
const GLColorRGB GLColorRGB::red(255u, 0u, 0u);
const GLColorRGB GLColorRGB::yellow(255u, 255u, 0);

const GLColor GLColor::black = GLColor(0u, 0u, 0u, 255u);
const GLColor GLColor::blue   = GLColor(0u, 0u, 255u, 255u);
const GLColor GLColor::cyan   = GLColor(0u, 255u, 255u, 255u);
const GLColor GLColor::green  = GLColor(0u, 255u, 0u, 255u);
const GLColor GLColor::red    = GLColor(255u, 0u, 0u, 255u);
const GLColor GLColor::yellow = GLColor(255u, 255u, 0, 255u);
const GLColor GLColor::white = GLColor(255u, 255u, 255u, 255u);

const GLColor16 GLColor16::white = GLColor16(65535u, 65535u, 65535u, 65535u);

namespace
{
float ColorNorm(GLubyte channelValue)
{
    return static_cast<float>(channelValue) / 255.0f;
}

GLubyte ColorDenorm(float colorValue)
{
    return static_cast<GLubyte>(colorValue * 255.0f);
}

// Use a custom ANGLE platform class to capture and report internal errors.
class TestPlatform : public angle::Platform
{
  public:
    TestPlatform() : mIgnoreMessages(false) {}

    void logError(const char *errorMessage) override;
    void logWarning(const char *warningMessage) override;
    void logInfo(const char *infoMessage) override;

    void ignoreMessages();
    void enableMessages();

  private:
    bool mIgnoreMessages;
};

void TestPlatform::logError(const char *errorMessage)
{
    if (mIgnoreMessages)
        return;

    FAIL() << errorMessage;
}

void TestPlatform::logWarning(const char *warningMessage)
{
    if (mIgnoreMessages)
        return;

    std::cerr << "Warning: " << warningMessage << std::endl;
}

void TestPlatform::logInfo(const char *infoMessage)
{
    if (mIgnoreMessages)
        return;

    angle::WriteDebugMessage("%s\n", infoMessage);
}

void TestPlatform::ignoreMessages()
{
    mIgnoreMessages = true;
}

void TestPlatform::enableMessages()
{
    mIgnoreMessages = false;
}

TestPlatform g_testPlatformInstance;

std::array<Vector3, 4> GetIndexedQuadVertices()
{
    std::array<Vector3, 4> vertices;
    vertices[0] = Vector3(-1.0f, 1.0f, 0.5f);
    vertices[1] = Vector3(-1.0f, -1.0f, 0.5f);
    vertices[2] = Vector3(1.0f, -1.0f, 0.5f);
    vertices[3] = Vector3(1.0f, 1.0f, 0.5f);
    return vertices;
}

}  // anonymous namespace

GLColorRGB::GLColorRGB() : R(0), G(0), B(0)
{
}

GLColorRGB::GLColorRGB(GLubyte r, GLubyte g, GLubyte b) : R(r), G(g), B(b)
{
}

GLColorRGB::GLColorRGB(const Vector3 &floatColor)
    : R(ColorDenorm(floatColor.x)), G(ColorDenorm(floatColor.y)), B(ColorDenorm(floatColor.z))
{
}

GLColor::GLColor() : R(0), G(0), B(0), A(0)
{
}

GLColor::GLColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a) : R(r), G(g), B(b), A(a)
{
}

GLColor::GLColor(const Vector4 &floatColor)
    : R(ColorDenorm(floatColor.x)),
      G(ColorDenorm(floatColor.y)),
      B(ColorDenorm(floatColor.z)),
      A(ColorDenorm(floatColor.w))
{
}

GLColor::GLColor(const GLColor16 &color16)
    : R(static_cast<GLubyte>(color16.R)),
      G(static_cast<GLubyte>(color16.G)),
      B(static_cast<GLubyte>(color16.B)),
      A(static_cast<GLubyte>(color16.A))
{
}

GLColor::GLColor(GLuint colorValue) : R(0), G(0), B(0), A(0)
{
    memcpy(&R, &colorValue, sizeof(GLuint));
}

Vector4 GLColor::toNormalizedVector() const
{
    return Vector4(ColorNorm(R), ColorNorm(G), ColorNorm(B), ColorNorm(A));
}

GLColor ReadColor(GLint x, GLint y)
{
    GLColor actual;
    glReadPixels((x), (y), 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &actual.R);
    EXPECT_GL_NO_ERROR();
    return actual;
}

bool operator==(const GLColor &a, const GLColor &b)
{
    return a.R == b.R && a.G == b.G && a.B == b.B && a.A == b.A;
}

std::ostream &operator<<(std::ostream &ostream, const GLColor &color)
{
    ostream << "(" << static_cast<unsigned int>(color.R) << ", "
            << static_cast<unsigned int>(color.G) << ", " << static_cast<unsigned int>(color.B)
            << ", " << static_cast<unsigned int>(color.A) << ")";
    return ostream;
}

GLColor16::GLColor16() : R(0), G(0), B(0), A(0)
{
}

GLColor16::GLColor16(GLushort r, GLushort g, GLushort b, GLushort a) : R(r), G(g), B(b), A(a)
{
}

GLColor16 ReadColor16(GLint x, GLint y)
{
    GLColor16 actual;
    glReadPixels((x), (y), 1, 1, GL_RGBA, GL_UNSIGNED_SHORT, &actual.R);
    EXPECT_GL_NO_ERROR();
    return actual;
}

bool operator==(const GLColor16 &a, const GLColor16 &b)
{
    return a.R == b.R && a.G == b.G && a.B == b.B && a.A == b.A;
}

std::ostream &operator<<(std::ostream &ostream, const GLColor16 &color)
{
    ostream << "(" << static_cast<unsigned int>(color.R) << ", "
            << static_cast<unsigned int>(color.G) << ", " << static_cast<unsigned int>(color.B)
            << ", " << static_cast<unsigned int>(color.A) << ")";
    return ostream;
}

}  // namespace angle
Exemplo n.º 23
0
ListMenuItemStyle::ListMenuItemStyle() :
    m_separator(0xFF332828),
    m_lineLongSelected(GLColor(0x4FFF00FF)),


    m_listText(0xFFFFFFFF),
    m_pressedText(0xFFFFFFFF),
    m_longPressedText(0xFFFFFFFF),

    m_inactiveText(0xffa3a3a3),
    m_inactivePressedText(0xffa3a3a3),
    m_inactiveLongPresedText(0xffa3a3a3),
    m_fontSize(24)
{
    m_lineSelected = Brush( [](Brush &, const Rect & rect) {

        unsigned short alpha = 0x30;
        for(int i=1; i<rect.h()/2; ++i, alpha += 4) {

            if(alpha >= 0xff) {
                alpha = 0xff;
            }

            GLColor c = ((unsigned char)alpha << 24) | 0x0000FF;
            glSetPen(c);
            glDrawHLine(rect.x(), rect.x2()-1, rect.y()+i);

        }

        for(int i=(const int)rect.h()/2; i<rect.h()-1; ++i, alpha -= 4) {
            if(alpha <= 0x20) {
                alpha = 0x20;
            }
            GLColor c =  ((unsigned char)alpha << 24) | 0x0000FF;
            glSetPen(c);
            glDrawHLine(rect.x(), rect.x2()-1, rect.y()+i);
        }
    });

    // Set the separator as gradient-line
    m_separator = Brush( [](Brush &, const Rect & rect) {
        /*const short alpha = 0xff;
        float colors = 255.0f;
        float r = rect.w() / 2;
        float sub_f = 255 / r + (r * 0.1f/100.0f);

        for(int i=r; i > 0; --i)
        {
            GLColor col = colors;
            GLColor c =  ((unsigned char)alpha << 24) | (col << 16) | (col << 8) | (col & 0xff);

            glActiveContext()->setColorPixel(glActiveContext(), rect.x()+i, rect.y(), c);

            colors -= sub_f;
            if(colors < 0)
                colors = 0;
        }


        colors = 0xff;
        for(int i=0; i < r; ++i)
        {
            GLColor col = colors;
            GLColor c =  ((unsigned char)alpha << 24) | (col << 16) | (col << 8) | (col & 0xff);

            glActiveContext()->setColorPixel(glActiveContext(), rect.x()+r+i, rect.y(), c);

            colors -= sub_f;
            if(colors < 0)
                colors = 0;
        }*/

            glSetPen(0x4FFFFFFF);
            glDrawHLine(rect.x()+4, rect.x2()-4, rect.y());

    });
}
Exemplo n.º 24
0
void CFont::SetColor(float iRed, float iGreen, float iBlue) {
	// Set color
	mColor = GLColor(iRed, iGreen, iBlue, 1.0);
}
Exemplo n.º 25
0
void GLLight::SetAmbient( float r, float g, float b, float a )
{
	ambient_ = GLColor( r, g, b, a );
	glLightfv( lightNum_, GL_AMBIENT, ambient_.pointer() );
}
Exemplo n.º 26
0
LabelDecoration::LabelDecoration(BaseEntity* _source, Vector3f _screen_position, float _lifetime)
{
	source_ = _source;
	assert(source_ != NULL);
	source_->AddSubscriber(this);
	source_location_ = source_->GetGlobalPosition();
	lifetime_ = _lifetime;
	full_lifetime_ = _lifetime;
	fill_.SetFillColor(GLColor(255, 255, 255));

	Section_ptr section = (Section_ptr)_source;
	Vector3f screen_position = _screen_position;
	Vector3f icon_spacing(25, 0, 0);
	if(screen_position.x > Camera::Instance().GetWidth() * 0.1f)
		icon_spacing.x *= -1;
	bool interesting = false;

	std::vector<std::string> tags = GetRelevantTags((Section*)_source);

	for(std::vector<std::string>::iterator it = tags.begin(); it != tags.end(); ++it)
	{
		if(!it->compare("Weapon"))
		{
			Billboard* bb = new Billboard("WeaponIcon", BillboardType::ScreenSpace);
			bb->SetPosition(screen_position);
			labels_.push_back(bb);
			screen_position += icon_spacing;
			interesting = true;
		}
		if(!it->compare("Beam"))
		{
			Billboard* bb = new Billboard("BeamIcon", BillboardType::ScreenSpace);
			bb->SetPosition(screen_position);
			labels_.push_back(bb);
			screen_position += icon_spacing;
			interesting = true;
		}
		if(!it->compare("Shield"))
		{
			Billboard* bb = new Billboard("ShieldIcon", BillboardType::ScreenSpace);
			bb->SetPosition(screen_position);
			labels_.push_back(bb);
			screen_position += icon_spacing;
			interesting = true;
		}
		if(!it->compare("Generator"))
		{
			Billboard* bb = new Billboard("GeneratorIcon", BillboardType::ScreenSpace);
			bb->SetPosition(screen_position);
			labels_.push_back(bb);
			screen_position += icon_spacing;
			interesting = true;
		}
		if(!it->compare("EnergyStorage"))
		{
			Billboard* bb = new Billboard("EnergyStorageIcon", BillboardType::ScreenSpace);
			bb->SetPosition(screen_position);
			labels_.push_back(bb);
			screen_position += icon_spacing;
			interesting = true;
		}
		if(!it->compare("Thruster"))
		{
			Billboard* bb = new Billboard("ThrusterIcon", BillboardType::ScreenSpace);
			bb->SetPosition(screen_position);
			labels_.push_back(bb);
			screen_position += icon_spacing;
			interesting = true;
		}
		if(!it->compare("Core"))
		{
			Billboard* bb = new Billboard("CoreIcon", BillboardType::ScreenSpace);
			bb->SetPosition(screen_position);
			labels_.push_back(bb);
			screen_position += icon_spacing;
			interesting = true;
		}
		if(!it->compare("Joint"))
		{
			Billboard* bb = new Billboard("JointIcon", BillboardType::ScreenSpace);
			bb->SetPosition(screen_position);
			labels_.push_back(bb);
			screen_position += icon_spacing;
			interesting = true;
		}
	}
	if(!interesting)
		lifetime_ = -1;

	screen_position_ = screen_position;
}
Exemplo n.º 27
0
void GLLight::SetDiffuse( float r, float g, float b, float a )
{
	diffuse_ = GLColor( r, g, b, a );
	glLightfv( lightNum_, GL_DIFFUSE, diffuse_.pointer() );
}