probably final commit
This commit is contained in:
parent
81bdfd478c
commit
f6bfd40e05
7 changed files with 49 additions and 53 deletions
|
@ -1,51 +1,56 @@
|
|||
[
|
||||
{
|
||||
"directory": "/home/sam/Documents/Projects/brimstone",
|
||||
"directory": "/home/sam/Documents/Projects/brimstone-sdlgpu",
|
||||
"arguments": ["/usr/bin/gcc", "-c", "-g", "-O0", "-Isrc", "-DDEBUG", "-I", "/home/sam/.xmake/packages/s/stc/v4.2/bfec6d3335d54b48969cc50946a9b5ac/include", "-I", "/home/sam/.xmake/packages/c/cglm/v0.9.4/02efbe15d36b48b6bf756a5d63445178/include", "-o", "build/.objs/brimstone/linux/arm64/debug/src/brimstone/io/file.c.o", "src/brimstone/io/file.c"],
|
||||
"file": "src/brimstone/io/file.c"
|
||||
},
|
||||
{
|
||||
"directory": "/home/sam/Documents/Projects/brimstone",
|
||||
"directory": "/home/sam/Documents/Projects/brimstone-sdlgpu",
|
||||
"arguments": ["/usr/bin/gcc", "-c", "-g", "-O0", "-Isrc", "-DDEBUG", "-I", "/home/sam/.xmake/packages/s/stc/v4.2/bfec6d3335d54b48969cc50946a9b5ac/include", "-I", "/home/sam/.xmake/packages/c/cglm/v0.9.4/02efbe15d36b48b6bf756a5d63445178/include", "-o", "build/.objs/brimstone/linux/arm64/debug/src/brimstone/io/copy_pass.c.o", "src/brimstone/io/copy_pass.c"],
|
||||
"file": "src/brimstone/io/copy_pass.c"
|
||||
},
|
||||
{
|
||||
"directory": "/home/sam/Documents/Projects/brimstone",
|
||||
"directory": "/home/sam/Documents/Projects/brimstone-sdlgpu",
|
||||
"arguments": ["/usr/bin/gcc", "-c", "-g", "-O0", "-Isrc", "-DDEBUG", "-I", "/home/sam/.xmake/packages/s/stc/v4.2/bfec6d3335d54b48969cc50946a9b5ac/include", "-I", "/home/sam/.xmake/packages/c/cglm/v0.9.4/02efbe15d36b48b6bf756a5d63445178/include", "-o", "build/.objs/brimstone/linux/arm64/debug/src/brimstone/graphics/transfer_buffer.c.o", "src/brimstone/graphics/transfer_buffer.c"],
|
||||
"file": "src/brimstone/graphics/transfer_buffer.c"
|
||||
},
|
||||
{
|
||||
"directory": "/home/sam/Documents/Projects/brimstone",
|
||||
"directory": "/home/sam/Documents/Projects/brimstone-sdlgpu",
|
||||
"arguments": ["/usr/bin/gcc", "-c", "-g", "-O0", "-Isrc", "-DDEBUG", "-I", "/home/sam/.xmake/packages/s/stc/v4.2/bfec6d3335d54b48969cc50946a9b5ac/include", "-I", "/home/sam/.xmake/packages/c/cglm/v0.9.4/02efbe15d36b48b6bf756a5d63445178/include", "-o", "build/.objs/brimstone/linux/arm64/debug/src/brimstone/graphics/upload.c.o", "src/brimstone/graphics/upload.c"],
|
||||
"file": "src/brimstone/graphics/upload.c"
|
||||
},
|
||||
{
|
||||
"directory": "/home/sam/Documents/Projects/brimstone",
|
||||
"directory": "/home/sam/Documents/Projects/brimstone-sdlgpu",
|
||||
"arguments": ["/usr/bin/gcc", "-c", "-g", "-O0", "-Isrc", "-DDEBUG", "-I", "/home/sam/.xmake/packages/s/stc/v4.2/bfec6d3335d54b48969cc50946a9b5ac/include", "-I", "/home/sam/.xmake/packages/c/cglm/v0.9.4/02efbe15d36b48b6bf756a5d63445178/include", "-o", "build/.objs/brimstone/linux/arm64/debug/src/brimstone/graphics/command_buffer.c.o", "src/brimstone/graphics/command_buffer.c"],
|
||||
"file": "src/brimstone/graphics/command_buffer.c"
|
||||
},
|
||||
{
|
||||
"directory": "/home/sam/Documents/Projects/brimstone",
|
||||
"directory": "/home/sam/Documents/Projects/brimstone-sdlgpu",
|
||||
"arguments": ["/usr/bin/gcc", "-c", "-g", "-O0", "-Isrc", "-DDEBUG", "-I", "/home/sam/.xmake/packages/s/stc/v4.2/bfec6d3335d54b48969cc50946a9b5ac/include", "-I", "/home/sam/.xmake/packages/c/cglm/v0.9.4/02efbe15d36b48b6bf756a5d63445178/include", "-o", "build/.objs/brimstone/linux/arm64/debug/src/brimstone/graphics/shaders.c.o", "src/brimstone/graphics/shaders.c"],
|
||||
"file": "src/brimstone/graphics/shaders.c"
|
||||
},
|
||||
{
|
||||
"directory": "/home/sam/Documents/Projects/brimstone",
|
||||
"directory": "/home/sam/Documents/Projects/brimstone-sdlgpu",
|
||||
"arguments": ["/usr/bin/gcc", "-c", "-g", "-O0", "-Isrc", "-DDEBUG", "-I", "/home/sam/.xmake/packages/s/stc/v4.2/bfec6d3335d54b48969cc50946a9b5ac/include", "-I", "/home/sam/.xmake/packages/c/cglm/v0.9.4/02efbe15d36b48b6bf756a5d63445178/include", "-o", "build/.objs/brimstone/linux/arm64/debug/src/brimstone/graphics/device.c.o", "src/brimstone/graphics/device.c"],
|
||||
"file": "src/brimstone/graphics/device.c"
|
||||
},
|
||||
{
|
||||
"directory": "/home/sam/Documents/Projects/brimstone",
|
||||
"directory": "/home/sam/Documents/Projects/brimstone-sdlgpu",
|
||||
"arguments": ["/usr/bin/gcc", "-c", "-g", "-O0", "-Isrc", "-DDEBUG", "-I", "/home/sam/.xmake/packages/s/stc/v4.2/bfec6d3335d54b48969cc50946a9b5ac/include", "-I", "/home/sam/.xmake/packages/c/cglm/v0.9.4/02efbe15d36b48b6bf756a5d63445178/include", "-o", "build/.objs/brimstone/linux/arm64/debug/src/brimstone/graphics/pipeline.c.o", "src/brimstone/graphics/pipeline.c"],
|
||||
"file": "src/brimstone/graphics/pipeline.c"
|
||||
},
|
||||
{
|
||||
"directory": "/home/sam/Documents/Projects/brimstone",
|
||||
"directory": "/home/sam/Documents/Projects/brimstone-sdlgpu",
|
||||
"arguments": ["/usr/bin/gcc", "-c", "-g", "-O0", "-Isrc", "-DDEBUG", "-I", "/home/sam/.xmake/packages/s/stc/v4.2/bfec6d3335d54b48969cc50946a9b5ac/include", "-I", "/home/sam/.xmake/packages/c/cglm/v0.9.4/02efbe15d36b48b6bf756a5d63445178/include", "-o", "build/.objs/brimstone/linux/arm64/debug/src/brimstone/init/systems.c.o", "src/brimstone/init/systems.c"],
|
||||
"file": "src/brimstone/init/systems.c"
|
||||
},
|
||||
{
|
||||
"directory": "/home/sam/Documents/Projects/brimstone",
|
||||
"directory": "/home/sam/Documents/Projects/brimstone-sdlgpu",
|
||||
"arguments": ["/usr/bin/gcc", "-c", "-g", "-O0", "-Isrc", "-DDEBUG", "-I", "/home/sam/.xmake/packages/s/stc/v4.2/bfec6d3335d54b48969cc50946a9b5ac/include", "-I", "/home/sam/.xmake/packages/c/cglm/v0.9.4/02efbe15d36b48b6bf756a5d63445178/include", "-o", "build/.objs/brimstone/linux/arm64/debug/src/brimstone/main.c.o", "src/brimstone/main.c"],
|
||||
"file": "src/brimstone/main.c"
|
||||
},
|
||||
{
|
||||
"directory": "/home/sam/Documents/Projects/brimstone-sdlgpu",
|
||||
"arguments": ["/usr/bin/gcc", "-c", "-g", "-O0", "-Isrc", "-DDEBUG", "-I", "/home/sam/.xmake/packages/s/stc/v4.2/bfec6d3335d54b48969cc50946a9b5ac/include", "-I", "/home/sam/.xmake/packages/c/cglm/v0.9.4/02efbe15d36b48b6bf756a5d63445178/include", "-o", "build/.objs/brimstone/linux/arm64/debug/src/brimstone/misc/malloc.c.o", "src/brimstone/misc/malloc.c"],
|
||||
"file": "src/brimstone/misc/malloc.c"
|
||||
}]
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
#version 460
|
||||
|
||||
layout(location = 0) in vec4 vertColor;
|
||||
layout(location = 1) in vec2 vertTexCoords;
|
||||
|
||||
layout(location = 0) in vec2 vertTexCoords;
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
|
||||
layout(set = 2, binding = 0) uniform sampler2D Sampler;
|
||||
layout(set = 2, binding = 0) uniform sampler2D textureSampler;
|
||||
|
||||
void main() {
|
||||
fragColor = texture(Sampler, vertTexCoords) * vertColor;
|
||||
fragColor = texture(textureSampler, vertTexCoords);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
#version 460
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in vec3 aColor;
|
||||
layout(location = 2) in vec2 aTexCoords;
|
||||
|
||||
layout(location = 0) out vec4 vertColor;
|
||||
layout(location = 1) out vec2 vertTexCoords;
|
||||
layout(location = 1) in vec2 aTexCoords;
|
||||
layout(location = 0) out vec2 vertTexCoords;
|
||||
|
||||
layout(set = 1, binding = 0) uniform UBO {
|
||||
mat4 viewproj;
|
||||
|
@ -14,7 +11,6 @@ layout(set = 1, binding = 0) uniform UBO {
|
|||
|
||||
void main() {
|
||||
vertTexCoords = aTexCoords;
|
||||
vertColor = vec4(aColor, 1.0f);
|
||||
|
||||
mat4 mvp = viewproj * model;
|
||||
gl_Position = mvp * vec4(aPos, 1.0f);
|
||||
|
|
|
@ -27,7 +27,7 @@ SDL_GPUGraphicsPipeline* GraphicsPipelineCreate(SDL_GPUDevice* device, SDL_Windo
|
|||
.pitch = sizeof(Vertex),
|
||||
},
|
||||
},
|
||||
.num_vertex_attributes = 3,
|
||||
.num_vertex_attributes = 2,
|
||||
.vertex_attributes = (SDL_GPUVertexAttribute[]){
|
||||
{
|
||||
.buffer_slot = 0,
|
||||
|
@ -35,16 +35,10 @@ SDL_GPUGraphicsPipeline* GraphicsPipelineCreate(SDL_GPUDevice* device, SDL_Windo
|
|||
.location = 0,
|
||||
.offset = offsetof(Vertex, pos),
|
||||
},
|
||||
{
|
||||
.buffer_slot = 0,
|
||||
.format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3,
|
||||
.location = 1,
|
||||
.offset = offsetof(Vertex, color),
|
||||
},
|
||||
{
|
||||
.buffer_slot = 0,
|
||||
.format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2,
|
||||
.location = 2,
|
||||
.location = 1,
|
||||
.offset = offsetof(Vertex, texcoords),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
#ifndef VERTEX_H
|
||||
#define VERTEX_H
|
||||
|
||||
#include <cglm/cglm.h>
|
||||
|
||||
typedef struct {
|
||||
struct {
|
||||
float x, y, z;
|
||||
} pos;
|
||||
struct {
|
||||
float r, g, b;
|
||||
} color;
|
||||
struct {
|
||||
float x, y;
|
||||
} texcoords;
|
||||
vec3 pos;
|
||||
vec2 texcoords;
|
||||
} Vertex;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,10 +10,10 @@ int main(int argc, char** argv) {
|
|||
LogAssertSDL(success, "Failed to claim window for device");
|
||||
|
||||
Vertex vertices[] = {
|
||||
{ { -0.5f, 0.5f, 0.0f }, { 1.0f, 1.0f, 1.0f }, { 0.0f, 0.0f } }, // top left
|
||||
{ { -0.5f, -0.5f, 0.0f }, { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f } }, // bottom left
|
||||
{ { 0.5f, -0.5f, 0.0f }, { 1.0f, 0.0f, 0.0f }, { 1.0f, 1.0f } }, // bottom right
|
||||
{ { 0.5f, 0.5f, 0.0f }, { 1.0f, 1.0f, 1.0f }, { 1.0f, 0.0f } }, // top right
|
||||
{ { -0.5f, 0.5f, 0.0f }, { 0.0f, 0.0f } }, // top left
|
||||
{ { -0.5f, -0.5f, 0.0f }, { 0.0f, 1.0f } }, // bottom left
|
||||
{ { 0.5f, -0.5f, 0.0f }, { 1.0f, 1.0f } }, // bottom right
|
||||
{ { 0.5f, 0.5f, 0.0f }, { 1.0f, 0.0f } }, // top right
|
||||
};
|
||||
int indices[] = { 0, 1, 2, 2, 3, 0 };
|
||||
|
||||
|
@ -45,10 +45,15 @@ int main(int argc, char** argv) {
|
|||
ShaderFree(device, vertex_shader);
|
||||
ShaderFree(device, fragment_shader);
|
||||
|
||||
const char* path = "image.jxl";
|
||||
success = IMG_Init(IMG_INIT_JPG);
|
||||
LogAssertSDL(success, "Failed to initialize SDL_image");
|
||||
|
||||
const char* path = "image.jpg";
|
||||
SDL_Surface* image = IMG_Load(path);
|
||||
LogAssertSDLf(image != NULL, "Failed to load image: %s", path);
|
||||
|
||||
printf("%d %d\n", image->w, image->h);
|
||||
|
||||
if(image->format != SDL_PIXELFORMAT_ABGR8888) {
|
||||
SDL_Surface* converted = SDL_ConvertSurface(image, SDL_PIXELFORMAT_ABGR8888);
|
||||
SDL_DestroySurface(image);
|
||||
|
@ -108,8 +113,8 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
glm_mat4_identity(ubo.model);
|
||||
/*glm_rotate(
|
||||
ubo.model, glm_rad(sinf(SDL_GetTicks() / 200.0f) * 50.0f), (vec3){ 0.5f, 1.0f, 0.2f });*/
|
||||
glm_rotate(
|
||||
ubo.model, glm_rad(sinf(SDL_GetTicks() / 200.0f) * 50.0f), (vec3){ 0.5f, 1.0f, 0.2f });
|
||||
|
||||
SDL_PushGPUVertexUniformData(cmd, 0, &ubo, sizeof(ubo));
|
||||
|
||||
|
@ -145,7 +150,6 @@ int main(int argc, char** argv) {
|
|||
1);
|
||||
SDL_DrawGPUIndexedPrimitives(render_pass, sizeof(indices), 1, 0, 0, 0);
|
||||
SDL_EndGPURenderPass(render_pass);
|
||||
|
||||
CommandBufferSubmit(cmd);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,13 +6,17 @@
|
|||
#include <SDL3/SDL_log.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define LogInfof(fmt, ...) SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, fmt, __VA_ARGS__)
|
||||
#define LogDebugf(fmt, ...) SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, fmt, __VA_ARGS__)
|
||||
#define LogWarnf(fmt, ...) SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, fmt, __VA_ARGS__)
|
||||
#define LogErrorf(fmt, ...) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, fmt, __VA_ARGS__)
|
||||
#define LogCriticalf(fmt, ...) SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, fmt, __VA_ARGS__)
|
||||
#define LogTracef(fmt, ...) SDL_LogTrace(SDL_LOG_CATEGORY_APPLICATION, fmt, __VA_ARGS__)
|
||||
#define LogVerbosef(fmt, ...) SDL_LogVerbose(SDL_LOG_CATEGORY_APPLICATION, fmt, __VA_ARGS__)
|
||||
#ifndef LOG_CATEGORY
|
||||
#define LOG_CATEGORY SDL_LOG_CATEGORY_APPLICATION
|
||||
#endif
|
||||
|
||||
#define LogInfof(fmt, ...) SDL_LogInfo(LOG_CATEGORY, fmt, __VA_ARGS__)
|
||||
#define LogDebugf(fmt, ...) SDL_LogDebug(LOG_CATEGORY, fmt, __VA_ARGS__)
|
||||
#define LogWarnf(fmt, ...) SDL_LogWarn(LOG_CATEGORY, fmt, __VA_ARGS__)
|
||||
#define LogErrorf(fmt, ...) SDL_LogError(LOG_CATEGORY, fmt, __VA_ARGS__)
|
||||
#define LogCriticalf(fmt, ...) SDL_LogWarn(LOG_CATEGORY, fmt, __VA_ARGS__)
|
||||
#define LogTracef(fmt, ...) SDL_LogTrace(LOG_CATEGORY, fmt, __VA_ARGS__)
|
||||
#define LogVerbosef(fmt, ...) SDL_LogVerbose(LOG_CATEGORY, fmt, __VA_ARGS__)
|
||||
|
||||
#define LogAssertf(condition, fmt, ...) \
|
||||
do { \
|
||||
|
|
Loading…
Add table
Reference in a new issue