2013-01-13 21:39:25 -05:00
|
|
|
/*
|
2015-01-01 18:04:46 -05:00
|
|
|
* Copyright 2011-2015 Branimir Karadzic. All rights reserved.
|
2013-01-13 21:39:25 -05:00
|
|
|
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
2013-11-14 00:54:36 -05:00
|
|
|
#ifndef BGFX_GLCONTEXT_WGL_H_HEADER_GUARD
|
|
|
|
#define BGFX_GLCONTEXT_WGL_H_HEADER_GUARD
|
2013-01-13 21:39:25 -05:00
|
|
|
|
|
|
|
#if BGFX_USE_WGL
|
|
|
|
|
|
|
|
#include <wgl/wglext.h>
|
2014-05-26 17:09:26 -04:00
|
|
|
|
|
|
|
namespace bgfx
|
|
|
|
{
|
2013-01-13 21:39:25 -05:00
|
|
|
typedef PROC (APIENTRYP PFNWGLGETPROCADDRESSPROC) (LPCSTR lpszProc);
|
|
|
|
typedef BOOL (APIENTRYP PFNWGLMAKECURRENTPROC) (HDC hdc, HGLRC hglrc);
|
|
|
|
typedef HGLRC (APIENTRYP PFNWGLCREATECONTEXTPROC) (HDC hdc);
|
2014-09-07 20:17:38 -04:00
|
|
|
typedef BOOL (APIENTRYP PFNWGLDELETECONTEXTPROC) (HGLRC hglrc);
|
2013-01-13 21:39:25 -05:00
|
|
|
//
|
|
|
|
typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void);
|
|
|
|
typedef void (APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
|
|
|
|
typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
|
|
|
|
typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
|
|
|
|
typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param);
|
|
|
|
typedef void (APIENTRYP PFNGLTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
|
|
|
|
typedef void (APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param);
|
2013-03-06 22:36:49 -05:00
|
|
|
typedef void (APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param);
|
2013-01-13 21:39:25 -05:00
|
|
|
typedef void (APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture);
|
|
|
|
typedef void (APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures);
|
|
|
|
typedef void (APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures);
|
|
|
|
typedef void (APIENTRYP PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
|
|
|
|
typedef void (APIENTRYP PFNGLDEPTHFUNCPROC) (GLenum func);
|
|
|
|
typedef void (APIENTRYP PFNGLDISABLEPROC) (GLenum cap);
|
|
|
|
typedef void (APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height);
|
|
|
|
typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
|
|
|
|
typedef void (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *params);
|
|
|
|
typedef void (APIENTRYP PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *params);
|
|
|
|
typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGPROC) (GLenum name);
|
|
|
|
typedef void (APIENTRYP PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count);
|
|
|
|
typedef void (APIENTRYP PFNGLBLENDFUNCPROC) (GLenum sfactor, GLenum dfactor);
|
|
|
|
typedef void (APIENTRYP PFNGLPOINTSIZEPROC) (GLfloat size);
|
|
|
|
typedef void (APIENTRYP PFNGLCULLFACEPROC) (GLenum mode);
|
|
|
|
typedef void (APIENTRYP PFNGLCLEARPROC) (GLbitfield mask);
|
|
|
|
typedef void (APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height);
|
|
|
|
typedef void (APIENTRYP PFNGLENABLEPROC) (GLenum cap);
|
|
|
|
typedef void (APIENTRYP PFNGLCLEARSTENCILPROC) (GLint s);
|
|
|
|
typedef void (APIENTRYP PFNGLDEPTHMASKPROC) (GLboolean flag);
|
|
|
|
typedef void (APIENTRYP PFNGLCLEARDEPTHPROC) (GLdouble depth);
|
|
|
|
typedef void (APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
|
|
|
|
typedef void (APIENTRYP PFNGLSTENCILFUNCPROC) (GLenum func, GLint ref, GLuint mask);
|
|
|
|
typedef void (APIENTRYP PFNGLSTENCILMASKPROC) (GLuint mask);
|
|
|
|
typedef void (APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass);
|
|
|
|
|
|
|
|
extern PFNWGLGETPROCADDRESSPROC wglGetProcAddress;
|
|
|
|
extern PFNWGLMAKECURRENTPROC wglMakeCurrent;
|
|
|
|
extern PFNWGLCREATECONTEXTPROC wglCreateContext;
|
|
|
|
extern PFNWGLDELETECONTEXTPROC wglDeleteContext;
|
|
|
|
|
2014-09-07 20:17:38 -04:00
|
|
|
struct SwapChainGL;
|
|
|
|
|
2013-01-13 21:39:25 -05:00
|
|
|
struct GlContext
|
|
|
|
{
|
|
|
|
GlContext()
|
|
|
|
: m_opengl32dll(NULL)
|
|
|
|
, m_context(NULL)
|
|
|
|
, m_hdc(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void create(uint32_t _width, uint32_t _height);
|
|
|
|
void destroy();
|
2013-04-27 18:16:05 -04:00
|
|
|
void resize(uint32_t _width, uint32_t _height, bool _vsync);
|
2014-09-07 20:17:38 -04:00
|
|
|
|
2014-09-23 23:35:39 -04:00
|
|
|
static bool isSwapChainSupported();
|
2014-09-07 20:17:38 -04:00
|
|
|
SwapChainGL* createSwapChain(void* _nwh);
|
2014-11-30 12:06:47 -05:00
|
|
|
void destroySwapChain(SwapChainGL* _swapChain);
|
2014-09-07 20:17:38 -04:00
|
|
|
void swap(SwapChainGL* _swapChain = NULL);
|
|
|
|
void makeCurrent(SwapChainGL* _swapChain = NULL);
|
|
|
|
|
2013-01-13 21:39:25 -05:00
|
|
|
void import();
|
|
|
|
|
|
|
|
bool isValid() const
|
|
|
|
{
|
|
|
|
return NULL != m_context;
|
|
|
|
}
|
|
|
|
|
2014-09-07 20:17:38 -04:00
|
|
|
int32_t m_contextAttrs[9];
|
|
|
|
int m_pixelFormat;
|
|
|
|
PIXELFORMATDESCRIPTOR m_pfd;
|
2013-07-27 01:55:13 -04:00
|
|
|
void* m_opengl32dll;
|
2013-01-13 21:39:25 -05:00
|
|
|
HGLRC m_context;
|
|
|
|
HDC m_hdc;
|
|
|
|
};
|
|
|
|
} // namespace bgfx
|
|
|
|
|
|
|
|
#endif // BGFX_USE_WGL
|
|
|
|
|
2013-11-14 00:54:36 -05:00
|
|
|
#endif // BGFX_GLCONTEXT_WGL_H_HEADER_GUARD
|