Repo containing my code: https://github.com/safron1111/DignDig, So for the past 2 days I have been looking all through my code and looking back at guides and looking things up to try to make a 3D enviornment in OpenGL, so far I have gotten to the point where I am using matrices to make 3D work, but when I moved from 2D rendering to 3D, it hasnt worked and I've really been stumped. I believe its either the matrices or shader code but I am really not sure, the polygon that is meant to render on the ground isn't, and I am not sure if it's because my code isnt set up in the right order or if I am missing something. The goal currently is to render a square polygon facing so that it appears to be on the floor, or atleast something similar, but I have not been able to acheive this, I have tried not using textures, changing to wireframe mode, changing the order of code, and messing with values and matrices, and nothing seems to work, nor do I get any errors. Thanks! (As you can see there is no square visible)
#[SOLVED] Been stuck for 2 days trying to render a 3D polygon in OpenGL using Silk.NET and C#
59 messages · Page 1 of 1 (latest)
you have a lot of code for how much drawing you're doing
why do you have both a class called Camera and a class called CameraClass?
why do you have a tonne of functions called Draw* that don't draw anything, but instead compile and link shaders and fill buffers?
as with all things, I would recommend you start with opening renderdoc, but also I feel like you might need to peel back some layers here too
you're also doing so much stuff in statics that stuff could be going wrong at any point
definitely also try with a regular C# debugger to see if your values make sense
e.g., you are currently reading from _mainWindow before its even set to anything https://github.com/safron1111/DignDig/blob/main/DigNDig/Camera.cs#L29
also note you're doing math with ints here, so your aspect ratio is probably wrong as well, but thats likely not your main issue
mainly because I never knew if I would need previous code and it would be easier to copy from my project than looking it back up or trying to reremember it
because originally the cameraclass was storing code and the camera was meant to be used to initialize a new camera but I didnt end up using it
because I was trying to subdivide things so it would be easier to find the write code since I wouldnt have to look though monolithic blocks and use smaller chunks, but its still not to the point where it wouldve done that effectively
oh my I didnt even realize, sorry ive been sleep deprived writing and rereading the code
this is like the first day ive been properly awake with enough sleep
let me fix that
i think this is only harming, not helping.
as is keeping code around that you're not using
ok ill get rid of the code not being used
anyway, the answer to "why is my screen blank" is to open renderdoc
that should be your first stop
its saying my file format is unrecognized
huh?
you are trying to open your executable as a capture, which is not how your use renderdoc
please read the getting started guide
yeah i tried dragging it in because the launch application wouldnt open a menu
nothing happens after i press it
it doesn't open a menu, it focusses a panel
just spend a little time with it first 😅
i think i found the problem but i dont know how to fix it, i was told you had to load the modelLoc, viewLoc, and projectionLoc, after the program is linked or else they wouldnt get locations on the gpu, and i even tested this myself, and it seemed to be true, however, in renderdoc, its saying im passing "no resource" to the gpu when trying to pass model, view, and projection matrices to the shaders, but i cant send them to the shaders if its already been linked right??
im probably misunderstanding how opengl works
you have to set uniforms after programs are linked, that's correct. what's not correct is that you have to do it immediately or only once. uniforms will get locations if they are used in the shader or is you set then explicitly
im doing it only once but what is immedietely?
because its right after the program is linked
that is immediately
once the program is linked, you can set uniforms whenever you want
so is it just saying no resource for no reason or am i doing it wrong?
i don't know what you are looking at
that means you don't have a valid program bound
so is something here wrong?
i followed how silk.nets documentation does it
i also havent changed this bit of code since it was 2D and untextured (except for defining the shaders)
no that's fine
but you need to bind it to set uniforms
have you gone through learnopengl?
if not if recommend going through it
yes and silk.net documentation
but I was sleep deprived and very tired when I did
i would recommend going through it again
slowly, and not sleep deprived
just reading through it once is not enough, you need to understand everything there
got it
it works
doesnt look right but it works
thank you