This commit is contained in:
tavo 2025-10-30 23:19:41 -06:00
parent 7a3bd9094e
commit 89773f7117
2 changed files with 62 additions and 2 deletions

2
external/skr vendored

@ -1 +1 @@
Subproject commit 0c374728fd7a2a622a3894be9f807b86a2f92f95 Subproject commit 2472372886571bcc38893e2c2424ce4f198f16a7

View file

@ -17,9 +17,69 @@ int main(void) {
glewInit(); glewInit();
SkrTriangle(&state); // SkrTriangle(&state);
#include <main/shaders/texture.frag.c>
#include <main/shaders/texture.vert.c>
SkrShader shaders[] = {
{GL_VERTEX_SHADER, texture_vert, NULL},
{GL_FRAGMENT_SHADER, texture_frag, NULL},
};
GLuint prog =
m_skr_gl_create_program_from_shaders(shaders, sizeof(shaders));
static SkrShaderProgram program = {.Backend.GL.ID = 0};
program.Backend.GL.ID = prog;
static SkrVertex vertices[] = {
{{0.5f, 0.5f, 0.0f}, {1.0f, 0.0f, 0.0f}, {0}, {1.0f, 1.0f}},
{{0.5f, -0.5f, 0.0f}, {0.0f, 1.0f, 0.0f}, {0}, {1.0f, 0.0f}},
{{-0.5f, -0.5f, 0.0f}, {0.0f, 0.0f, 1.0f}, {0}, {0.0f, 0.0f}},
{{-0.5f, 0.5f, 0.0f}, {1.0f, 1.0f, 0.0f}, {0}, {0.0f, 1.0f}},
};
static unsigned int indices[] = {0, 1, 3, 1, 2, 3};
// Make mesh
static SkrMesh mesh = {
.Vertices = vertices,
.VertexCount = 4,
.Indices = indices,
.IndexCount = 6,
.Program = &program,
};
// Make model
static SkrModel model = {
.Meshes = &mesh,
.MeshCount = 1,
};
const char* paths[] = {"assets/container.jpg",
"assets/awesomeface.png"};
unsigned int tex_ids[2];
m_skr_gl_load_textures_2d_from_paths(paths, tex_ids, 2);
static SkrTexture textures[2] = {0};
for (int i = 0; i < 2; i++) {
textures[i].Backend.GL.ID = tex_ids[i];
textures[i].Type =
(i == 0) ? SKR_TEXTURE_DIFFUSE : SKR_TEXTURE_SPECULAR;
}
model.Textures = textures;
model.TextureCount = 2;
state.Models = &model;
state.ModelCount = 1;
glUseProgram(prog);
m_skr_gl_shader_set_int(prog, "texture1", 0);
m_skr_gl_shader_set_int(prog, "texture2", 1);
while (!SkrShouldClose(&state)) { while (!SkrShouldClose(&state)) {
glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
SkrRendererRender(&state); SkrRendererRender(&state);
} }