103 lines
3.4 KiB
C
103 lines
3.4 KiB
C
#pragma once
|
|
|
|
#define XRES 1280
|
|
#define YRES 720
|
|
|
|
typedef HGLRC (WINAPI *PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList);
|
|
typedef void (WINAPI *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
|
|
typedef void (WINAPI *PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, GLvoid *userParam);
|
|
|
|
PFNGLCREATEPROGRAMPROC glCreateProgram;
|
|
PFNGLCREATESHADERPROC glCreateShader;
|
|
PFNGLSHADERSOURCEPROC glShaderSource;
|
|
PFNGLCOMPILESHADERPROC glCompileShader;
|
|
PFNGLATTACHSHADERPROC glAttachShader;
|
|
PFNGLLINKPROGRAMPROC glLinkProgram;
|
|
PFNGLUSEPROGRAMPROC glUseProgram;
|
|
PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
|
|
PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
|
|
PFNGLGENBUFFERSPROC glGenBuffers;
|
|
PFNGLBUFFERDATAPROC glBufferData;
|
|
PFNGLMAPBUFFERPROC glMapBuffer;
|
|
PFNGLUNMAPBUFFERPROC glUnmapBuffer;
|
|
PFNGLBINDBUFFERPROC glBindBuffer;
|
|
PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
|
|
PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
|
|
PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation;
|
|
|
|
#pragma data_seg(".screenSettings")
|
|
static DEVMODE screenSettings = {{0}, 0, 0, sizeof(DEVMODE), 0, 0x001c0000, {0}, 0, 0, 0, 0, 0, {0}, 0, 32, XRES, YRES, {0}, 0};
|
|
|
|
#pragma data_seg(".pfd")
|
|
static const PIXELFORMATDESCRIPTOR pfd = {0, 1, PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8};
|
|
|
|
#pragma code_seg(".compile")
|
|
unsigned int __cdecl compileShader(const char* vsh, const char* fsh)
|
|
{
|
|
GLuint s,p;
|
|
p = glCreateProgram();
|
|
s = glCreateShader(GL_VERTEX_SHADER);
|
|
glShaderSource(s, 1, &vsh, NULL);
|
|
glCompileShader(s);
|
|
glAttachShader(p, s);
|
|
s = glCreateShader(GL_FRAGMENT_SHADER);
|
|
glShaderSource(s, 1, &fsh, NULL);
|
|
glCompileShader(s);
|
|
glAttachShader(p, s);
|
|
glLinkProgram(p);
|
|
glUseProgram(p);
|
|
return p;
|
|
};
|
|
|
|
#ifdef _DEBUG
|
|
void APIENTRY glDebugOutputAMD(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam)
|
|
{
|
|
OutputDebugStringA("[");
|
|
|
|
if (severity == GL_DEBUG_SEVERITY_HIGH_AMD)
|
|
OutputDebugStringA("high");
|
|
else if (severity == GL_DEBUG_SEVERITY_MEDIUM_AMD)
|
|
OutputDebugStringA("medium");
|
|
else if (severity == GL_DEBUG_SEVERITY_LOW_AMD)
|
|
OutputDebugStringA("low");
|
|
|
|
OutputDebugStringA("] ");
|
|
|
|
if (category == GL_DEBUG_CATEGORY_API_ERROR_AMD)
|
|
OutputDebugStringA("api error");
|
|
else if (category == GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD)
|
|
OutputDebugStringA("window system");
|
|
else if (category == GL_DEBUG_CATEGORY_DEPRECATION_AMD)
|
|
OutputDebugStringA("deprecation");
|
|
else if (category == GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD)
|
|
OutputDebugStringA("undefined behavior");
|
|
else if (category == GL_DEBUG_CATEGORY_PERFORMANCE_AMD)
|
|
OutputDebugStringA("performance");
|
|
else if (category == GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD)
|
|
OutputDebugStringA("shader compiler");
|
|
else if (category == GL_DEBUG_CATEGORY_APPLICATION_AMD)
|
|
OutputDebugStringA("application");
|
|
else if (category == GL_DEBUG_CATEGORY_OTHER_AMD)
|
|
OutputDebugStringA("other");
|
|
|
|
OutputDebugStringA(": ");
|
|
OutputDebugStringA(message);
|
|
OutputDebugStringA("\n");
|
|
|
|
DebugBreak();
|
|
}
|
|
#endif
|
|
|
|
#pragma data_seg(".attribs")
|
|
static const int attribs[] =
|
|
{
|
|
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
|
|
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
|
|
#ifdef _DEBUG
|
|
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB | WGL_CONTEXT_DEBUG_BIT_ARB,
|
|
#else
|
|
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
|
|
#endif
|
|
0
|
|
};
|