direct c import
This commit is contained in:
11
main.sx
11
main.sx
@@ -2,7 +2,7 @@
|
||||
#import "modules/sdl3.sx";
|
||||
#import "modules/opengl.sx";
|
||||
#import "modules/math";
|
||||
|
||||
stb :: #import "modules/stb.sx";
|
||||
|
||||
WIDTH :f32: 800;
|
||||
HEIGHT :f32: 600;
|
||||
@@ -33,7 +33,6 @@ main :: () {
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LESS);
|
||||
|
||||
print("create program: {}\n{}\n", VERT_SHADER_SRC, FRAG_SHADER_SRC);
|
||||
program := create_program(VERT_SHADER_SRC, FRAG_SHADER_SRC);
|
||||
glUseProgram(program);
|
||||
|
||||
@@ -97,7 +96,7 @@ main :: () {
|
||||
|
||||
glBindVertexArray(vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, 1152, @vertices, GL_STATIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, 1152, xx vertices, GL_STATIC_DRAW);
|
||||
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, 0, 32, xx 0);
|
||||
glEnableVertexAttribArray(0);
|
||||
@@ -188,7 +187,7 @@ create_program :: (vert_src: [:0]u8, frag_src: [:0]u8) -> u32 {
|
||||
}
|
||||
|
||||
compile_shader :: (shader_type : u32, source: [:0]u8) -> u32 {
|
||||
shader : u32 = glCreateShader(shader_type);
|
||||
shader := glCreateShader(shader_type);
|
||||
glShaderSource(shader, 1, source, null);
|
||||
glCompileShader(shader);
|
||||
|
||||
@@ -202,7 +201,7 @@ compile_shader :: (shader_type : u32, source: [:0]u8) -> u32 {
|
||||
return shader;
|
||||
}
|
||||
|
||||
VERT_SHADER_SRC : string = #string GLSL
|
||||
VERT_SHADER_SRC : [:0]u8 = #string GLSL
|
||||
#version 330 core
|
||||
layout (location = 0) in vec3 aPos;
|
||||
layout (location = 1) in vec3 aNormal;
|
||||
@@ -217,7 +216,7 @@ void main() {
|
||||
}
|
||||
GLSL;
|
||||
|
||||
FRAG_SHADER_SRC : string = #string GLSL
|
||||
FRAG_SHADER_SRC : [:0]u8 = #string GLSL
|
||||
#version 330 core
|
||||
in vec3 vNormal;
|
||||
in vec3 vPos;
|
||||
|
||||
Reference in New Issue
Block a user