This repository has been archived on 2025-02-04. You can view files and clone it, but cannot push or open issues or pull requests.
helpless/oogabooga/gfx_impl_legacy_opengl.c
Charlie b9503d8d19 - D3D11, Image drawing & Matrix4 xform drawing
- I didn't get rotation going quite right with the xform, but it's 2am goodnight
	- Smashed my head and had bad thoughts about microsoft many times

- stuff
- lotsa example code in entry.c
2024-07-01 02:14:08 +02:00

80 lines
No EOL
1.9 KiB
C

// #Temporary #Cleanup
// #Temporary #Cleanup
// #Temporary #Cleanup
// #Temporary #Cleanup
#include "GL/gl.h"
HDC hdc;
typedef BOOL (APIENTRY *PFNWGLSWAPINTERVALEXTPROC) (int interval);
const Gfx_Handle GFX_INVALID_HANDLE = 0;
void gfx_init() {
// #Temporary #Cleanup
// #Temporary #Cleanup
// #Temporary #Cleanup
// #Temporary #Cleanup
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
32,
0, 0, 0, 0, 0, 0,
0, 0,
0, 0, 0, 0, 0,
24,
8,
0,
PFD_MAIN_PLANE,
0,
0, 0, 0
};
hdc = GetDC(window._os_handle);
int pixelFormat = ChoosePixelFormat(hdc, &pfd);
SetPixelFormat(hdc, pixelFormat, &pfd);
HGLRC hglrc = wglCreateContext(hdc);
wglMakeCurrent(hdc, hglrc);
PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) wglGetProcAddress("wglSwapIntervalEXT");
assert(wglSwapIntervalEXT, "Could not load wglSwapIntervalEXT");
wglSwapIntervalEXT(0);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
void gfx_update() {
Draw_Quad_Block *block = &draw_frame.first_block;
glBegin(GL_QUADS);
while (block != 0) {
for (u64 i = 0; i < block->num_quads; i++) {
Draw_Quad q = block->quad_buffer[i];
glColor4f(v4_expand(q.color));
glVertex2f(v2_expand(q.bottom_left));
glVertex2f(v2_expand(q.top_left));
glVertex2f(v2_expand(q.top_right));
glVertex2f(v2_expand(q.bottom_right));
}
block = block->next;
}
glEnd();
SwapBuffers(hdc);
glClearColor(window.clear_color.r, window.clear_color.g, window.clear_color.b, window.clear_color.a);
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0, 0, window.width, window.height);
draw_frame = ZERO(Draw_Frame);
}