C
C#•2w ago
Yhuot

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
cap5lut
cap5lut•2w ago
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/
MODiX
MODiX•2w ago
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!
Yhuot
YhuotOP•2w ago
It is humongous, but yes, i can, do you need the whole (almost an) engine or just the graphics part?
cap5lut
cap5lut•2w ago
basically everything that touches opgengl first ;p
Yhuot
YhuotOP•2w ago
oke
cap5lut
cap5lut•2w ago
if its not that much code, u can also use discord embedded $code
MODiX
MODiX•2w ago
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/
Yhuot
YhuotOP•2w ago
BlazeBin - iehmsgjedhpg
A tool for sharing your source code with the world!
Yhuot
YhuotOP•2w ago
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
Yhuot
YhuotOP•2w ago
BlazeBin - wsqpfsxvcnxk
A tool for sharing your source code with the world!
Yhuot
YhuotOP•2w ago
brb also thanks for responding
cap5lut
cap5lut•2w ago
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
Yhuot
YhuotOP•2w ago
you mean, like, for 3D? they're needed for the hello triangle?
cap5lut
cap5lut•2w ago
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 MochaPot.Engine ur stuff? 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 CoffeeShop.Open(); and GL.DrawTriangle([0.0f, .5f, 0f, -.5f, -.5f, 0f, .5f, -.5f, 0f]);
Yhuot
YhuotOP•2w ago
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
Yhuot
YhuotOP•2w ago
BlazeBin - iehmsgjedhpg
A tool for sharing your source code with the world!
BlazeBin - iehmsgjedhpg
A tool for sharing your source code with the world!
Yhuot
YhuotOP•2w ago
these files pardon my delay, was cooking
cap5lut
cap5lut•2w ago
oh wow, i didnt notice that paste.mod.gg had tabs xD
Yhuot
YhuotOP•2w ago
lol 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
cap5lut
cap5lut•2w ago
hmmm tbh i dont see something obvious right now
Yhuot
YhuotOP•2w ago
well this is concerning this means that, everything is apaprently in place
cap5lut
cap5lut•2w ago
im not an expert at this either
Yhuot
YhuotOP•2w ago
do you reckon i should ask this in the graphical language server? i see
cap5lut
cap5lut•2w ago
i would at a shit ton of checks like Console.WriteLine($"GL errors? {GL.GetError()}"); to see if anything goes wrong anywhere
Yhuot
YhuotOP•2w ago
oh, 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
cap5lut
cap5lut•2w ago
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 😂 )
Yhuot
YhuotOP•2w ago
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
cap5lut
cap5lut•2w ago
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
Yhuot
YhuotOP•2w ago
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!
cap5lut
cap5lut•2w ago
viewport and matrices are the things that usually go wrong ;p im glad that my random guessing helped a bit 😉

Did you find this page helpful?