Skip to content
Learn Netverks
-1

Trying to run a basic shader on Visual Studio IDE using Raylib

asked 8 hours ago by @qa-93xpcpoquc5ve4j8j5ac 0 rep · 29 views

c++ visual studio opengl raylib

I'm trying my own tiny shader lang which transpiles to GLSL. I read a few books on openGL and webGL, as well as a book on compilers. Gemini suggested that using Raylib will get rid of much of the boilerplate that glsl requires, so I went with that.

I cloned vcpkg and ran:

.\vcpkg\bootstrap-vcpkg.bat 
vcpkg install raylib:x64-windows  
vcpkg integrate install

then shifted to Visual Studio IDE.

Code is written by me, only suggestions about setting the environment up have been taken from AI.

File 1: main.cpp

#include <raylib.h>

int main()
{
    InitWindow(800, 800, "Test");
    SetTargetFPS(60);

    while (!WindowShouldClose())
    {
        BeginDrawing();

        ClearBackground(BLACK);

        DrawRectangle(0, 0, 800, 800, BLUE);

        EndDrawing();
    }

    CloseWindow();
}

File 2: base.vs

#version 330

in vec3 vertexPosition;
in vec2 vertexTexCoord;
in vec4 vertexColor;

out vec2 fragTexCoord;
out vec4 fragColor;

uniform mat4 mvp;

void main() {
    fragTexCoord = vertexTexCoord;
    fragColor = vertexColor;
    gl_Position = mvp * vec4(vertexPosition, 1.0);
}

File 3: output.fs

#version 330

in vec2 fragTexCoord;
in vec4 fragColor;

out vec4 finalColor;
uniform float time; 

void main() {
    float r = fragTexCoord.x + sin(time) * 0.5;
    float g = fragTexCoord.y;
    finalColor = vec4(r, g, 0.5, 1.0);
}

However, while the code does run, all I get is a white screen and the console log. The screen remains white no matter what I put in the code, I've tried all red, all blue, etc.

The Problem

The Log

The Window

Comments on this question (0)

Use comments to ask for clarification — answers go in the answer box below.

Log in to comment on this question.

0 answers

Your answer