Add Color class.

--HG--
branch : minor
This commit is contained in:
vrld
2011-04-06 21:20:32 +02:00
parent eadcca21e1
commit aa5eb4380d
4 changed files with 112 additions and 22 deletions
+1 -2
View File
@@ -4,6 +4,7 @@
#include <graphics/Drawable.h>
#include <graphics/Volatile.h>
#include <graphics/Image.h>
#include <graphics/Color.h>
#include <image/Image.h>
#include <image/ImageData.h>
#include <common/math.h>
@@ -15,8 +16,6 @@ namespace graphics
{
namespace opengl
{
struct Color; // forward declaration for clear
class Framebuffer : public Drawable, public Volatile
{
public:
+4 -10
View File
@@ -82,16 +82,10 @@ namespace opengl
float color[4];
//get the color
glGetFloatv(GL_CURRENT_COLOR, color);
s.color.r = (GLubyte)(color[0]*255.0f);
s.color.g = (GLubyte)(color[1]*255.0f);
s.color.b = (GLubyte)(color[2]*255.0f);
s.color.a = (GLubyte)(color[3]*255.0f);
s.color.set( (color[0]*255.0f), (color[1]*255.0f), (color[2]*255.0f), (color[3]*255.0f) );
//get the background color
glGetFloatv(GL_COLOR_CLEAR_VALUE, color);
s.backgroundColor.r = (GLubyte)(color[0]*255.0f);
s.backgroundColor.g = (GLubyte)(color[1]*255.0f);
s.backgroundColor.b = (GLubyte)(color[2]*255.0f);
s.backgroundColor.a = (GLubyte)(color[3]*255.0f);
s.backgroundColor.set( color[0]*255.0f, color[1]*255.0f, color[2]*255.0f, color[3]*255.0f );
//store modes here
GLint mode;
//get blend mode
@@ -489,7 +483,7 @@ namespace opengl
return new Framebuffer(width, height);
}
void Graphics::setColor(Color c)
void Graphics::setColor(const Color& c)
{
glColor4ubv(&c.r);
}
@@ -508,7 +502,7 @@ namespace opengl
return t;
}
void Graphics::setBackgroundColor(Color c)
void Graphics::setBackgroundColor(const Color& c)
{
glClearColor((float)c.r/255.0f, (float)c.g/255.0f, (float)c.b/255.0f, (float)c.a/255.0f);
}
+4 -10
View File
@@ -31,6 +31,7 @@
// LOVE
#include <graphics/Graphics.h>
#include <graphics/Color.h>
#include <image/Image.h>
#include <image/ImageData.h>
@@ -48,10 +49,6 @@ namespace graphics
{
namespace opengl
{
struct Color
{
unsigned char r, g, b, a;
};
struct DisplayMode
{
@@ -93,10 +90,7 @@ namespace opengl
// Default values.
DisplayState()
{
color.r = 255;
color.g = 255;
color.b = 255;
color.a = 255;
color.set(255,255,255,255);
backgroundColor.r = 0;
backgroundColor.g = 0;
backgroundColor.b = 0;
@@ -265,7 +259,7 @@ namespace opengl
/**
* Sets the foreground color.
**/
void setColor(Color c);
void setColor(const Color& c);
/**
* Gets current color.
@@ -275,7 +269,7 @@ namespace opengl
/**
* Sets the background Color.
**/
void setBackgroundColor(Color c);
void setBackgroundColor(const Color& c);
/**
* Gets the current background color.