fix compile errors
[wdl/wdl-ol.git] / WDL / gpu / gpu.h
blob22547eb95dfd11fdd5b243830c0241fca56b61d0
1 /*
2 WDL - gpu.h
3 Copyright (C) 2007 Cockos Incorporated
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
23 #ifndef _WDL_GPU_H
24 #define _WDL_GPU_H
26 #ifdef _WIN32
28 #include <windows.h>
29 #include <gl/gl.h>
30 #include "wglext.h"
32 #include "../wingui/membitmap.h"
34 class WDL_GPU_Surface;
36 class WDL_GPU
38 public:
39 WDL_GPU();
40 ~WDL_GPU();
42 int init(HWND hwnd);
43 void release();
44 int isInited() { return m_glDll != NULL; }
46 WDL_GPU_Surface *createSurface(WDL_WinMemBitmap *bm, int w, int h);
48 HGLRC (WINAPI *wglCreateContext)(HDC dc);
49 BOOL (WINAPI *wglMakeCurrent)(HDC dc, HGLRC rc);
50 BOOL (WINAPI *wglDeleteContext)(HGLRC rc);
51 PROC (WINAPI *wglGetProcAddress)(LPCSTR name);
53 void (WINAPI *glClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
54 void (WINAPI *glClear)(GLbitfield mask);
55 void (WINAPI *glEnable)(GLenum cap);
56 void (WINAPI *glDisable)(GLenum cap);
57 void (WINAPI *glBlendFunc)(GLenum sfactor, GLenum dfactor);
58 void (WINAPI *glLineWidth)(GLfloat width);
59 void (WINAPI *glColor3f)(GLfloat red, GLfloat green, GLfloat blue);
60 void (WINAPI *glBegin)(GLenum mode);
61 void (WINAPI *glEnd)();
62 void (WINAPI *glVertex2f)(GLfloat x, GLfloat y);
63 void (WINAPI *glFlush)();
64 void (WINAPI *glFinish)();
65 const GLubyte *(WINAPI *glGetString)(GLenum name);
66 void (WINAPI *glReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
68 // WGL_ARB_extensions_string
69 PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB;
71 // WGL_ARB_pbuffer
72 PFNWGLCREATEPBUFFERARBPROC wglCreatePbufferARB;
73 PFNWGLGETPBUFFERDCARBPROC wglGetPbufferDCARB;
74 PFNWGLRELEASEPBUFFERDCARBPROC wglReleasePbufferDCARB;
75 PFNWGLDESTROYPBUFFERARBPROC wglDestroyPbufferARB;
76 PFNWGLQUERYPBUFFERARBPROC wglQueryPbufferARB;
78 // WGL_ARB_pixel_format
79 PFNWGLGETPIXELFORMATATTRIBIVARBPROC wglGetPixelFormatAttribivARB;
80 PFNWGLGETPIXELFORMATATTRIBFVARBPROC wglGetPixelFormatAttribfvARB;
81 PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB;
83 HINSTANCE m_glDll;
84 HWND m_hwnd;
85 HGLRC m_rc;
88 class WDL_GPU_Surface
90 public:
91 WDL_GPU_Surface(WDL_GPU *parent, WDL_WinMemBitmap *bm, int w, int h);
92 ~WDL_GPU_Surface();
94 void clear(float cr, float cg, float cb);
95 void beginScene();
96 void setLineAA(int on);
97 void beginLine(float cr, float cg, float cb);
98 void end();
99 void drawLine(int x1, int y1, int x2, int y2);
100 void flush();
101 void blit();
103 private:
104 WDL_GPU *m_parent;
105 WDL_WinMemBitmap *m_bm;
106 HBITMAP m_oldbm, m_bmp;
107 int m_w, m_h;
109 HPBUFFERARB m_hPBuffer;
110 HDC m_hDC;
111 HGLRC m_hRC;
112 void *m_bits;
115 #else
117 //todo
119 #endif
121 #endif