/
redgpu
/
raygpu
Обзор
Документация
Войти
/
redgpu
/
raygpu
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/pipeline_basic.c
44 строки
1 KB
manuel
ooooooooof
24 авг 2025, 01:29
24 авг 2025, 01:29
1357b67
Код
Авторство
О чём код?
#include <raygpu.h> #ifdef __EMSCRIPTEN__ #include <emscripten.h> #endif VertexArray* vao; DescribedBuffer* vbo; DescribedPipeline* pipeline; void mainloop(cwoid){ BeginDrawing(); ClearBackground(BLACK); BeginPipelineMode(pipeline); BindShaderVertexArray(pipeline, vao); DrawArrays(RL_TRIANGLES, 3); EndPipelineMode(); DrawFPS(0,0); EndDrawing(); } int main(void){ InitWindow(800, 600, "The Render Pipeline"); const char* resourceDirectoryPath = FindDirectory("resources", 3); char* shaderSource = LoadFileText(TextFormat("%s/simple_shader.wgsl", resourceDirectoryPath)); float vertices[6] = { 0,0, 1,0, 0,1 }; vbo = GenVertexBuffer(vertices, sizeof(vertices)); vao = LoadVertexArray(); VertexAttribPointer(vao, vbo, 0, WGPUVertexFormat_Float32x2, 0, WGPUVertexStepMode_Vertex); EnableVertexAttribArray(vao, 0); pipeline = LoadPipeline(shaderSource); float uniformData[4] = {0,0,0,0}; SetTargetFPS(0); #ifndef __EMSCRIPTEN__ while(!WindowShouldClose()){ mainloop(); } #else emscripten_set_main_loop(mainloop, 0, 0); #endif }