direct c import
This commit is contained in:
11
main.sx
11
main.sx
@@ -2,7 +2,7 @@
|
|||||||
#import "modules/sdl3.sx";
|
#import "modules/sdl3.sx";
|
||||||
#import "modules/opengl.sx";
|
#import "modules/opengl.sx";
|
||||||
#import "modules/math";
|
#import "modules/math";
|
||||||
|
stb :: #import "modules/stb.sx";
|
||||||
|
|
||||||
WIDTH :f32: 800;
|
WIDTH :f32: 800;
|
||||||
HEIGHT :f32: 600;
|
HEIGHT :f32: 600;
|
||||||
@@ -33,7 +33,6 @@ main :: () {
|
|||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDepthFunc(GL_LESS);
|
glDepthFunc(GL_LESS);
|
||||||
|
|
||||||
print("create program: {}\n{}\n", VERT_SHADER_SRC, FRAG_SHADER_SRC);
|
|
||||||
program := create_program(VERT_SHADER_SRC, FRAG_SHADER_SRC);
|
program := create_program(VERT_SHADER_SRC, FRAG_SHADER_SRC);
|
||||||
glUseProgram(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
@@ -97,7 +96,7 @@ main :: () {
|
|||||||
|
|
||||||
glBindVertexArray(vao);
|
glBindVertexArray(vao);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
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);
|
glVertexAttribPointer(0, 3, GL_FLOAT, 0, 32, xx 0);
|
||||||
glEnableVertexAttribArray(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 {
|
compile_shader :: (shader_type : u32, source: [:0]u8) -> u32 {
|
||||||
shader : u32 = glCreateShader(shader_type);
|
shader := glCreateShader(shader_type);
|
||||||
glShaderSource(shader, 1, source, null);
|
glShaderSource(shader, 1, source, null);
|
||||||
glCompileShader(shader);
|
glCompileShader(shader);
|
||||||
|
|
||||||
@@ -202,7 +201,7 @@ compile_shader :: (shader_type : u32, source: [:0]u8) -> u32 {
|
|||||||
return shader;
|
return shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
VERT_SHADER_SRC : string = #string GLSL
|
VERT_SHADER_SRC : [:0]u8 = #string GLSL
|
||||||
#version 330 core
|
#version 330 core
|
||||||
layout (location = 0) in vec3 aPos;
|
layout (location = 0) in vec3 aPos;
|
||||||
layout (location = 1) in vec3 aNormal;
|
layout (location = 1) in vec3 aNormal;
|
||||||
@@ -217,7 +216,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
GLSL;
|
GLSL;
|
||||||
|
|
||||||
FRAG_SHADER_SRC : string = #string GLSL
|
FRAG_SHADER_SRC : [:0]u8 = #string GLSL
|
||||||
#version 330 core
|
#version 330 core
|
||||||
in vec3 vNormal;
|
in vec3 vNormal;
|
||||||
in vec3 vPos;
|
in vec3 vPos;
|
||||||
|
|||||||
6
modules/stb.sx
Normal file
6
modules/stb.sx
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#import c {
|
||||||
|
#include "vendors/stb_image/stb_image.h";
|
||||||
|
#include "vendors/stb_image/stb_image_write.h";
|
||||||
|
#source "vendors/stb_image/stb_image_impl.c";
|
||||||
|
#source "vendors/stb_image/stb_image_write_impl.c";
|
||||||
|
};
|
||||||
7988
vendors/stb_image/stb_image.h
vendored
Normal file
7988
vendors/stb_image/stb_image.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
vendors/stb_image/stb_image_impl.c
vendored
Normal file
2
vendors/stb_image/stb_image_impl.c
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
|
#include "stb_image.h"
|
||||||
1724
vendors/stb_image/stb_image_write.h
vendored
Normal file
1724
vendors/stb_image/stb_image_write.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
vendors/stb_image/stb_image_write_impl.c
vendored
Normal file
2
vendors/stb_image/stb_image_write_impl.c
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||||
|
#include "stb_image_write.h"
|
||||||
5079
vendors/stb_truetype/stb_truetype.h
vendored
Normal file
5079
vendors/stb_truetype/stb_truetype.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
vendors/stb_truetype/stb_truetype_impl.c
vendored
Normal file
2
vendors/stb_truetype/stb_truetype_impl.c
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#define STB_TRUETYPE_IMPLEMENTATION
|
||||||
|
#include "stb_truetype.h"
|
||||||
Reference in New Issue
Block a user