Closed Gishblade closed 4 months ago
Oh, and important to note that this bug is present for versions v4.5.0 and v5.0.0 of this binding.
github.com/gen2brain/raylib-go/raylib v0.0.0-20230511170620-d84e4cc82f8d // indirect - version 4.5.0 github.com/gen2brain/raylib-go/raylib v0.0.0-20231123174446-48309e2407b7 // indirect - version 5.0.0.
Unsure if it is an issue with the bindings or raylib.
@Gishblade Maybe you are missing a rl.Begin
and rl.End
?
I've got the Begin/End for both BeginDrawing and BeginMode3D.
I don't think there's a third one needed?
Is this an issue with just the Go bindings or Raylib in general?
// Draw a grid centered at (0, 0, 0)
void DrawGrid(int slices, float spacing)
{
int halfSlices = slices/2;
rlBegin(RL_LINES);
for (int i = -halfSlices; i <= halfSlices; i++)
{
if (i == 0)
{
rlColor3f(0.5f, 0.5f, 0.5f);
rlColor3f(0.5f, 0.5f, 0.5f);
rlColor3f(0.5f, 0.5f, 0.5f);
rlColor3f(0.5f, 0.5f, 0.5f);
}
else
{
rlColor3f(0.75f, 0.75f, 0.75f);
rlColor3f(0.75f, 0.75f, 0.75f);
rlColor3f(0.75f, 0.75f, 0.75f);
rlColor3f(0.75f, 0.75f, 0.75f);
}
rlVertex3f((float)i*spacing, 0.0f, (float)-halfSlices*spacing);
rlVertex3f((float)i*spacing, 0.0f, (float)halfSlices*spacing);
rlVertex3f((float)-halfSlices*spacing, 0.0f, (float)i*spacing);
rlVertex3f((float)halfSlices*spacing, 0.0f, (float)i*spacing);
}
rlEnd();
}
@Gishblade I think you missed a Begin() and End(), which is the Go call for rlBegin and rlEnd. This is what DrawGrid does internally as well.
@gen2brain Think this issue can be closed then.
oh, so in my case raylib needs
rl.Begin() rl.BeginDrawing() rl.BeginMode3D()
to render correctly, and the examples mostly get away without explicitly calling rl.Begin() because they happen to call DrawGrid() which calls into rl.Begin()
?
Is it intended for users to call rlBegin() themselves?
I don't see a Begin() method in the cheetsheet (just BeginDrawing, BeginMode2D, BeginMode3D, etc.) suggesting it's supposed to be for internal use?
rlBegin()
is part of rlgl. rlgl is a low level API for OpenGL.
It's meant to be used by advanced users.
I've noticed a weird issue where my shader does not work correctly until
rl.DrawGrid(0, 1.0)
is called at least once (it does not need to be called every frame)Video of Bug: https://www.youtube.com/watch?v=lKa4bVZqznE
I suspect it is related to how textures get loaded in the shader.
My rendering loop is
when
modelCase != 2
it does not use my shader at all, and code works as expected (even when not callingrl.DrawGrid(0, 1.0)
.My custom shader is
Importantly, if I change
to
It renders the models original texture (what is being passed by
texture0
) just fine.So the issue seems to be that it does not load the
arguments correctly until after
rl.DrawGrid(0, 1.0)
is called for some reason.