diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2020-06-08 09:32:17 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2020-06-08 09:32:17 +0000 |
| commit | 96d5ebf72ac395c57489b567c47d35d4807f1994 (patch) | |
| tree | bf6431a5ae276cd2e59b33c6ec56ebd9a4735195 /src/gl.zig | |
| parent | error handling (diff) | |
| download | glsl-view-96d5ebf72ac395c57489b567c47d35d4807f1994.tar.gz glsl-view-96d5ebf72ac395c57489b567c47d35d4807f1994.zip | |
zig-fmt for low-column-screens
Diffstat (limited to 'src/gl.zig')
| -rw-r--r-- | src/gl.zig | 41 |
1 files changed, 28 insertions, 13 deletions
@@ -1,6 +1,5 @@ const std = @import("std"); const c_allocator = @import("std").heap.c_allocator; -const panic = @import("std").debug.panic; const c = @import("c.zig"); const cfg = @import("config.zig"); @@ -298,14 +297,6 @@ pub const ShaderProgram = struct { c.glUseProgram(self.program_id); } - pub fn attribLocation(self: ShaderProgram, name: [*]const u8) c.GLint { - const id = c.glGetAttribLocation(self.program_id, name); - if (id == -1) { - panic("invalid attrib: {}\n", .{name}); - } - return id; - } - pub fn uniformLocation(self: ShaderProgram, name: [*]const u8) !c.GLint { const id = c.glGetUniformLocation(self.program_id, name); if (id == -1) @@ -399,7 +390,12 @@ pub const UniformCache = struct { } } - c.glGetUniformIndices(self.shader.program_id, @intCast(c.GLsizei, count), existing_names_c.ptr, existing_indices.ptr); + c.glGetUniformIndices( + self.shader.program_id, + @intCast(c.GLsizei, count), + existing_names_c.ptr, + existing_indices.ptr, + ); for (existing_indices) |index, i| { const name = existing_names[i]; @@ -450,7 +446,10 @@ fn initGlShader(source: []const u8, name: []const u8, kind: c.GLenum) !c.GLuint const message = try c_allocator.alloc(u8, @intCast(usize, error_size)); c.glGetShaderInfoLog(shader_id, error_size, &error_size, message.ptr); - std.debug.warn("Error compiling {s} shader:\n{s}\n", .{ name, @ptrCast([*:0]const u8, message.ptr) }); + std.debug.warn( + "Error compiling {s} shader:\n{s}\n", + .{ name, @ptrCast([*:0]const u8, message.ptr) }, + ); return error.CompileError; } @@ -473,12 +472,28 @@ pub const FramebufferObject = struct { c.glGenTextures(1, &self.texture_id); c.glBindTexture(c.GL_TEXTURE_2D, self.texture_id); - c.glTexImage2D(c.GL_TEXTURE_2D, 0, c.GL_RGBA, width, height, 0, c.GL_RGBA, c.GL_UNSIGNED_BYTE, null); + c.glTexImage2D( + c.GL_TEXTURE_2D, + 0, + c.GL_RGBA, + width, + height, + 0, + c.GL_RGBA, + c.GL_UNSIGNED_BYTE, + null, + ); c.glTexParameteri(c.GL_TEXTURE_2D, c.GL_TEXTURE_MIN_FILTER, c.GL_LINEAR); c.glTexParameteri(c.GL_TEXTURE_2D, c.GL_TEXTURE_MAG_FILTER, c.GL_LINEAR); c.glBindTexture(c.GL_TEXTURE_2D, 0); - c.glFramebufferTexture2D(c.GL_FRAMEBUFFER, c.GL_COLOR_ATTACHMENT0, c.GL_TEXTURE_2D, self.texture_id, 0); + c.glFramebufferTexture2D( + c.GL_FRAMEBUFFER, + c.GL_COLOR_ATTACHMENT0, + c.GL_TEXTURE_2D, + self.texture_id, + 0, + ); if (c.glCheckFramebufferStatus(c.GL_FRAMEBUFFER) != c.GL_FRAMEBUFFER_COMPLETE) return error.FBONotComplete; |
