Skip to content

Commit ef8fd91

Browse files
committed
files from monorepo @ 14e6258901c6fb47ae598705682837ef6c298e60
0 parents  commit ef8fd91

File tree

8 files changed

+10112
-0
lines changed

8 files changed

+10112
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Ignore some special directories
2+
.zig-cache
3+
zig-out
4+
5+
# Ignore some special OS files
6+
*.DS_Store

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Michal Ziulek
4+
Copyright (c) 2024 zig-gamedev contributors
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# [zopengl(https://github.com/zig-gamedev/zopengl)
2+
3+
OpenGL loader, bindings and optional wrapper for Zig.
4+
5+
Supports:
6+
* OpenGL Core Profile up to version 4.2
7+
* OpenGL ES up to version 2.0
8+
9+
## Getting started
10+
11+
Example `build.zig`:
12+
13+
```zig
14+
pub fn build(b: *std.Build) void {
15+
const exe = b.addExecutable(.{ ... });
16+
17+
const zopengl = b.dependency("zopengl", .{});
18+
exe.root_module.addImport("zopengl", zopengl.module("root"));
19+
}
20+
```
21+
22+
Now in your code you may import and use `zopengl`:
23+
24+
```zig
25+
const zopengl = @import("zopengl");
26+
27+
pub fn main() !void {
28+
// Create window and OpenGL context here... (you can use our `zsdl` or `zglfw` libs for this)
29+
30+
try zopengl.loadCoreProfile(getProcAddress, 4, 0);
31+
32+
const gl = zopengl.bindings; // or zopengl.wrapper (experimental)
33+
34+
gl.clearBufferfv(gl.COLOR, 0, &[_]f32{ 0.2, 0.4, 0.8, 1.0 });
35+
}
36+
37+
fn getProcAddress(name: [:0]const u8) ?*const anyopaque {
38+
// Load GL function pointer here
39+
// You could use `zsdl.gl.getProcAddress() or `zglfw.getProcAddress()`
40+
}
41+
```

build.zig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const std = @import("std");
2+
3+
pub fn build(b: *std.Build) void {
4+
const target = b.standardTargetOptions(.{});
5+
6+
const optimize = b.standardOptimizeOption(.{
7+
.preferred_optimize_mode = .ReleaseSafe,
8+
});
9+
10+
_ = b.addModule("root", .{
11+
.root_source_file = b.path("src/zopengl.zig"),
12+
});
13+
14+
const lib = b.addStaticLibrary(.{
15+
.name = "zopengl",
16+
.root_source_file = b.path("src/zopengl.zig"),
17+
.target = target,
18+
.optimize = optimize,
19+
});
20+
_ = b.installArtifact(lib);
21+
}

build.zig.zon

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.{
2+
.name = "zopengl",
3+
.version = "0.6.0-dev",
4+
.paths = .{
5+
"build.zig",
6+
"build.zig.zon",
7+
"src",
8+
"README.md",
9+
"LICENSE",
10+
},
11+
}

0 commit comments

Comments
 (0)