/* The MIT License * * Copyright (c) 2010 OTClient, https://github.com/edubart/otclient * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include "graphics.h" #include "logger.h" #include #include 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 notice("GPU %s", (const char*)glGetString(GL_RENDERER)); notice("OpenGL %s", (const char*)glGetString(GL_VERSION)); } 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() { }