Added color
This commit is contained in:
commit
c40a38253d
13 changed files with 8300 additions and 0 deletions
88
src/color.cpp
Normal file
88
src/color.cpp
Normal file
|
@ -0,0 +1,88 @@
|
|||
#include "color.hpp"
|
||||
|
||||
namespace oglu
|
||||
{
|
||||
const Color Color::Black(0.f, 0.f, 0.f, 1.f);
|
||||
const Color Color::White(1.f, 1.f, 1.f, 1.f);
|
||||
const Color Color::Red(1.f, 0.f, 0.f, 1.f);
|
||||
const Color Color::Green(0.f, 1.f, 0.f, 1.f);
|
||||
const Color Color::Blue(0.f, 0.f, 1.f, 1.f);
|
||||
const Color Color::Yellow(1.f, 1.f, 0.f, 1.f);
|
||||
const Color Color::Magenta(1.f, 0.f, 1.f, 1.f);
|
||||
const Color Color::Cyan(0.f, 1.f, 1.f, 1.f);
|
||||
const Color Color::Transparent(0.f, 0.f, 0.f, 0.f);
|
||||
|
||||
Color::Color() :
|
||||
r(0.f), g(0.f), b(0.f), a(0.f)
|
||||
{
|
||||
}
|
||||
|
||||
Color::Color(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) :
|
||||
r(red), g(green), b(blue), a(alpha)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator==(const Color& left, const Color& right)
|
||||
{
|
||||
return
|
||||
(
|
||||
(left.r == right.r) &&
|
||||
(left.g == right.g) &&
|
||||
(left.b == right.b) &&
|
||||
(left.a == right.a)
|
||||
);
|
||||
}
|
||||
|
||||
bool operator!=(const Color& left, const Color& right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
Color operator+(const Color& left, const Color& right)
|
||||
{
|
||||
return Color(
|
||||
left.r + right.r,
|
||||
left.g + right.g,
|
||||
left.b + right.b,
|
||||
left.a + right.a
|
||||
);
|
||||
}
|
||||
|
||||
Color operator-(const Color& left, const Color& right)
|
||||
{
|
||||
return Color(
|
||||
left.r - right.r,
|
||||
left.g - right.g,
|
||||
left.b - right.b,
|
||||
left.a - right.a
|
||||
);
|
||||
}
|
||||
|
||||
Color operator*(const Color& left, const Color& right)
|
||||
{
|
||||
return Color(
|
||||
left.r * right.r,
|
||||
left.g * right.g,
|
||||
left.b * right.b,
|
||||
left.a * right.a
|
||||
);
|
||||
}
|
||||
|
||||
Color& operator+=(Color& left, const Color& right)
|
||||
{
|
||||
left = left + right;
|
||||
return left;
|
||||
}
|
||||
|
||||
Color& operator-=(Color& left, const Color& right)
|
||||
{
|
||||
left = left - right;
|
||||
return left;
|
||||
}
|
||||
|
||||
Color& operator*=(Color& left, const Color& right)
|
||||
{
|
||||
left = left * right;
|
||||
return left;
|
||||
}
|
||||
}
|
26
src/openglu.cpp
Normal file
26
src/openglu.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include "openglu.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
|
||||
namespace oglu
|
||||
{
|
||||
void LoadGLLoader(GLADloadproc proc)
|
||||
{
|
||||
if (!gladLoadGLLoader(proc))
|
||||
{
|
||||
throw std::exception("Failed to initialize GLAD");
|
||||
}
|
||||
}
|
||||
|
||||
void SetViewport(GLint x, GLint y, GLsizei width, GLsizei height)
|
||||
{
|
||||
glViewport(x, y, width, height);
|
||||
}
|
||||
|
||||
void ClearScreen(GLbitfield mask, Color clearColor)
|
||||
{
|
||||
glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a);
|
||||
glClear(mask);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue