Silk.NET.OpenGL + Silk.NET.SDL, can't render vertexes/shapes
After naively deciding to make my own game engine in C#, i've ran into a problem, i finally managed to get the window to appear, but aside from clear colors, i can't seem to get triangles or points to render, i've checked, and the context is active, the shaders are (allegedly) compiled, loaded and used, before you ask, yes! i used teh goddamn AI to teach me how to use the API, no, i didn't "over rely" on it, i did not tell the AI to generate an engine (that's not even possible, methinks), i'm dumb, but not dumb enough to just have AI make my code and then complain when it doesn't work, please do not just reduce it to "sounds like an AI problem", anyway, if anyone wishes to see the code and help me figure out what i am forgetting when rendering triangles, please do respond to thread, thank you in advance.
more info:
-The window opens.
-The class i've made to represent a triangle is in fact reporting to be rendered.
30 Replies
can u $paste the code?
also while sparse, there are some getting started docs for Silk.NET.OpenGl:
https://dotnet.github.io/Silk.NET/docs/opengl/
If your code is too long, you can post to https://paste.mod.gg/, save, and copy the link into chat for others to see your shared code!
It is humongous, but yes, i can, do you need the whole (almost an) engine or just the graphics part?
basically everything that touches opgengl first ;p
oke
if its not that much code, u can also use discord embedded $code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif in chat
For longer snippets, use: https://paste.mod.gg/BlazeBin - iehmsgjedhpg
A tool for sharing your source code with the world!
Program.cs is another assembly
that i'm using to test
any gl calls work
except when i try to draw a triangle
clearing the color works
made it black, blue, whatevs
but not the triangle
i tried following 3 different tutorials online too
idk what piece i'm missing
and yes
this "engine" is a mess
but the messy part (i hope) isn't the part causing the error
i should probably add Barista.cs there too
BlazeBin - wsqpfsxvcnxk
A tool for sharing your source code with the world!
brb
also thanks for responding
tbh there is so much stuff abstracted away, that its hard to follow, but from the code u have shown, in doesnt seem like u set any projection matrix at all
you mean, like, for 3D?
they're needed for the hello triangle?
yes, no matter if 2d or 3d, that matrix sets up how stuff will be rendered, if u dont do that, i dunno what the defaults, but u usually end up seeing nothing
i also see nothing viewport related in there
is that nvm i brain farted
actually it seems by default its set for 2d, so its more a question of how u set up the viewport and some other stuff.
so i would like to see the code for
MochaPot.Engine ur stuff?CoffeeShop.Open(); and GL.DrawTriangle([0.0f, .5f, 0f, -.5f, -.5f, 0f, .5f, -.5f, 0f]);yeah lol
line 17 of CoffeeShop.cs and line 475 of Counter.cs respectively
they're in the same paste.mod.gg set of the first link
BlazeBin - iehmsgjedhpg
A tool for sharing your source code with the world!
BlazeBin - iehmsgjedhpg
A tool for sharing your source code with the world!
these files
pardon my delay, was cooking
oh wow, i didnt notice that
paste.mod.gg had tabs xDlol
I set up the viewport around line 108 of Mug.cs
i'm starting to think that is a bad place for setting up the viewport
hmmm tbh i dont see something obvious right now
well this is concerning
this means that, everything is apaprently in place
im not an expert at this either
do you reckon i should ask this in the graphical language server?
i see
i would at a shit ton of checks like
Console.WriteLine($"GL errors? {GL.GetError()}"); to see if anything goes wrong anywhereoh, i did that
unfortunately
all i got was "NoError"
every step of the way
which is even worse than actually getting an error as you already know
thanks for answering, i think i'll leave this thread open, unless i specifically need to close it, i'll also open it in the OpenGL server if i do find one
hmmm im not sure if u have to do that
gl.UseProgram(...) call in DrawTriangle, but thats more or less my last idea right now
(its been a couple of years since i last touched silk.net/opengl, and im drunk rn 😂 )i mean, the tutorials tell me to use it, i tried using it, and also not using it to see if i get an error, nothing happens, i wish i got at least a crash lol
lmao, perfectly comprehensible
my next step now would be to ignore all the abstractions and everything and simply use the hard coded way from the tutorial to render something, and from that build up the abstraction again
yeah, i think i'll try that on a separate assembly
ty
@cap5lut You were right, i should've checked the viewport earlier
turns out
it was receiving 0 from both the Counter.Height and width
so the drawable area was 0
so nothing was being drawn
TY!
viewport and matrices are the things that usually go wrong ;p
im glad that my random guessing helped a bit 😉