using std::string;
+#define MOTION_BLUR_COEFF 0.99f
+#define MOTION_BLUR_INTENS 0.99f
+
void Graphix::setWindowSize(unsigned int _width, unsigned int _height)
{
width = _width;
return width;
}
-void Graphix::swap()
+
+void Graphix::enableEffects(Effects _eff)
{
- SDL_GL_SwapWindow(sdl_window);
+ effects |= _eff;
}
+void Graphix::disableEffects(Effects _eff)
+{
+ effects &= ~_eff;
+}
+
+bool Graphix::testEffect(Effects _eff)
+{
+ return effects & _eff;
+}
+
void Graphix::init()
{
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+ //SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, 16);
+ //SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, 16);
+ //SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, 16);
+ //SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, 16);
+
sdl_window = SDL_CreateWindow(windowTitle.c_str(), xpos, ypos, width, height, windowFlags);
if (sdl_window == nullptr)
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glClearColor(0.9f, 0.9f, 1.0f, 1.f);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glClearAccum(0.f, 0.f, 0.f, 0.f);
+ glClear(GL_ACCUM_BUFFER_BIT);
+
shader_BBox = new Shader("basic_VS.hlsl", "basic_FS.hlsl");
}
void Graphix::clear()
{
- glClearColor(0.9f, 0.9f, 1.0f, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ if (testEffect(EF_MOTION_BLUR))
+ {
+ glAccum(GL_RETURN, MOTION_BLUR_INTENS);
+ glClear(GL_ACCUM_BUFFER_BIT);
+ }
+
+
+}
+
+
+void Graphix::swap()
+{
+ if (testEffect(EF_MOTION_BLUR))
+ glAccum(GL_ACCUM, MOTION_BLUR_COEFF);
+ SDL_GL_SwapWindow(sdl_window);
}
+
+
void Graphix::cleanup()
{
delete shader_BBox;
SDL_GLContext Graphix::sdl_glcontext;
+short Graphix::effects = EF_NOTHING;
Shader* Graphix::shader_BBox;
#include <string>
+#define BIT(x) (1<<(x))
+
+enum Effects {
+ EF_NOTHING = 0,
+ EF_MOTION_BLUR = BIT(1),
+ EF_TRANSPARENCY = BIT(2),
+ EF_BLOOM = BIT(3)
+};
class Shader;
static void catchMouse();
static void freeMouse();
+ static void enableEffects(Effects eff);
+ static void disableEffects(Effects eff);
+ static bool testEffect(Effects eff);
+
static void swap();
static void init();
static SDL_GLContext sdl_glcontext;
+ static short effects;
+
};