In file libs/cs2d/openglcommon/glcommon2d.h:

class csGraphics2DGLCommon : public csGraphics2D

Basic OpenGL version of the 2D driver class You can look at the openGLX graphics class as an example of how to inherit and use this class

Inheritance:


Public Methods

csGraphics2DGLCommon(ISystem* piSystem)
constructor initializes System member
virtual void DrawBox(int x, int y, int w, int h, int color)
Draw a box
virtual void DrawLine(int x1, int y1, int x2, int y2, int color)
Draw a line
static void DrawPixelGL(int x, int y, int color)
Draw a pixel
static void DrawSpriteGL(ITextureHandle *hTex, int sx, int sy, int sw, int sh, int tx, int ty, int tw, int th)
Draw a 2D sprite
static unsigned char* GetPixelAtGL(int x, int y)
Get address of video RAM at given x,y coordinates
virtual void Initialize()
Figure out draw functions
virtual bool Open(char *Title)
initialize fonts, texture cache, prints renderer name and version
static void setGLColorfromint(int color)
Figure out GL RGB color from a packed color format
static void WriteCharGL(int x, int y, int fg, int bg, char c)
Write a single character
virtual ~csGraphics2DGLCommon()
Destructor deletes texture_cache and LocalFontServer

Protected Fields

ISystem* System
local copy of System interface for CsPrintf

Private Fields

static csGraphics2DOpenGLFontServer* LocalFontServer
hold the CS fonts in an OpenGL-friendly format
static OpenGLTextureCache* texture_cache
my own private texture cache--for 2D sprites!

Inherited from csGraphics2D:

Public Fields

static int Font
static bool FullScreen
static RGBpaletteEntry Palette[256]
static bool PaletteAlloc[256]
static int Width

Public Methods

static void (*DrawPixel)(int x, int y, int color)
static void (*DrawSprite)(ITextureHandle *hTex, int sx, int sy, int sw, int sh, int tx, int ty, int tw, int th)
static unsigned char* (*GetPixelAt)(int x, int y)
static void (*WriteChar)(int x, int y, int fg, int bg, char c)
virtual bool BeginDraw()
virtual void Clear(int color)
void ClearAll(int color)
static bool ClipLine(float &x1, float &y1, float &x2, float &y2, int xmin, int ymin, int xmax, int ymax)
virtual void Close()
virtual bool DoubleBuffer(bool Enable)
virtual bool DoubleBuffer()
static void DrawPixel8(int x, int y, int color)
virtual void FinishDraw()
virtual void FreeArea(ImageArea *Area)
virtual void GetClipRect(int &xmin, int &ymin, int &xmax, int &ymax)
int GetNumPalEntries()
virtual int GetPage()
int GetPixelBytes()
csPixelFormat* GetPixelFormat()
virtual void GetStringError(HRESULT hRes, char* szValue)
virtual int GetTextHeight(int Font)
virtual int GetTextWidth(int Font, char *text)
virtual bool PerformExtension(char* args)
virtual void Print(csRect *area = NULL)
virtual void RestoreArea(ImageArea *Area, bool Free = true)
virtual bool SaveArea(ImageArea *&Area, int x, int y, int w, int h)
virtual void SetClipRect(int xmin, int ymin, int xmax, int ymax)
virtual bool SetMouseCursor(int iShape, ITextureHandle *hBitmap)
virtual bool SetMousePosition(int x, int y)
virtual void SetRGB(int i, int r, int g, int b)
void SysPrintf(int mode, char* text, ...)
virtual void Write(int x, int y, int fg, int bg, char *text)

Public

Protected Fields

static int ClipX1
static int* LineAddress
static unsigned char* Memory
static csPixelFormat pfmt
static ISystem* system

Protected Methods

void complete_pixel_format()
static void DrawPixel16(int x, int y, int color)
static void DrawPixel32(int x, int y, int color)
static void DrawSprite16(ITextureHandle *hTex, int sx, int sy, int sw, int sh, int tx, int ty, int tw, int th)
static void DrawSprite32(ITextureHandle *hTex, int sx, int sy, int sw, int sh, int tx, int ty, int tw, int th)
static void DrawSprite8(ITextureHandle *hTex, int sx, int sy, int sw, int sh, int tx, int ty, int tw, int th)
static unsigned char* GetPixelAt16(int x, int y)
static unsigned char* GetPixelAt32(int x, int y)
static unsigned char* GetPixelAt8(int x, int y)
static void WriteChar16(int x, int y, int fg, int bg, char c)
static void WriteChar32(int x, int y, int fg, int bg, char c)
static void WriteChar8(int x, int y, int fg, int bg, char c)

Protected


Documentation

Basic OpenGL version of the 2D driver class You can look at the openGLX graphics class as an example of how to inherit and use this class. In short, inherit from this common class instead of from csGraphics2D, and override all the functions you normally would except for the 2D drawing functions, which are supplied for you here. That way all OpenGL drawing functions are unified over platforms, so that a fix or improvement will be inherited by all platforms instead of percolating via people copying code over. -GJH
static OpenGLTextureCache* texture_cache
my own private texture cache--for 2D sprites!

static csGraphics2DOpenGLFontServer* LocalFontServer
hold the CS fonts in an OpenGL-friendly format

ISystem* System
local copy of System interface for CsPrintf

csGraphics2DGLCommon(ISystem* piSystem)
constructor initializes System member.. LocalFontServer and texture_cache are initialized in Open()

virtual ~csGraphics2DGLCommon()
Destructor deletes texture_cache and LocalFontServer

virtual void Initialize()
Figure out draw functions...little else done here, most of the work is done in Open()

virtual bool Open(char *Title)
initialize fonts, texture cache, prints renderer name and version. you should still print out the 2D driver type (X, Win, etc.) in your subclass code. Note that the Open() method makes some OpenGL calls, so your GL context should already be created and bound before you call csGraphics2DGLCommon::Open()! This means you may or may not be calling this method at the beginning of your own class Open(), since the GL context may not have been bound yet... check the GLX class for an example

virtual void DrawLine(int x1, int y1, int x2, int y2, int color)
Draw a line

virtual void DrawBox(int x, int y, int w, int h, int color)
Draw a box

static void DrawPixelGL(int x, int y, int color)
Draw a pixel

static void WriteCharGL(int x, int y, int fg, int bg, char c)
Write a single character

static void DrawSpriteGL(ITextureHandle *hTex, int sx, int sy, int sw, int sh, int tx, int ty, int tw, int th)
Draw a 2D sprite

static void setGLColorfromint(int color)
Figure out GL RGB color from a packed color format

static unsigned char* GetPixelAtGL(int x, int y)
Get address of video RAM at given x,y coordinates. The OpenGL version of this function just returns NULL.


Direct child classes:
csGraphics2DOpenGL
csGraphics2DOpenGL
csGraphics2DOS2GL
csGraphics2DGLX
csGraphics2DGLBe

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de