2010-11-18 23:13:35 +01:00
|
|
|
#ifndef GRAPHICS_H
|
|
|
|
#define GRAPHICS_H
|
|
|
|
|
2011-08-14 04:09:11 +02:00
|
|
|
#include "graphicsdeclarations.h"
|
2010-11-23 22:56:28 +01:00
|
|
|
|
2010-11-18 23:13:35 +01:00
|
|
|
class Graphics
|
|
|
|
{
|
|
|
|
public:
|
2011-08-14 04:09:11 +02:00
|
|
|
/// Initialize default OpenGL states
|
2010-11-18 23:13:35 +01:00
|
|
|
void init();
|
2011-04-10 22:40:44 +02:00
|
|
|
|
|
|
|
/// Termiante graphics
|
2010-11-18 23:13:35 +01:00
|
|
|
void terminate();
|
|
|
|
|
2011-04-06 22:53:00 +02:00
|
|
|
/// Check if a GL extension is supported
|
2011-03-19 01:22:29 +01:00
|
|
|
bool isExtensionSupported(const char *extension);
|
|
|
|
|
2011-08-14 04:09:11 +02:00
|
|
|
/// Resizes OpenGL viewport
|
2011-04-08 07:10:00 +02:00
|
|
|
void resize(const Size& size);
|
2010-11-18 23:13:35 +01:00
|
|
|
|
2010-11-23 22:56:28 +01:00
|
|
|
/// Restore original viewport
|
|
|
|
void restoreViewport();
|
|
|
|
|
2010-11-23 16:30:43 +01:00
|
|
|
/// Called before every render
|
2010-11-18 23:13:35 +01:00
|
|
|
void beginRender();
|
2010-11-21 22:48:58 +01:00
|
|
|
|
2010-11-23 16:30:43 +01:00
|
|
|
/// Called after every render
|
2010-11-18 23:13:35 +01:00
|
|
|
void endRender();
|
2011-08-14 19:45:25 +02:00
|
|
|
|
|
|
|
void bindColor(const Color& color);
|
|
|
|
void bindTexture(const TexturePtr& texture);
|
2010-11-23 16:30:43 +01:00
|
|
|
|
2011-08-14 04:09:11 +02:00
|
|
|
// drawing API
|
|
|
|
void drawTexturedRect(const Rect& screenCoords,
|
|
|
|
const TexturePtr& texture,
|
2011-08-14 19:45:25 +02:00
|
|
|
const Rect& textureCoords = Rect());
|
2011-02-08 23:48:26 +01:00
|
|
|
|
2011-08-14 04:09:11 +02:00
|
|
|
void drawRepeatedTexturedRect(const Rect& screenCoords,
|
|
|
|
const TexturePtr& texture,
|
2011-08-14 19:45:25 +02:00
|
|
|
const Rect& textureCoords);
|
2011-08-14 04:09:11 +02:00
|
|
|
|
|
|
|
void drawFilledRect(const Rect& screenCoords,
|
|
|
|
const Color& color);
|
2011-04-16 18:08:55 +02:00
|
|
|
|
2011-08-14 04:09:11 +02:00
|
|
|
void drawBoundingRect(const Rect& screenCoords,
|
|
|
|
const Color& color = Color::green,
|
|
|
|
int innerLineWidth = 1);
|
|
|
|
|
|
|
|
const Size& getScreenSize() const { return m_screenSize; }
|
2011-04-07 09:30:32 +02:00
|
|
|
|
2011-08-14 19:45:25 +02:00
|
|
|
void startDrawing();
|
|
|
|
void stopDrawing();
|
|
|
|
|
|
|
|
int getOpacity() const { return m_opacity; }
|
|
|
|
void setOpacity(int opacity) { m_opacity = opacity; }
|
2011-04-16 18:08:55 +02:00
|
|
|
|
2011-08-14 19:45:25 +02:00
|
|
|
private:
|
|
|
|
bool m_drawing;
|
|
|
|
int m_opacity;
|
2010-11-25 00:36:15 +01:00
|
|
|
Size m_screenSize;
|
2010-11-18 23:13:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extern Graphics g_graphics;
|
|
|
|
|
2011-08-14 04:09:11 +02:00
|
|
|
#endif
|