tibia-client/src/graphics.cpp

64 lines
1.0 KiB
C++
Raw Normal View History

#include "graphics.h"
#include <GL/gl.h>
#include <GL/glu.h>
Graphics g_graphics;
Graphics::Graphics()
{
}
Graphics::~Graphics()
{
}
void Graphics::init()
{
// setup opengl
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // black background
glEnable(GL_ALPHA_TEST); // enable alpha
glAlphaFunc(GL_GREATER, 0.0f); // default alpha mode
glDisable(GL_DEPTH_TEST); // we are rendering 2D only, we don't need it
}
void Graphics::terminate()
{
}
void Graphics::resize(int width, int height)
{
// resize gl viewport
glViewport(0, 0, width, height);
/*
0,0---------0,w
| |
| |
| |
h,0---------h,w
*/
// setup view region like above
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0f, width, height, 0.0f);
// back to model view
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void Graphics::beginRender()
{
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
}
void Graphics::endRender()
{
}