port from perforce
This commit is contained in:
152
space4k/src/glgraphics.h
Normal file
152
space4k/src/glgraphics.h
Normal file
@@ -0,0 +1,152 @@
|
||||
#pragma once
|
||||
|
||||
#pragma data_seg(".glCreateProgram")
|
||||
static const char* glCreateProgram = "glCreateProgram";
|
||||
|
||||
#pragma data_seg(".glCreateShader")
|
||||
static const char* glCreateShader = "glCreateShader";
|
||||
|
||||
#pragma data_seg(".glShaderSource")
|
||||
static const char* glShaderSource = "glShaderSource";
|
||||
|
||||
#pragma data_seg(".glCompileShader")
|
||||
static const char* glCompileShader = "glCompileShader";
|
||||
|
||||
#pragma data_seg(".glAttachShader")
|
||||
static const char* glAttachShader = "glAttachShader";
|
||||
|
||||
#pragma data_seg(".glLinkProgram")
|
||||
static const char* glLinkProgram = "glLinkProgram";
|
||||
|
||||
#pragma data_seg(".glUseProgram")
|
||||
static const char* glUseProgram = "glUseProgram";
|
||||
|
||||
#pragma data_seg(".glActiveTexture")
|
||||
static const char* glActiveTexture = "glActiveTexture";
|
||||
|
||||
#pragma code_seg(".UseShader")
|
||||
inline void UseShader(GLuint shader)
|
||||
{
|
||||
_asm
|
||||
{
|
||||
mov eax, shader
|
||||
push shaders[eax*4]
|
||||
push dword ptr [glUseProgram]
|
||||
|
||||
call dword ptr [wglGetProcAddress]
|
||||
call eax
|
||||
}
|
||||
}
|
||||
|
||||
#pragma code_seg(".CreateShader")
|
||||
inline void CreateShaders()
|
||||
{
|
||||
_asm
|
||||
{
|
||||
xor esi, esi
|
||||
|
||||
shaderloop:
|
||||
push 8B30h
|
||||
push dword ptr [glCreateShader]
|
||||
push 8B31h
|
||||
push dword ptr [glCreateShader]
|
||||
push dword ptr [glCreateProgram]
|
||||
|
||||
call dword ptr [wglGetProcAddress]
|
||||
call eax
|
||||
mov ebx,eax
|
||||
|
||||
call dword ptr [wglGetProcAddress]
|
||||
call eax
|
||||
mov edi,eax
|
||||
|
||||
call dword ptr [wglGetProcAddress]
|
||||
call eax
|
||||
mov edx,eax
|
||||
lea eax, fsh[esi*4]
|
||||
|
||||
push ebx
|
||||
push dword ptr [glLinkProgram]
|
||||
|
||||
push edx
|
||||
push ebx
|
||||
push dword ptr [glAttachShader]
|
||||
|
||||
push edx
|
||||
push dword ptr [glCompileShader]
|
||||
|
||||
push 0
|
||||
push eax
|
||||
push 1
|
||||
push edx
|
||||
push dword ptr [glShaderSource]
|
||||
|
||||
push edi
|
||||
push ebx
|
||||
push dword ptr [glAttachShader]
|
||||
|
||||
push edi
|
||||
push dword ptr [glCompileShader]
|
||||
|
||||
push 0
|
||||
push offset vertexShader
|
||||
push 1
|
||||
push edi
|
||||
push dword ptr [glShaderSource]
|
||||
|
||||
mov edi, dword ptr [wglGetProcAddress]
|
||||
call edi
|
||||
call eax
|
||||
call edi
|
||||
call eax
|
||||
call edi
|
||||
call eax
|
||||
call edi
|
||||
call eax
|
||||
call edi
|
||||
call eax
|
||||
call edi
|
||||
call eax
|
||||
call edi
|
||||
call eax
|
||||
|
||||
mov dword ptr shaders[esi*4], ebx
|
||||
inc esi
|
||||
test esi, shaderCount
|
||||
jz shaderLoop
|
||||
}
|
||||
}
|
||||
|
||||
#pragma code_seg(".CreateOGL")
|
||||
inline void CreateOGL()
|
||||
{
|
||||
_asm
|
||||
{
|
||||
push hdc
|
||||
push offset pfd
|
||||
push offset pfd
|
||||
push hdc
|
||||
call dword ptr [ChoosePixelFormat]
|
||||
push eax
|
||||
push hdc
|
||||
call dword ptr [SetPixelFormat]
|
||||
call dword ptr [wglCreateContext]
|
||||
push eax
|
||||
push hdc
|
||||
call dword ptr [wglMakeCurrent]
|
||||
}
|
||||
}
|
||||
|
||||
#pragma code_seg(".DrawFrame")
|
||||
void DrawFrame()
|
||||
{
|
||||
glLoadIdentity();
|
||||
glTranslated(1, 1, x_Sin(time)*3);
|
||||
glRotatef(-time * 10, 0, 1, 0);
|
||||
UseShader(WORLD_GLSL);
|
||||
glNormal3f(WIDTH, HEIGHT, ASPECT);
|
||||
glColor3f(time, 0, 0);
|
||||
glRects(-1, -1, 1, 1);
|
||||
|
||||
SwapBuffers(hdc);
|
||||
}
|
||||
Reference in New Issue
Block a user