Skip to content

Commit

Permalink
First implementation of scene using core profile
Browse files Browse the repository at this point in the history
  • Loading branch information
bfeldpw committed Nov 12, 2023
1 parent b134c2c commit ade3807
Show file tree
Hide file tree
Showing 17 changed files with 1,629 additions and 717 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Figure 2 shows an enlarged version of a similar scene as seen in Figure 1 to dem

## Installation and dependencies

Zig seems to be very handy when it comes to cross compiling. I only tried within Linux, GLFW3 and thus, OpenGL have to be installed.
Zig seems to be very handy when it comes to cross compiling. I only tried within Linux, GLFW3, GLEW and thus, OpenGL have to be installed.

<!-- ## Performance measurements -->

Expand Down
26 changes: 26 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,32 @@ pub fn build(b: *std.Build) void {
b.installArtifact(exe);
// exe.emit_docs = .emit;

const exe_gl_test = b.addExecutable(.{
.name = "gl_test",
.root_source_file = .{ .path = "src/gl_test.zig" },
.target = target,
.optimize = optimize,
});
exe_gl_test.addIncludePath(.{.path = "src"});
exe_gl_test.addCSourceFile(.{
.file = .{ .path = "src/stb_implementation.c" },
.flags = &.{
"-std=c99",
"-fno-sanitize=undefined",
"-g",
"-O0",
},
});
exe_gl_test.linkLibC();
exe_gl_test.linkSystemLibrary("gl");
exe_gl_test.linkSystemLibrary("glew");
exe_gl_test.linkSystemLibrary("glfw");
if (optimize == std.builtin.Mode.ReleaseSafe) {
exe_gl_test.strip = true;
}
b.installArtifact(exe_gl_test);
// exe.emit_docs = .emit;

const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());

Expand Down
8 changes: 8 additions & 0 deletions resource/shader/base.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#version 330 core

out vec4 FragColor;

void main()
{
FragColor = vec4(1.0f, 0.5f, 0.2f, 0.2f);
}
9 changes: 9 additions & 0 deletions resource/shader/base.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#version 330 core
layout (location = 0) in vec2 pos;

uniform vec4 t; // orthogonal transformation

void main()
{
gl_Position = vec4((pos.x-t.z)*t.x, (-pos.y+t.w)*t.y, 0.0, 1.0);
}
3 changes: 2 additions & 1 deletion src/c.zig
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub const c = @cImport({
@cInclude("GL/gl.h");
// @cInclude("GL/gl.h");
@cInclude("GL/glew.h");
@cInclude("GLFW/glfw3.h");
});
10 changes: 5 additions & 5 deletions src/config.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub const multithreading = true;
/// Globally turn on the General Purpose Allocators (GPAs)
/// verbose output
pub const debug_allocator = false;
pub const sub_sampling_base = 4;
pub const sub_sampling_base = 2;
pub const sub_sampling_blocky = false;

pub const fnt = struct {
Expand All @@ -28,7 +28,7 @@ pub const fnt = struct {
};

pub const gfx = struct {
pub const depth_levels_max = 8;
pub const depth_levels_max = 32;
pub const fps_target = 60; // Hz
pub const scale_by = ScalePreference.room_height;
pub const ambient_normal_shading = 0.4; // interval [0, 1]
Expand All @@ -43,10 +43,10 @@ pub const gfx = struct {
};

pub const rc = struct {
pub const map_display_every_nth_line = 4;
pub const map_display_height = 0.3;
pub const map_display_every_nth_line = 1;
pub const map_display_height = 0.9;
pub const map_display_opacity = 0.5;
pub const map_display_reflections_max = 2;
pub const map_display_reflections_max = 32;
pub const segments_max = gfx.depth_levels_max-1;
pub const segments_splits_max = 2;
pub const threads_max = 16;
Expand Down
Loading

0 comments on commit ade3807

Please sign in to comment.