https://github.com/nickscha/w32_gl
C89, single header, nostdlib win32/opengl without windows.h
https://github.com/nickscha/w32_gl
c89 nostdlib single-header
Last synced: 10 months ago
JSON representation
C89, single header, nostdlib win32/opengl without windows.h
- Host: GitHub
- URL: https://github.com/nickscha/w32_gl
- Owner: nickscha
- License: mit
- Created: 2025-03-06T16:33:59.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-03-17T10:01:40.000Z (10 months ago)
- Last Synced: 2025-03-17T10:44:45.449Z (10 months ago)
- Topics: c89, nostdlib, single-header
- Language: C
- Homepage:
- Size: 120 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# w32_gl (in development)
A C89 standard compliant, single header, nostdlib (no C Standard Library) win32 and opengl api function prototypes without using windows.h
For more information please look at the "w32_gl.h" file or take a look at the "examples" or "tests" folder.
## Quick Start
Download or clone w32_gl.h and include it in your project.
```C
#include "w32_gl.h"
int main() {
return 0;
}
```
## Run Example: win32, opengl, nostdlib, freestsanding
In this repo you will find the "examples/w32_gl_10_full3d_hot_reload/w32_gl_nostdlib.c" with the corresponding "build.bat" file which
creates an executable only linked to "kernel32","user32","gdi32","opengl32" and is not using the C standard library and executes the program afterwards.
Features:
- **1 memory allocation**: 1 for everything. Just VirtualAlloc once. Arena/Bump Memory is passed to application code.
- **hot OpenGL shader reloading**: Just edit the GLSL files and the running program will update.
- **hot application code reloading**: Let the window stay open and edit/save/compile **speg.c** and see changes immediatly without restarting the program.
- **OpenGL Instanced Rendering**
- **Frustum Culling**: From my other linear algebra library **vm.h**
Files:
- **w32_gl_nostdlib.c**: The platform specific code (here win32) is defined here. build.bat produces **w32_gl_nostdlib.exe**
- **speg.h**: Shared header between the .exe and .dll (speg.c)
- **speg.c**: The application code/logic which is pure C89 without any linkings. build.bat produces **speg.dll**
- **test.vs,test.fs,test_instanced.vs**: The OpenGL GLSL shaders

## "nostdlib" Motivation & Purpose
nostdlib is a lightweight, minimalistic approach to C development that removes dependencies on the standard library. The motivation behind this project is to provide developers with greater control over their code by eliminating unnecessary overhead, reducing binary size, and enabling deployment in resource-constrained environments.
Many modern development environments rely heavily on the standard library, which, while convenient, introduces unnecessary bloat, security risks, and unpredictable dependencies. nostdlib aims to give developers fine-grained control over memory management, execution flow, and system calls by working directly with the underlying platform.
### Benefits
#### Minimal overhead
By removing the standard library, nostdlib significantly reduces runtime overhead, allowing for faster execution and smaller binary sizes.
#### Increased security
Standard libraries often include unnecessary functions that increase the attack surface of an application. nostdlib mitigates security risks by removing unused and potentially vulnerable components.
#### Reduced binary size
Without linking to the standard library, binaries are smaller, making them ideal for embedded systems, bootloaders, and operating systems where storage is limited.
#### Enhanced performance
Direct control over system calls and memory management leads to performance gains by eliminating abstraction layers imposed by standard libraries.
#### Better portability
By relying only on fundamental system interfaces, nostdlib allows for easier porting across different platforms without worrying about standard library availability.