#OpenGL CMake Template (glfw+glad+glm+imgui+spdlog+tracy+cgltf+stb_image)
1855 messages · Page 2 of 2 (latest)
being able to reuse the explanations and some of the code would reduce the work a lot I think
ok
2learn2opengl
cool
I did as well when I visited from my phone
i noticed
learnopengl2 is actually happening wtf
accumulation seems to take time for some reason, i see italy and israel, but not us recent viewers (us, de and sg)
what sort of data do you have about me now 
i can see the city where your internet comes out of the wall (where ISP/vpn has their node) what device you use and which sites you look at
my location shows another city than i am currently
every other day its a different city
doesn't deccer live in the walls with you anyways
he knows everything already
Black on black
i think i can follow LearnOpenGL: Remastered as my ogl is still stuck in 3.3 era
i thought of drawing my own
I sometimes use a bit of DSA from the github post
perhaps i should alo make up my mind what i actually want to achieve with this thing
probably a learnopengl lite of sorts
enought glisms explained to get you started, so that youa re able to write a naive deferred renderer perhaps
or a pbr modelviewer
that should cover all sorts of DSA isms, ubo/ssbo and computeisms too
that does sound good. kinda like how logl has this section
ur version can have it be a 3D model viewer
- some proper grouping of things and not willy nilly nonsense like glUniformXy and VAOs
but InputLayout, and how one can group all the state into Pipelineisms
no printf/cout too 🙂
fuck
almost 3am again
🇬🇳
pls no VAOs
spare everyone from the pain of managing that garbage
do vertex pulling only
the explanation: "VAO are legacy bullshit, don't use"
noobs should still understand them
in the hellotriangle part
the whole thing is supposed to be a deterrent for stupid questions in #opengl
You use vertex pulling for everything in GL? Doesn't it have a performance cost?
no
there's a testing thread somewhere in here, zero cost
there's no reason you shouldn't do vertex pulling
simpler
no VAO
no bullshit vertex layout thing
What I remember from that thread was that vertex pulling was at best as fast, and sometimes a little slower
Do you do vertex pulling in Vulkan too? No vertex layouts there either?
vulkan has fixed function vertex fetch because it provides some things that manual pulling does not
namely format conversion
I can't even do vertex layouts if I wanted to given I use mesh shaders 
mesh shaders do not support vertex layouts
btw it's 4% slower for modern GPUs https://docs.google.com/spreadsheets/d/15-V9RFoxj21PoMrfOyVLAMRN0ekejt6iiimWxyThDvk/edit#gid=0
And very slow for mobile GPUs
Just put a little disclaimer
what i want is, that people understand that VAO should be called inputlayout
and that the input layout can be implicit too, since you still describe it in form of struct vertex_t in the vertex shader when you do vertex pulling
you still need a default vao anyway
VAO:
[ ] vertex
[ ] array
[x] object
Khronos started as a room full of monkeys hammering away at typewriters, until one day a young Mark Segal (then working as an intern) found the complete OpenGL 1.0 spec and claimed it as his own
It was at that moment he knew they struck mold
John Khronos
just learned that i can include external files
in me markdown
```cpp title="Application.hpp"
--8<-- "Shared/Application.hpp:5:10"
```
https://deccer.github.io/OpenGL-Getting-Started/ new version is up
OpenGL Getting Started
rewordled intro/setup and first half of basic app
Next button 
I vaguely recall these flags not being compatible for some reason
GIT_TAG 3.3.8
GIT_SHALLOW TRUE
I think I removed all the GIT_SHALLOWisms from my cmake
Embrace cloning the entire history of the repo 
: )
i might mention that some people feel their butt getting hurt when using FetchContent and that an alternative could be submodules, to keep the "USE SUBMODULES YOU IMBECILE" people from posting that
I think fetchcontent is probably easier for a tutorial
it akchually doesnt matter how all the deps are provided
Maybe more can go wrong if you screw up copying cmake though
there is 0 difference, besides the one or 2 seconds one has to wait for fetchcontent to content the fetch
I mean there's a slight difference in how they're written
its just add_directory for the latter
Submodule I think is more intuitive and less magic
thats something the person reading it can figure out later
doesnt have to be part of a tutorial imho
Yeah it's a bikeshed topic for sure
Either choice works fine
I think explanation first
Prime the reader with a piece of info that they can digest
Btw that sentence is weird
I'm going to assume it's lorem ipsum for the purpose of your question
@hazy anchor Sorry I couldnt read up on everything in here. Is the project supposed to work out of the box? So just run it in vscode or is there more to it? The includes do not work for me. We could also discuss this in german if you want (I read up to the german conversation here 🙂 ), but I'm not sure, if others will have problems with the clutter in this thread then 😅
yes it does
Deutsch geht auch
ich hab den thread auch noch fuer ein anderes projekt gehijackt
hm... brauch ich noch ne launch file oder sowas in der Richtung? Also im Moment scheint es bei mir die ProjectApplication.hpp nicht zu includen
gerne 🙂
hast du vscode installert? und dazu die extension "CMake Tools"
ja
ok du brauchst aber nen compiler digga
entweder du installierst noch die Visual Studio Build Tools
oder halt VS komplett fuer c++ 🙂
ich hab einen compiler. Ich habe ja einiges schon gerendered bekommen 😅
eventuell geht auch nochd ieser kack mingw klumpen
ach dann sicher mingw 😛
ok der sollte auch funzen
dann ma weiter im Text... du hast also das repo gekloned mit --recursive hoffentlich, wie in der readme beschrieben?
ne bin auf ubuntu unterwegs. Also nutze sonst immer gcc?
ah
ubuntu, um so besser
ich trottel ging von windows aus weil die meisten hier windows user sind
ok dann is alles gut
also hast gekloned das ding mit --recursive?
ja ist auch einfacher für graphic zeug um ehrlich zu sein 😅
ich glaube schon, war n bisschen hastig dabei. Aber ich bin gut darin sowas zu übersehen. Ich probier es nochmal
ok check, hatte es vorher auch so
kk
dann oeffne mal den ordner wo dus reingekloned hast mit vscode
oder im vscode "ordner oeffnen"
offen
ja
wie gesagt, schon dinge mit cmake und den ganzen bums hier zum laufen gebracht 😄
dann drueck ma ctrl+shift+p und such in der liste nach CMake: Delete Dings & Reconfigure
ah
nur vscode brauchte dafür von mir immer ne extra einladung mit tasks und prelaunch kack
das brauchmer alles ned
macht cmake fuer uns
wenn das alles configuriert hat
guck dir ma unten die status leiste an
muesste so aehnliuch aussehen
mi Debug und gcc und Build und [all]
oh shit. Ich hätte immer nur cmake "starten" müssen anstand mich mit den vscode launch dreck rumzushclagen?
und den 2 buttons da, der kaefer und der play button
jo schaut so aus
dere kaefer started das aktuelle target per debugger 🙂
und play startets ohne debugger
gehts jetz oder wie?
fml ich habe so viel lebenszeit mal wieder verschwendet. Wenn das bei meinen anderen Projekten auch so geht bin ich dir einfach mal doppelt dankbar 😅
nice 🙂
ich hab am anfang auch erst wild f5 gedruekt das er los debuggen soll und das ging natuerlich ned
heiß
sweet
Andere tools binden sich ja doch recht nett ein 😅
Ok, ich habe grade was fürs leben gelernt
jetzt kannste in ProjectApplication Load() und Render() und Update() alles rausschmeisen was du nicht willst/brauchst
oder guckst vorher, vorm loeschen
mega! danke 🙂
was fuer dich sinn macht
texture laden, stbi benutzen oder debug message rausschreiben per spdlog oder so
(ich spring auch nochmal in mein altes projekt zurück um mit diesem neuen wissen dinge zu probieren. werde danach aber wahrscheinlich weiter dein Template nutzen. Ich hasse diese ganze aufsetzen geschichte 😭
riesen dank, dass du dir die zeit genommen hast 🙂
jo kein ding
das ist einfach die imgui demo die da drin schwebt und nicht aufs projekt bezogen oder?
mich hats auch immer angkotzt
japp
und ein oder zwei andere ImGui.XXX calls fuers menue, ah das ding hier hat gar kein menu 😄
Ich bastle grad annem neuen OpenGL Guide, da kommt eins rein
uebrigens knuffiges Tapir (oder was auch immer das fuern fiech is) baby pfp 😄
das passt zu deinem namen
Falls du mal lange Weile haben solltest
vielleicht kannst Du mal gucken ob man in den vs settings die beiden buttons da unten in der status leiste mitnem keyboard shortcut versehen kann, F5 fuer den kaefer und Alt+F5 fuer den play button
jo debug ist sogar standartmäßig ctrl+f5
und run ist shift+f5
einfach ctrl+p
keyboard shortcuts
cmake eingeben
und dort sind die ganzen drin.
Aber vscode hat immer eigene präferenzen was es in bestimmten situationen nimmt, das heißt, es kann sein, dass der eigene debug/run modus das überschreibt
wo hast du eigentlich diesen call hier in deinem template?
glDebugMessageCallback(MessageCallback, 0);
in Application.cpp:124 das ding ist in dem Project.Library ordnerle
@olive dew https://deccer.github.io/OpenGL-Getting-Started/00-setup/00-setup/ and the next page, does it look like its easier to chew?
@safe egret du auch, guck ma drueber
Yeah definitely
you can read more "here"
Aber here ist nicht verlinkt. Wahrscheinlich bezieht es sich auf den link davor, aber dann ist die formulierung komisch
ansonsten super! 👍
ah interesting
my friend is a beginner to graphics programming and I linked him this, but I think it was too much 😄
he was trying to make a project so I suggested cmake instead of vs solutions
then I showed him this project as an exshrimple
and what he do? rage quit? 😄
i started from scratch btw, no tringle yet, only basic window setup, not even Application class or anything
at least not in the markdownisms
nah he's a beginner so it's just too much stuff
C++ sucks to get started with
ah fair enough
but I suggested/he figured that following some guides on cmake would be helpful first
i try to explain cmakeisms too
could probably be a bit more elaborate
OpenGL Getting Started
everything in Main.cpp and 3 cmakelists
ah
: )
if your friend still has feedback besides kwitting, im all ears, perchance it can be massaged into the opengl guide htingy
I think he'll be looking at other stuff first
I do have one suggestion actually
making a copy of that project with the cmake, but an empty main.cpp (so just the dependency crap is done)
a lot of beginners (my friend included) just want to start from scratch without having to fiddle with build systems and dependency bs
I can do it myself tbh, since it's just deleting stuff 😄
ah
I can probably set this up, yeah
have a branch "bare-minimum" or something, which has the cmake setup and an int main() {} so that you can compile
some of the letters are higher than the others 
I think the font is just weird
aaaaaaaaaah
cursed
damn, im so stupid
i did pick a non default font
but it looks quite funny on your screenshot
did you forget a hyperlink here
nope, looks good on yours
i will change the font to some stock font then, so that it looks the same on all platforms
it looks neat like that
it's burning my eyes currently 
looks good now
We should make a list of intermediate steps to full GP
Like, if you have x amount of experience with this and that, start here, if you have y amount + decent math start here, etc
not a bad idea
minimum tringle
now i need to split it up into chunks of explainisms again - ill explain programs, program-pipelines, inputlayout, vb and ib, also debugmessage callback, and also perhaps object labels too, since those are useful for debugging shit - yeah i should renderdoc too here, there are also a few exercises of how to get into finding and fixing issues to prevent getting arrested for opengl crimes
then introduce the whole Application base thing
then textures
then camera, which means ubo - i thought of also adding dear imgui here, so that you can click different camera types perhaps and get lubed in for imgui altogether already
so that you can fly around the tringle - perhaps here also show how to deal with multiple inputlayouts, because thats what the noobs never understand either
then models
and then models without inputlayout and with vertexpulling
this whole coordinate system nonsense i need to source out somehow, i cba to explain it, i barely understand it myself hehe
are program pipelines worth explaining over normal shaders+programs?
imho program pipelines are a simpler mental model or maybe not idk
lemme look them up again
less glAttach/glDetach nonsnense
you can combine programs with each other however you like
the attach/detach thing requires linking again
ah glCreateShaderProgramv
ye looks easier
I'm not familiar with it so idk if drivers fook it up in some way (buggy, worse errors, etc.)
re: the discussion about my friend getting started yesterday
I made this thing to give to him: https://github.com/JuanDiegoMontoya/Unfrogged
tl;dr it's your thing without the explanations and with much less starting code
now he's gonna be looking at learnopengl
hmm hhmm mmhh
i just found something out
with mkdocs you have this typical docs/... structure where all your md files go into the docs basically, and your mkdocs.yml provides the navigation hierarchy of sorts
i just tried something with that include other file thing --8<-- "pathToFile"
docs/
someChapter/
someContentInThatChapter.md <- have this file contain `--8<-- "src/someChapter/README.md"`
src/
someChapter/README.md
and have the actual readme in the project folder the article is talking about
idk if any of what i say makes any sense hehe
or should i keep all docs together up in docs/
hmm github only picks up the readme in the repo root, neh?
does it really?
then this would be cool
i could reuse the chapter docs files as README at the same time when people browse the source
hmm nice
mkdocs.yml cant index into files outside of docs/ hence the "forward" thingy,
hmm mmh ill play with it : )
while looking for a better pic of a shrimple graphics pipeline i schtumbled upon this thing https://www3.ntu.edu.sg/home/ehchua/programming/opengl/CG_BasicsTheory.html
its glut and ffp opengl, but the imagery is quite nice ackchually
hehe i will go ith this one
obviously skipping tess/geom stage, but just mention them should be ok, since they might see those stages in renderdoc at some point
the only mention GS deserves is: "you do NOT use the geometry shader, ever, under any circumstance"
yeah
and i might add links to ogldev's tesselation videos he released a month ago or so, they are not bad
nice renderdoc screenshot 
this sounds odd
We want to render them as lines or points or triangle fans, but mostly triangles
how about
We may want to render them as lines, points, or triangle fans, but for now we'll do a triangle list
the emphasized bit is redundant
Most of the time we want to render triangles because the GPU is super optimized to handle those things and it does it well
not sure if now is the best time to introduce instancing
yep, same, ill just omit that, instancing attributes i could mention later as a side note, that its possible via vaos, but nobody does that
hmm the part after mentioning the blender and assimp is also weird heh
btw you should use glNamedBufferStorage
ah its too bad glfw doesnt run framebuffersizecallback when the window is created
dsa shader program creation doesnt support glProgramParameter ;C since you compile and link at the same time
via glCreateShaderProgramv
that sucks a little
what's the point of glProgramParameter
you can get rid of the out perVertex {} bs in vertex shaders
when you glPRogramParameter(GL_PROGRAM_SEPARABLE, GL_TRUE)
but its not a train smash
hehe
but then i lied as well
because shader pipeloines still require that out PerVertexism
ok, NEVERMIND 😄
john khronos failed once again
writing sucks 😄
i wonder if i should just provide code as is
hehe
I just look at your CMAKE for inspiration
you are downloading glad trough the CMAKE ?
yep, and have it generate the bindings at config time, which is also customiserable there
i also pushed slight fixes to it
more awkward writing https://deccer.github.io/OpenGL-Getting-Started/01-basics/02-basic-window-and-triangle/ up until fragment stage
OpenGL Getting Started
i think i fooked it up a little by adding all the code things for the basicappwithtringle in these stages
or perhaps it could work, idk
@safe egret du musst mal als Meerschweinchen herhalten, bis sich die anderen Jungs ruehren
@olive dew if you have 10? minutes would you mind reading over?
me too : )
I can't decide what the correct level of assumed background for this article is, but I feel like it needs to go one way or the other
Like either it needs more supporting diagrams to teach things like NDC, or you could cut out a fair bit of background by assuming that knowledge
The writing is also fairly conversational, it could be cut down to be more terse
more terse for people with background and more conversational to lube noobs in?
It can be both imo
there was an exercise we did in my writing class in school where we would cut a whole essay down into one paragraph, then into like one sentence, as a sense for how to distill the idea as efficiently as possible
its some what "hard" to decide where to cut... make smaller code chunks to explain the details, or drop more code blobs and summarize
i see
I'm not great at it because I tend to be verbose but at some point I can take an editing pass through it if you want
not today but maybe later on
So do most people's lol dw about it
Your writing isn't really worse than the average native English speaker's
enough to converse with americans hehe
I would like to use this "guide" or tutorial or whatever this can be called, as a drop in for noobs in #opengl
to avoid the "my screen is black" or "my tringle is kaputt" or "0xC0000005" when calling glDrawElements
but also nudge them to write more modern stuff, with pipelines et al in mind
so that they can move to vk more easily in the future
(it also kind of helps/helped me to transition)
Per vertex attribute (we have 2 attributes, Position and Color) we declare what data type each attribute is and of how many components that data type exists.
If you think of Position, usually 3 coordinates, x, y and z, also usually floating points - we have 3 components of type GL_FLOAT. Thats exactly what we describe here.
Same thing for the color attribute. Red, green and blue components, so, also 3 components of type GL_FLOAT.
A vertex may have "attributes" that describe its constituent data.
For instance, our vertex's first attribute is "position," consisting of 3 floating point components. We specify that the 0th attribute of `inputlayout` consists of 3 floats (`GL_FLOAT`), which are not normalized (`GL_FALSE`), and then specify the offset of the `Position` data within our `VertexPositionColor` struct:
glVertexArrayAttribFormat(inputLayout, 0, 3, GL_FLOAT, GL_FALSE, offsetof(VertexPositionColor, Position));
Example revision
At that point you barely even need to explain the color step beyond "this process is repeated for each attribute in the vertex struct"
when you hold it into my face like that, yeah
I think the most important part is making sure the code examples are good and happen in the right order
i agree
Also the difficulty with the "my screen is black" is that those people want a solution with zero effort
another LOGL-length article isn't really going to fix that
after the basic crap, before any first abstraction of inputlayout or anything else
i want to introduce renderdoc and debugcallback
and show them how they can help themselves
with exercises too
like messing with the vertexformat, wrong cullface or winding order
or wrong amount of verticles in glDrawArrays
so that they understand how to use the overlays by example
I would focus on that first then personally
The debugging crash course
it's more focused than trying to write a start to finish guide
ye, i wanted to have the tringle going first though
fair enough
I've just been through this process multiple times, writing what I thought was going to be the "omg it's simple, why don't people just explain it clearly" guide that ends up being long af and not any less confusing than all the others
yeah
i will point them at it
with pics and example code
so that they see the correlation between them
then they might understand the Where Is My Drawcall thing plugin in renderdoc
probably needs adjusting when actual noobs use this thing and get stuck or i wrote it too dumbly
oki, less bla bla
Yeah, you can always elaborate later
yeah was going to say, when i ask for feedback from a noobie they should be able to tell whether its too little or unnecessary
but the writing process invariably involves cutting back the content so keeping it trim to begin with might save time
yeah
does it make sense that i explain the code snippets as i go through the graphics pipeline btw?
mehrschweinchen.. etwas komisch 😅 worum gehts?
Yeah I think it's fine
: ) Lies dir mal den verlinkten artikel durch und sag mir ma ob du das verstehen wuerdest oder ob das alles schinesischer humbug fuer dich ist, wenn du 10 minuten hast oder so
oki, i noticed it towards the end that i was just mixing in that stuff and was like oof 😄
muss selbst heute noch ziemlich viel zeug editieren, um das morgen rumzuschicken (auch text+layout) und werde heute erstmal nicht dazu kommen 🙈
Arne, und wenn du nix dagegen hast werd ich dich oefter anboopen zum gegenlesen
ja kein stress, layout is erstma wurst, wichtig is ob man das als noob versteht oder ob das nur kauderwelsch is
achso dein zeug 😄
die Ausrede lass ich gelten
im so clever soemtimes
i want clearcolor to be in the same pink as the guide 😄
but due to enabled framebuffer srgb this is super bright
so i just take 0.7f, 0.1f, 0.4f and pow it by 2.2 😄
and get 0.45f, 0.0063f, 0.1332f
or at least i thought so
thats the guide-pink
thats 0.7, 0.1, 0.4
when i put that through pow... i get 179, 19, 102 thats weird
eye balled it until it looked similar
hey deccer the cmake master
how do you regenerate the build script using the cached variables at the command line
have not used CLI cmake for years
Ok NVM you just cmake .
I think I was confused because it was a non cache variable I was editing or something so it got overwritten when generating
i just use the cmake tools and shift+ctrl+p -> CMake: Reconfickture
examexercisesples 😄
thats what you get when your brain is offline, and wanted to rename examples to exercises
21:22:23
All state related to the definition of data
used by the vertex processor is encapsulated in a vertex array object.
The name space for vertex array objects is the unsigned integers, with zero
reserved by the GL.
... reserved by the GL 😄
reserved by the gnome loge
man who wrote this
BindVertexArray may also be used to bind an existing vertex array object.
If the bind is successful no change is made to the state of the bound vertex array
object, and any previous binding is broken.
...if its successful nothing changes, and any previous binding is broken...
(young John Connor Khronos)
I cant find the spot where it talks about the default vao in the 🥓
🥓 = bacon 🇺🇸 = speck 🇩🇪 = spec
quite annoying that i cant put exercises right under the actual topic, i have to have some helper thing in there
- Debug Callback: 02-debugging/02-debug-callback.md
- Debug Callback Exercises:
- Exercise 1: 02-debugging/02-debug-callback-exercise-01.md
- Exercise 2: 02-debugging/02-debug-callback-exercise-02.md
- RenderDoc: 02-debugging/03-renderdoc.md
- RenderDoc Exercises:
- Exercise 1: 02-debugging/04-renderdoc-exercise-01.md
- Exercise 2: 02-debugging/04-renderdoc-exercise-02.md
i cant have this
- Debug Callback: 02-debugging/02-debug-callback.md
- Exercise 1: 02-debugging/02-debug-callback-exercise-01.md
- Exercise 2: 02-debugging/02-debug-callback-exercise-02.md
- RenderDoc: 02-debugging/03-renderdoc.md
- Exercise 1: 02-debugging/04-renderdoc-exercise-01.md
- Exercise 2: 02-debugging/04-renderdoc-exercise-02.md
its unsupported : (
i was wondering if we should/could list common errors in the gl get started thing too, after debugcallback/renderdoc chapters or probably in some appendix, if you have more of those, let me know then we can compile those together into some comprehensive unfuck gl list
-
nothing works:
- get rid of GLCALL/GLCHECK macros, most of them use glGetError incorrectly anyway
- setup glDebugMessageCallback see here
- your shaders could contain errors, make sure you check linking state and fix according to what the error was highlighting
-
renderdoc crashes when i try to capture something from my project:
- most likely some of your code is fucked, its rarely renderdoc being fucked in that case
-
screen is black:
- camera (projection/view matrices are fucked) is not looking at the scene in question
- no texture is sampled due to missing or wrong uvs => default value is 0 aka black (depends on the driver)
- no shader bound (especially fragment shader)
- fragment shader doesnt write anything to its output
- no viewport is set/is too small
- you might be rendering to a framebuffer, but not blitting that framebuffer to the default one
- let clearcolor be something else than pure black
-
screen is white:
- perhaps your clearcolor is too, and no texture is sampled due to missing or wrong uvs => default value can be 1
aka white (depends on the driver)
- perhaps your clearcolor is too, and no texture is sampled due to missing or wrong uvs => default value can be 1
-
no visible output:
- check winding order and cullmode, you might be looking at the wrong side of your faces
-
exception when calling glDrawElements - aka "0xC0000005"
- no indexbuffer is bound/associated to the current vao/inputlayout
-
exception when calling glDrawArrays / or worse the driver is crashing
- you probably want to draw more primitives than you have in your vertexbuffer, check arguments of your glDrawArrays call
-
textures are black
- no textures bound
- are your textures complete? if not should produce an output in debug callback, so, go check that (hmm this might not be the case for glXXXTextureStorage i might take this one off the list)
- no samplers bound (check your sampler objects if you use them as separate objects)
- no or fucked uvs
-
textures look funny, like a garbled version of the actual image
- make sure your internalformat and actual pixel format match -> you probably used stb_image to load, but used 0 as the last parameter,
and pixel data has 3 components, instead of the 4 (GL_RGBA) you told OpenGL about -> request 4 channels from stb_image
- make sure your internalformat and actual pixel format match -> you probably used stb_image to load, but used 0 as the last parameter,
-
textures look like one color component is more prominent than others
- colors are more shifted towards blue -> you probably messed up the format and asked for GL_BRG.. of sorts => make sure they match
- colors are more shifted towards red -> original pixeldata was probably in BGR... but you asked for GL_RGB... of sorts => make sure they match
-
render artifacts, like small missing tiles on a floor
- synchronization issues - perhaps a missing glMemoryBarrier at the right spot
- ubo/ssbo alignment issue - check std140/430 rule in the glsl spec
- binding multiple textures to the same slot - check your glBindTextureUnit calls
- you might be using a float to index into a buffer to grab material/texture info, use a flat int
-
depth buffer not cleared
- despite calling glClear(GL_DEPTH_BUFFER_BIT) => check if glDepthMask was set to GL_FALSE or migrate to glClearNamedFramebuffer()
I'd like to add calling glClear(GL_DEPTH_BUFFER_BIT) with glDepthMask(GL_FALSE).
Might be wise to use the other functions for clearing framebuffers to avoid this footgun
So I guess the suggestion should be to use glClearNamedFramebuffer
yea
Oh shit it looks like glClearNamedFramebuffer has the same issue as glClear
kind of makes sense, that depthmask influences clear in any form neh?
Yeah its just kinda a pain in the ass, since when I ask to clear the depth buffer you kinda expect it to be cleared
yeah
i think ill add model and textures first before abstracting anything into application, inputlayout or texture constructs
to a) make people aware of formats, which will come in handy for inputlayouts
and b) when introducing classes later, showing how RAII nonsense works (ie referring to https://www.youtube.com/watch?v=7Qgd9B1KuMQ, rule of 3/5/0)
http://CppCon.org
—
Discussion & Comments: https://www.reddit.com/r/cpp/
—
Presentation Slides, PDFs, Source Code and other presenter materials are available at: https://github.com/CppCon/CppCon2019
—
RAII, or "Resource Allocation is Initialization," is one of the cornerstones of C++. What is it, why is it important, and how do we use it in our ...
hmm
perhaps i should add textures before debugcallback/renderdoc
or ill throw in renderdoc exercises later in between
apparently people use their phone to read this thing 😦
and are surprise that there are more than 1 page
@tacit marsh ill/am abuse/abusing this thread for the thing
turned that opengl thing into an editable gist https://gist.github.com/deccer/dbc53d34a378009c23a432b071273abb
it might get bigger and wont fit into a discord message soon 🙂
yeah thats a good start
or turn it into a project then others can contribute, gists dont have that possiblilitlity it looks like
eventually it would be good to have it part of an actual FAQ instead
as part of the tutorial series
yeah
ah indeed
I think the exception when calling glDrawElements could be expanded a little
"error reading location 0x0000000000000000" or whatever
And have one for "error executing location 0x0000" when calling any GL function, which indicates that gl pointers haven't been loaded yet
why does this not work
if (auto graphicsPipelineResult = graphicsPipelineBuilder
.WithInputLayout("PositionUv", std::to_array<const InputLayoutElement>(
{
{.Location = 0, .BindingIndex = 0, .AttributeFormat = Format::R32G32B32_FLOAT, .Offset = offsetof(VertexPositionUv, Position)},
{.Location = 1, .BindingIndex = 0, .AttributeFormat = Format::R32G32_FLOAT, .Offset = offsetof(VertexPositionUv, Uv)},
}))
.WithShaders("Data/Shaders/Simple.vs.glsl", "Data/Shaders/Simple.fs.glsl")
.WithPrimitiveTopology(PrimitiveTopology::Triangles)
.Build())
{
_graphicsPipeline = graphicsPipelineResult.value();
}
GraphicsPipelineBuilder& GraphicsPipelineBuilder::WithInputLayout(
std::string_view inputLayoutLabel,
std::span<InputLayoutElement> inputLayoutElements)
i dont understand how a 2 element array cannot be a span of the same type
Idk
you mean std::span<InputLayoutElement>(std::to_array<const InputLayoutElement>( ... ))? 😄
hmm seems to be explicitly supported 🤔
this code also worked before in a slightly different project
oh you mean std::span<const InputLayoutElement>
Ah that's different
can't bind temporary std::array to non-const constructor
yet another wrong default amirite
what can I say I'm a brain genius
i forgot the add the const on the WithIL function
but i cant use const here anymore anyway
GraphicsPipelineBuilder& GraphicsPipelineBuilder::WithInputLayout(
std::string_view inputLayoutLabel,
std::span<const InputLayoutElement> inputLayoutElements)
{
_graphicsPipelineDescriptor._inputLayoutLabel = inputLayoutLabel;
_graphicsPipelineDescriptor._inputLayoutElements = inputLayoutElements;
return *this;
}
because then the 2nd line wont work, because of const
cppisms
: D
by also just doing this std::span<const InputLayoutElement> _inputLayoutElements; here
weird that the error message swallowed the const
yeah its a weird one
tbf there isn't actually a const anywhere
its just that the const overload is the only one that will accept a temporary array, so when you try to construct a non-const span, both array constructors are disabled
bit fucky
🪣 🐻❄️

Impawstor detected (that's not a bear paw)
I just wanted to make a silly pun
rule of zero when 😔
as soon as i switched off, i knew the solution :B
[2023-12-02 20:17:13.509] [error] Building graphics gipeline "Simple" failed. �\UU�G��� graphics pipeline Simple. Details: pUU�G��� rogram VS_Program_Simple: 0(14) : error C1503: undefined variable "i_poXsition"
i have no idea where that garbage is coming from, when i step through where i thought the source is, it looks clean
its probably something with me not using string_views properly
I've actually never been to poipelione
its ez to go there
you just let your fingers become butter fingers
while typiong pipeloine
its one of those words which are hard to type hehe, like them ending on -ililibility
ah like flaot
yeah
flase
treu, hibgut
havent seen falot in the wild either yet , i mean flaot
i enjoy those little typos
they also bring amusement to jaker
i found the spot where its fucked, but im not sure how to fix it
auto infoLogLength = 0;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength);
std::vector<char> v(infoLogLength);
glGetProgramInfoLog(program, 1024, &infoLogLength, v.data());
std::string infoLog(v.begin(), v.end());
return std::unexpected(infoLog);
infoLog is garbled when i render expected.error() further up
what is the error type?
std::string
hmm thats strange
i had return std::unexpected(std::format("Unable to link program blabla {} {}", ..., infoLog));
wait whats the 1024 here
the maximum length
but that's not the maximum length
hang on a second
bababooey
not quite there yet 😄
this should be the right call
glGetProgramInfoLog(program, infoLogLength, nullptr, v.data());
but its still garbled
also why allocate a vector and copy into a string when you can just allocate the string with the right length from the beginning
immediately after the call or further up the call stack?
yes
auto infoLogLength = 0;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength);
auto infoLog = std::string(infoLogLength + 1, '\0');
glGetProgramInfoLog(program, infoLogLength, nullptr, infoLog.data());
return std::unexpected(infoLog);
i have tried a bunch of things, vector was just one of them
further up the callstack
aaaaaaaaaaaaaaaaaaaaah
foudn it
for some weird raisin, one of methods returning std::expected... had an string_view error type 
Wth is return std::unexpected
lol
Ah it got removed and replaced lol
that'd do it
Was reading this lmao
https://en.cppreference.com/w/cpp/error/unexpected
😄
std::expected<std::tuple<uint32_t, uint32_t, uint32_t>, std::string> GraphicsPipelineBuilder::CreateProgram(
std::string_view label,
std::string_view vertexShaderSource,
std::string_view fragmentShaderSource)
{
...
``` i mustve gotten distracted here by all the SVs
same in c# 🙂
you can even do one better
Result<(uint Program, uint VertexShader, uint FragmentShader), ...
ah yes, a struct
named tuple
ah yes... a struct
but yea, is a struct pretty much
[2023-12-02 21:15:44.115] [error] Building graphics pipeline "Simple" failed. Unable to link "Program-Simple-VS" Details: 0(14) : error C1503: undefined variable "i_poXsition"
I liked the corrupted one better
: )
It had more character
hmm looks like cmake's post/prebuild target thing doesnt pickup changes in the filesystem
but custom targets do
add_custom_command(
TARGET GameClient
PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Data ${CMAKE_CURRENT_BINARY_DIR}/Data
)
will be replaced by
add_custom_target(copy_data
ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Data ${CMAKE_CURRENT_BINARY_DIR}/Data
)
add_dependencies(GameClient copy_data)
hmm weird
when i do vertex pulling the vertices are in CW
when i dont to vertex pulling the verticles are in CCW
weeeeeeeeird : ) vertexbuffer is bound as ssbo, only shows 2 items, although i write 3, size is correct et al
ahaaaa vertex shader was fucked
Blessed pipeline
@tacit marsh in opengl you mentioned glDrawElements can be used with VP, but im a little puzzled how
glDrawElements is based on a bound EBO, via a VAO, isnt it?
no, bc you still don't need to specify a vertex format
and you can still generate vertex data however you want
from ssbos, textures, generated on the fly etc
ah so i just bind the ebo to the default vao
ebo doesnt care about the vertex attribs
correct
i don't think you were ever dumb :)
just gotta remember it's technically an optimisation.
: D
anyway, i literally just have a bind_index_buffer that hides the vao as an implementation detail lol
yeah same
ez
i would like to be a tiny bit explicit when constructing the pipeline
right now i have something like .WithInputLayout(...)
which constructs an actual vao
for VP im thinking of having a .WithDefaultInputLayout(), .WithNoInputLayout() or .WithInputLayoutForVertexPulling() naming is hard
so that when i do gfxpipeloine->BindIndexBuffer(indexBuffer); knows which vao to use
ye thats impl detail
use them only for vertex format, and always rebind buffers
can you just not specify an input layout?
i could do that too
then the gfxplbuilder will know when an inputlayout was requested or not and when not vp will be assumed
ye, perhaps better
ultimately the pipeline doesn't need to care if you're using vp right? just either you're pushing data through attributes from buffers attached to a vao or you aren't - you can bind ssbos and co in both cases
the pipeline object i create defines the gl state to be set when the pipeline is bound
until a new pipeline is bound
load:
_pipeline = _device->CreatePipelineBuilder().XXX().XXX().XXX().Build();
render:
_device->BeginRenderToFramebuffer/ToSwapchain()
_device->BindPipeline(_pipeline)
_device->EndRender()
right, so either it binds vbos to the vao or it doesn't. does it actually need to know what vertex pulling is
no
thats why i will leave out that WithNoInputLayout nonsens, and only have WithInputLayout when i actually want one
sick
that emoji 😄
it's one of my favourites
looks like you clap your finger and thumb kwikly and it makes some noise hence the particles hehe
didnt see the fidget spinner first
i need to untangle this channel somehow 😄
i keep mixing 5 projects in this one
moving opengl-getting-started out into https://discord.com/channels/318590007881236480/1181289212251742238
OpenGL CMake Template (glfw+glad+glm+imgui+spdlog+tracy+cgltf+stb_image)
hey hey, i love the idea of having an openGL template and it seems really amazing, I just have a slight suggestion, could you please add a little more "how to get started" text in the readme (like from git clone-ing to compiling the project and building an executable) for dumb and ambitious beginners like me who probably should take a class on C++ and properly learn makefiles before attempting graphics programming
thank you
(for context: i ran git clone, cmake CMakeLists.txt, then make, and now i don't know what to next. i just wanna run the build now. can't find a ./app file anywhere either)
i see the opengl-getting-started repo. i'll look through that rn
@ivory totem hmm are you talking about this one? https://github.com/deccer/OpenGL-Getting-Started or this one? https://github.com/deccer/CMake-Glfw-OpenGL-Template
ah i see, i should have read first : )
ok
so
sprintf is tracy's stuff as others pointed out
and yes i should hide warnings from dependencies so that warnings treated as errors dont block you from building
weird that it happens on mac though, also no surprise
the build artifact (binary/library or whatever) should usually sit in ./build/ somewhere
you are also the first mac person
and i also think it wont even run on mac, because im targeting gl4.6 by default, but anyway, that can be massaged
fear not
you just have to kick a bunch out of there then
or sell your mac and get an actual PC 😛
you need cmake and ninja installed
vscode's plugin too as described in the readme, then clone
then it should be enough to adjust the following files
actually not that much needs adjusting
just glNamedBufferData needs to be replaced with its nonDSA counterpart in https://github.com/deccer/CMake-Glfw-OpenGL-Template/blob/main/src/Project/ProjectApplication.cpp#L144
there are 3 occurencies
with glBufferData after those glBindBufferBase calls i think that should work
hmm glMultiDrawElementsIndirect wont though, thats a gl4.3 thing
you can emulate that with a loop and glDrawElementsIndirect
glTextureStorage2D is also a gl4.5 thing
well, thats one reason why i dont target macos : >
you could remove all the code and keep the skellington, and then slowly add your own thing, if you want, or take the template as a guide
at least for the cmake bits
@ivory totem
i have another repo, which might work for you
clone this repo https://github.com/deccer/OpenGL-Getting-Started and then git checkout 83272858fe8def06171ddf7634f917212531ef49
its a cmake project
actually, i did find this one to work ! https://github.com/ArthurSonzogni/OpenGL_CMake_Skeleton
but i'll try yours
would be easiest to get support from the person who actually made the repo :)
you need to make 2 adjustments though
for macos
change this line https://github.com/deccer/OpenGL-Getting-Started/blob/83272858fe8def06171ddf7634f917212531ef49/src/01-BasicTriangle-nonDSA/Main.cpp#L186 to 1 and this one https://github.com/deccer/OpenGL-Getting-Started/blob/83272858fe8def06171ddf7634f917212531ef49/src/01-BasicTriangle-nonDSA/Main.cpp#L188
GLFW_OPENGL_CORE_PROFILE needs to be set to GLFW_FORWARD_COMPATIBLE i think its called
because macos sucks
alright changed the two
this should work then
if you have cmake and the cmake tools for vscode installed
ideally ninja too
Users/x/Desktop/Programming/cpp/OpenGL-Getting-Started-2/src/01-BasicTriangle-DSA/Main.cpp:186:41: error: use of undeclared identifier 'GLFW_FORWARD_COMPATIBLE'
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_FORWARD_COMPATIBLE);
uh oh
fook
i probably misspelled it
use your google foo to find the right one
ah fuck it, here it is GLFW_OPENGL_FORWARD_COMPAT
./01-BasicTriangle-DSA
[2023-12-18 11:51:06.707] [error] GLFW: Error Invalid OpenGL profile 0x00022006
[2023-12-18 11:51:06.707] [error] GLFW: Unable to create window
(base) rain
hmm mmh
yeah
you are supposed to try that with the nonDSA variant
find that status bar
click on [all] and select the nonDSA thing, then click on the bug icon
that starts the debugger
if you select nonDSA on the right where i have [Fuk] atm, and press the play button, then it will just run it not attach a debugger
@ivory totem
Btw I ran this at my friend's house last night and I have some complaints to file
I suppose I could fix it myself but that would be hard
The main issue I had was that for some reason intellisense couldn't figure out any of the API calls, it gave errors (but things still built)
No his machine is much newer than mine
I think something to do with having glad in a separate project may confuse VS or something
Or confuse intellisense rather
weirdly enough clion and vs were weird yesterday for me too
with glad
it would never be a ble to find glad/gl.h
but when i use vscode + cmake plugin it would just work
Idk what the best solution is for this with cmake since the way glad is often used isn't really fitting the CMake paradigm
best workaround is download glad, and add it as a library
I'm just going to send him one of my project templates to keep things simple
into libs/glad
Also it would be nice if the template didn't impose the application structure and just had a single-file main.cpp hello triangle
Maybe as another branch or something idk
then ```cmake
add_library(glad
glad/src/glad.c)
target_include_directories(glad PUBLIC glad/include)
and in your main project target_link_libraries(YourProjectWhatever PRIVATE glad glfw glm) as usual, and the include header is different in the manual one
its <glad/glad.h> there
ill fix that tomorrow (the single file project setup)
could your friend try out vscode + cmake plugin?
with the current cmake-template
im curious if that still works
Idk how to use vscode
make him join, i can explain 🙂
I am trying to teach him so it would probably be easier for me to try just it myself or something
He hasn't done significant projects before
I'm sure it probably works, I don't really want to go installing more toolchain stuff on my machine
It's just an issue with the way visual studio kind of segregates projects probably
Oh lol
No
are you saying you just discovered something or is this ongoing
ah
With the template or without?
with this one
because mf didnt want to use the cmake template
but now that the template isnt working either anymore... something's fishy
the latest commit in the dummy repo switched to manual glad
yeah so did the template
template is using v1 of glad though
and i have another c++ shit project on my disk here using glad's v2 generator which also works
hmm
which version of vs is he using?
mayhaps msft messed something up again
I doubt it, this is a VS2019 I installed on his machine like 2 years ago
im on windows right now, let me pull the template rq
Basically the same as what I'm using
]
[45/45] Linking CXX executable src\Project\Project.exe
Rebuild All succeeded.
thats with vs (2022)
Yeah like I said it did compile just fine
It's just that intellisense had no idea what was going on
and all the GL calls were underlined red and stuff
oh that idk
and when i tried it myself it wouldnt find anything glad either
although glad was generated properly
when intellisense is fucked, restarting vs usually helps, and also deleting the .vs folder after closing/before restarting it
This was like a brand new clone of the repo
I didn't try that but figured it didn't have much time to get messed up
Nah I used the CMake GUI and just pressed open project like I always do when using CMake on windows