OpenGL Tutorial 2 - Triangle

  Рет қаралды 99,095

Victor Gordan

Victor Gordan

Күн бұрын

Пікірлер: 211
@juanmaaguilaronate3686
@juanmaaguilaronate3686 4 жыл бұрын
I think I've never seen a tutorial as concise and well explained as this one. Pretty nice job!
@VictorGordan
@VictorGordan 4 жыл бұрын
Thank you so much! I'm glad this helped someone :)
@mitchellkelly241
@mitchellkelly241 3 жыл бұрын
Criminally underrated series, amazing work!
@VictorGordan
@VictorGordan 3 жыл бұрын
Thank you! :d
@CHESShireCat
@CHESShireCat 5 күн бұрын
See this is exactly what I wanted to learn from my professor. But he kind of just dropped us into the deep end with no explanation. Thanks for the tutorials you are the only hope for me to pass this class.
@Phidelux
@Phidelux 3 жыл бұрын
Love your series. Small hint here. C++11 introduced raw string literals, which is a really nice feature for multiline string definitions: const char* vs = R"glsl( #version 330 core layout(location = 0) in vec4 aPos; void main() { gl_Position = aPos; } )glsl"; Additionally C/C++ string literals are automatically null terminated. Thus, adding a `\0` at the end of the string literal explicitly, will lead to a one byte larger string literal containing two null bytes at the end.
@VictorGordan
@VictorGordan 3 жыл бұрын
Thanks! Yeah, I've found out about the R" thing a while ago haha ;)
@shubhabrotapal4709
@shubhabrotapal4709 9 ай бұрын
Super beginner friendly tutorial, code comments at the end are cherry on top ❤❤❤
@LowRezCat
@LowRezCat Жыл бұрын
For those who start their journey: This video is the really big step you should do, and once you overcome this challenge, you will go far. You might not see huge results for now. But trust me, you got it! ♥
@nikitaavramov6519
@nikitaavramov6519 Жыл бұрын
hope you are right. I felt like Victor was talking Chinese for half of this video. I have been using After Effects, Photoshop and illustrator. Went through a course of c/c++ and even played around with MASM and made a program that changes pixels on screen when you move your mouse over them (in a virtual box emulating 16 bit DOS os). But still most of these concepts were foreign to me (shaders?). Felt like there is some context to this tutorial I missed. Should I have background somewhere before I continue this series?
@VictorGordan
@VictorGordan Жыл бұрын
​@@nikitaavramov6519 the only background knowledge you need is C++. Don't worry if some things don't make sense now. Continue and they might click in later. Also try to do the exercises from the GitHub repo, that might help ;)
@seanmaddows9790
@seanmaddows9790 Жыл бұрын
Thanks for the advice, this is a tough one.
@prakhargupta1745
@prakhargupta1745 Жыл бұрын
hopefully it gets easier, because this is challenging
@LowRezCat
@LowRezCat Жыл бұрын
@@prakhargupta1745 It is the harder part (at least from my experience), everything else is just calling gl function and understanding C++ better. One tip from me: try to really *read* into things, take your time and analyse your every step. Good luck with you jorney!
@yutsuneko
@yutsuneko 2 жыл бұрын
Ok I finally got it working, now I'm gonna watch the video on repeat and try to understand everything I missed out. Thanks!
@VictorGordan
@VictorGordan 2 жыл бұрын
Good luck :d
@szabotudor
@szabotudor 3 жыл бұрын
This is awesome! I could never understand how VBOs and VAOs work until now.
@VictorGordan
@VictorGordan 3 жыл бұрын
Glad I could help! :)
@menghanzhang
@menghanzhang Жыл бұрын
It's the best tutorial I have seen! I'm doing a year project using OpenGL, it's very useful for me. And what surprises me is that you can make it so clear in such a short time! Thank you very much!
@Combinehuntsmanunit
@Combinehuntsmanunit 2 ай бұрын
amazing tutorials man! i have already worked with open gl for many years using c# and this series helped me a lot while implementing everything again and is still my goto guide when dealing with errors. Amazing videos thanks man!
@VictorGordan
@VictorGordan 3 жыл бұрын
If you are following the tutorials on a Mac and are getting unexpected errors, it might be because of your OS. Here is a possible fix Steve Hewson found: "With the help of a discord commuinity, I realised that it was to with my OS (macOS) Using: glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); after: glfwWindowHint(GLFW_OPENGL_CORE_PROFILE, GLFW_TRUE); resolved the issue. I used: std::cout
@Drmarcus9
@Drmarcus9 3 жыл бұрын
This channel is so underrated, you deserve so much more man
@VictorGordan
@VictorGordan 3 жыл бұрын
Thank you! :')
@BarkingFlame
@BarkingFlame 3 жыл бұрын
I appreciate this series! Thank you for sharing your knowledge
@VictorGordan
@VictorGordan 3 жыл бұрын
No problem :)
@rigbyb
@rigbyb Жыл бұрын
Your tutorials are so much better for understanding OpenGL. Thank you :)
@VictorGordan
@VictorGordan 3 жыл бұрын
I accidentally deleted someone's comment. If you're reading this, sorry for that! Btw, the problem with your fragment shader was that you defined a vec4 but only plugged in 3 values instead of 4.
@anoldeyhrithik
@anoldeyhrithik 2 жыл бұрын
Literally, It is the best OpenGL tutorial I have ever watched. Keep it up 🔥🔥🔥🔥 !!
@dnox428
@dnox428 2 жыл бұрын
i think i wouldn't start actually using openGL without you :D thanks mah boi
@dhruvagrawal3856
@dhruvagrawal3856 3 жыл бұрын
great opengl series! I learned c++ and wanted to learn opengl could not find any good tutorials but found you !!!!! at last I am learning it and can understand the code properly ,it is all thanks to you :)
@VictorGordan
@VictorGordan 3 жыл бұрын
Thank you! Good luck with OpenGL :)
@dhruvagrawal3856
@dhruvagrawal3856 3 жыл бұрын
@@VictorGordan welcome victor, I had a doubt that how can I make smaller triangles......well I guess the number we give in the vertices array, it is the position (x and y ) of the points of triangle thus making 6 arguments 2 * 3 = 6, so I also guess that -1.0f is the left end of our window and 1.0f is the right end, so, I think I should keep the gap between the triangle small, thus resulting in a small triangle, So if this right pls tell me, and if this wrong, pls tell me what should I do Thank you : )......btw I like the exercises you post on your github
@VictorGordan
@VictorGordan 3 жыл бұрын
Yes, you are correct, but you also need to change the y axis of the vertices. An easy way to get a smaller or bigger triangle is to multiply all vertices by a number. If you multiply by 2, it will be twice as big. If you multiply by 0.5, twice as small. Good to know someone actually does the exercises haha
@dhruvagrawal3856
@dhruvagrawal3856 3 жыл бұрын
@@VictorGordan Thank you for replying!!!! Thank you for the reply and I thought a lot of people must have done the exercises helps learning a lot of things........Well I had a doubt that when I complete the series I want to ask how can I make games with it?? mean how to make 2d game or 3d?? can I make a game by drawing the triangle and add collisions etc, Like I know all the stuff like how to make collision and the maths but I dont know how can I make things like infinite scrolling backgrounds, like I dont know how should I implement it and do stuff.Maybe I will learn this ahead in series. But pls rely to my questions...thank you : )
@dhruvagrawal3856
@dhruvagrawal3856 3 жыл бұрын
@@VictorGordan I also wanna know how to make two shapes in a same window??
@Napriiihm
@Napriiihm Жыл бұрын
Nice explanations and I like the training with the Exercises, thanks :)
@VictorGordan
@VictorGordan Жыл бұрын
Glad you looked at the exercises! :)
@shafagh_projects
@shafagh_projects 3 жыл бұрын
You made the best and super organized tutorial of the time. thank you so much
@VictorGordan
@VictorGordan 3 жыл бұрын
Thank you! :]
@justcore69
@justcore69 Жыл бұрын
Thank you for the tutorial. It was very easy to follow and understand all of the code :)
@eenrandomkip2162
@eenrandomkip2162 Жыл бұрын
Thank you so much you explain prety much everything perfectly
@ReleaseTheKraken25
@ReleaseTheKraken25 7 ай бұрын
I want to kiss this man’s face. Great work, these are very well made and your effort shows. I really appreciate the time you spent making these for us and I am excited to continue the series ❤
@voytechj
@voytechj 3 жыл бұрын
@10:50 I have doubts that the order of generating buffers is important, because it only allocates memory by a driver. The order that is important is binding VAO first and then call rest of the functions that modifies VAO as a side effect.
@VictorGordan
@VictorGordan 3 жыл бұрын
Yes, I believe you are right, it is the binding that is important. That makes sense tbh
@juanma9868
@juanma9868 2 жыл бұрын
With this i managed to draw a pentagon, and i feel like im sitting over my own brain. Your tutorial is fucking amazing and clear, thank you!!
@TtEL
@TtEL 4 ай бұрын
12:00 Wouldn't you want to use the size of GLfloat and not float?
@jorgelinares1944
@jorgelinares1944 2 жыл бұрын
Great tutorial, love your channel! It inspired me and I have some plans to make a channel like yours taking some tips from your 1024 subs special video, thanks a lot!
@VictorGordan
@VictorGordan 2 жыл бұрын
Good luck!
@ProUserGamer12
@ProUserGamer12 9 ай бұрын
all vscoder's please do not forget to #include library otherwise it will not define sqrt.
@raum_3035
@raum_3035 5 ай бұрын
Thank you :D
@ProUserGamer12
@ProUserGamer12 5 ай бұрын
@@raum_3035 Welcome.
@_sharkdev_
@_sharkdev_ 2 жыл бұрын
Great series, I've been taking notes! I am having a problem though - I believe I followed the tutorial as shown, but my triangle appears white instead of orange. Where may I have slipped and how could I fix it? Thanks! EDIT: I checked my code with your source code, and I had some things in the wrong order, but mainly I noticed the shader code at the start was missing the "void main() " portion - does that have anything to do with it? It worked after reorganizing and adding that to the shader codes
@VictorGordan
@VictorGordan 2 жыл бұрын
Well, the "main()" function is the code that gets run, so since there was no main function in the fragment shader, nothing happened. The "main()" function is vital
@amanakeet
@amanakeet 6 ай бұрын
A beautiful course, thanks a lot
@boazfortuijn4774
@boazfortuijn4774 11 ай бұрын
For if you want to paste that vertex part: const char* vertexShaderSource = "#version 330 core " "layout (location = 0) in vec3 aPos; " "void main() " "{ " " gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0); " "}\0"; const char* fragmentShaderSource = "#version 330 core " "out vec4 FragColor; " "void main() " "{ " " FragColor = vec4(0.8f, 0.3f, 0.02f, 1.0f); " "} \0";
@racingsnowfox
@racingsnowfox 3 ай бұрын
thx, i had a mistake in it that i couldnt find
@atzek
@atzek 3 жыл бұрын
Hey, I wanted to get familiar with OpenGL, but having watched this video I realized how little knowledge about all of these functions and objects I have. I have no idea what the things like VBO, VAO, binding buffers, creating some programs, vertex attributes etc. are. What do you think would be the best way to get familiar with these concepts? Going through the documentation, learning more about computer graphics or some other resources? Could you recommend anything?
@VictorGordan
@VictorGordan 3 жыл бұрын
Yeah, these things can seem weird at first. But if you just continue on with the series you should start to get a feel for them. Reading the documentation also helps quite a bit. Basically just put them into practice and you'll get used to them ;)
@atzek
@atzek 3 жыл бұрын
@@VictorGordan All right, thanks for the reply :)
@x3n662
@x3n662 8 ай бұрын
GOOD TUTORIAL but one side note... 13:08 For those who had an AMD cpu I recomend to not Delete the VBO
@Snail5008
@Snail5008 3 жыл бұрын
This is awesome! :)
@VictorGordan
@VictorGordan 3 жыл бұрын
Glad u think that! :D
@drimiteros_21
@drimiteros_21 7 ай бұрын
Great video, I resently started messing around with Graphics programming and your videos are gold! I have a question, have you considered making another series using glew instead of glad? As far as I know, glew is easier to work with, but does not provide the flexibility of glad. I followed another tutorial that was using glew and I got to draw a triangle in no time.
@VictorGordan
@VictorGordan 7 ай бұрын
You can use GLAD, doesn't rly make a difference for 99% of the tutorial series
@drimiteros_21
@drimiteros_21 7 ай бұрын
@@VictorGordan Got it, thank you
@walidalrifai2326
@walidalrifai2326 3 жыл бұрын
I am a beginner for this language and I somehow understand the program but I want to know what function to add or change to change the triangle colour. thank you!!
@VictorGordan
@VictorGordan 3 жыл бұрын
You need to modify the vec4 in FragColor in order to change the color of the triangle. In tutorial number 5 I talk more about Shaders (they deal with the colors on the screen). Thanks for watching!
@DidIJustDoThat
@DidIJustDoThat 6 ай бұрын
A while back in math class I was doing simultaneous equations and got that 27 equals to 9(I don't know what was in my mind ). This is how I feel like after watching this video. I have tried reading the learn opengl website and I think I am understanding a small portion of what is happening.
@nicolelyy1757
@nicolelyy1757 3 жыл бұрын
Thanks for the great tutorial!!! Just a small question, may I know why are the coordinates must be between -1 and 1?
@VictorGordan
@VictorGordan 3 жыл бұрын
It's just the way it is. It probably has some nice mathematical properties which allow for some nice tricks inside the OpenGL API. If you want to not have them between -1 and 1 keep watching my videos up to the camera one (or the one before that, can't remember) ;)
@nicolelyy1757
@nicolelyy1757 3 жыл бұрын
@@VictorGordan ohh alright! thank you very much!!!
@SUUHOO-i4g
@SUUHOO-i4g Жыл бұрын
for the next person, if you got the orange or triangle color problem, that's the fragmentshader problem. my problem is the typos in the copying process e.g., "GLuint fragmentShader = glCreateShader(GL_VERTEX_SHADER);" instead of GL_FRAGMENT_SHADER. :)
@mr_fire_6863
@mr_fire_6863 Жыл бұрын
thank you
@rishikeshjaiswal3979
@rishikeshjaiswal3979 Жыл бұрын
For me, this does not work!
@yato_rv
@yato_rv 7 ай бұрын
@@rishikeshjaiswal3979 make sure the fragment shader sourcecode is just as in the video. even if there's only a semicolon missing at the end of the vec4 it won't work
@lobstercrab-neverdie
@lobstercrab-neverdie 7 ай бұрын
nvm the triangles showed up thanks for the video
@awwabasad1117
@awwabasad1117 Жыл бұрын
cool! just one question: when you wrote your vertex data in lines 34... of your program, why did you add "* float(sqrt(3)) / 3" just after the coordinates? on opengl learn it says just the raw coordinates in and of themselves should be sufficient enough (i.e., 0.5f, 0.5f, 0.0f) - unless this has some mathematical reasoning behind it? Ive been trying to write in my own vertices but im just curious as to why you did that Lol. Anyway, huge props for the tutorials, i by far prefer watching videos than reading long articles. Thank you!
@samdavepollard
@samdavepollard 3 ай бұрын
late reply but it's to make the triangle equilateral (all sides the same length, all angles 60 degrees) the vertices in the learnopengl lesson give us a triangle which is almost, but not quite, equilateral; the angles in that one are something like 63.4, 63.4 and 53.2 (degrees)
@awwabasad1117
@awwabasad1117 3 ай бұрын
@@samdavepollard ahh finally after all this time i have an answer! appreciate it
@ВолоддимерТурчинов
@ВолоддимерТурчинов 3 жыл бұрын
Such a nice voice to follow dat tutorials ^^
@VictorGordan
@VictorGordan 3 жыл бұрын
Thank you :)
@PhamAnhKhoa118
@PhamAnhKhoa118 3 жыл бұрын
Hi Victor, I've recently seen a lesson about creating mirror using stencil buffer. In their code, they specify an array of 42 vertices (first 36 vertices for the cube and other 6 vertices for the plane). But then when they draw a plane like a mirror surface, they write this line only without binding a VAO: glDrawArrays(GL_TRIANGLES, 36, 6); So my questions is: Why don't they bind a vertex array object before drawing their cubes or planes and can I do that for my usual code? Thanks a lot for your help!
@VictorGordan
@VictorGordan 3 жыл бұрын
By the looks of it they only have one VBO with all the vertices, and one VAO for both shapes. They don't bind anything because it's likely binded when they creat that object, and since they have no other VAOs, they don't bother binding it again. This is bad practice though. You shouldn't do this normally. Also the second argument of glDrawArrays is the starting index of thr vertices, while the third one is the amount of vertices. So they probably did smth like this. // They created the VBO and VAO and in the process binded them // They did not unbind the VAO ... ... ... // They draw the plane glDrawArrays(GL_TRIANGLES, 36, 6); // They draw the cube glDrawArrays(GL_TRIANGLES, 0, 36); Personally I would use indices, and I would bind my VAOs before drawing thdm tho 😬
@anuragbhatt28
@anuragbhatt28 3 жыл бұрын
My triangle is white in color while his was orange. I have rechecked my code but still haven't found any error can someone help me?
@VictorGordan
@VictorGordan 3 жыл бұрын
Usually it is an error in the code (got this q lots of time). I suggest rechecking the code :) Probably smth wrong with the fragment shader code
@TrungTran-rz6tz
@TrungTran-rz6tz 3 жыл бұрын
I have a question about exercise 3. When modifying `glVertexAttribPointer`, why do we have to write `2 * sizeof(float)` for the `stride` parameter? I found this in the documentation: "If stride is 0, the generic vertex attributes are understood to be tightly packed in the array" So if we have 2 floats per generic vertex attribute, we can totally just leave `stride = 0` right?
@VictorGordan
@VictorGordan 3 жыл бұрын
Yup, you can just use stride 0. I just prefer specifying the stride so that I don't get into the habbit of leaving it on 0. Cause you will have many situations in which it won't be 0 and it will bite you in the back :p
@TrungTran-rz6tz
@TrungTran-rz6tz 3 жыл бұрын
@@VictorGordan I see, thanks for the quick reply man. Your series and the repo is awesome by the way :) Very easy to follow for beginners of this subject, great job!
@VictorGordan
@VictorGordan 3 жыл бұрын
Thank you and good luck with the tutorials :)
@Доелкашусвареньем
@Доелкашусвареньем 3 жыл бұрын
Thank you for the tutorial! What do you think about using glfwSwapInterval() function? The compiled program takes 70% of GPU without v sync and it is funny because it is just a window doing nothing. That is why I am concerned about this. When I set swap interval to 1 task manager showes only about 4% of GPU. Don't you have the same behaviour on your computer?
@VictorGordan
@VictorGordan 3 жыл бұрын
Oh yeah, you should definetly use VSync (glfwSwapInterval). I just forgot to add it in this tutorial 😅
@pedrolimon8275
@pedrolimon8275 2 жыл бұрын
Nice video bro!
@VictorGordan
@VictorGordan 2 жыл бұрын
Thanks! :)
@skizzme
@skizzme 6 ай бұрын
My only complaint about your videos is that youtube didnt recommend them soon enough lol
@NamelessY
@NamelessY 2 жыл бұрын
5:50 btw I didn't understand what it meant that we are using only one string
@VictorGordan
@VictorGordan 2 жыл бұрын
It means the whole shader code is written in one string, not multiple
@NamelessY
@NamelessY 2 жыл бұрын
Ok thx
@rishikeshjaiswal3979
@rishikeshjaiswal3979 Жыл бұрын
Why is my triangle white? I changed the fragment shader colors as well, but still the problem persists.
@harishkumarlaxmikantgajako1044
@harishkumarlaxmikantgajako1044 2 жыл бұрын
Awesome Tutorials sir. But How do we make lines from given set of points?
@VictorGordan
@VictorGordan 2 жыл бұрын
You use GL_LINES or GL_LINE_STRIP instead of GL_TRIANGLES when drawing the data
@atlasflare7824
@atlasflare7824 2 жыл бұрын
I think using sqrt needs #include . Source code does not have this, or maybe I am missing something. Thanks for the series.
@VictorGordan
@VictorGordan 2 жыл бұрын
Huh, that's actually really weird 😅 I usually just use functions and only include libraries if I need to, so that's why I didn't notice I forgot to include it. I think it still works because it might be included in GLFW, so since I am including GLFW, I'm also including the math library ;) But yeah, probably should have included it more specifically!
@theingegnere
@theingegnere 2 жыл бұрын
Hi. I am having some questions: 1)how you can compile using sqrt() without adding math.h ? 2) when I instance glGenVertexArrays my window crashes. On the website I checked that this can be solved using gl/glew.h which we are not using here. Where I am wrong? Thank you.
@VictorGordan
@VictorGordan 2 жыл бұрын
1) Do I not have math.h? If not, just add it in yours 2) glew is another library that does what glad does in the tutorial. If if crashes, you probably missed a step or did something wrong. Or, your system might not support OpenGL 3.3+ because it's old.
@theingegnere
@theingegnere 2 жыл бұрын
@@VictorGordan Thanks for the reply. I repeated all instead using Dev C++, VS 2022 and it works well. One of the point I missed is the generation of the glfw3.h via cmake instead of downloading the repository directly. Thanks for you great tutorials.
@stevehewson8677
@stevehewson8677 3 жыл бұрын
Hi, saying that this is a brilliant tutorial is an understatement. Not only did I understand OpenGL, but also the graphics pipeline basics. It compiles fine but when I run, I keep getting “Segmentation fault: 11”. I even tried to compile your code directly as well, but same result. Any hints on where I could correct this?
@VictorGordan
@VictorGordan 3 жыл бұрын
Thank you for the kind words! First try seeing if you still get the error when running the VS project I left in the source code on GitHub. Then if that still fails, you might be running out of RAM? From what I've heard that error can be attributed to many things, so it's hard to pinpoint to something specific... Hope that helps!
@stevehewson8677
@stevehewson8677 3 жыл бұрын
​@@VictorGordan Thanks a lot for the quick help. With the help of a discord commuinity, I realised that it was to with my OS (macOS) Using: glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); after: glfwWindowHint(GLFW_OPENGL_CORE_PROFILE, GLFW_TRUE); resolved the issue. I used: std::cout
@abhaychandavar1766
@abhaychandavar1766 3 жыл бұрын
@@stevehewson8677 thanks man, I was facing the same issue, this comment should be pinned
@VictorGordan
@VictorGordan 3 жыл бұрын
@@abhaychandavar1766 I'm onto it ;)
@christiancompiles5549
@christiancompiles5549 Жыл бұрын
Wonderbar.
@urizilber7545
@urizilber7545 2 жыл бұрын
Very informative
@VictorGordan
@VictorGordan 2 жыл бұрын
Thx! ^-^
@footballCartoon91
@footballCartoon91 2 жыл бұрын
why so many functions to call just to render a static single screen buffer
@HibaSf-w7w
@HibaSf-w7w Жыл бұрын
How can i draw two square the first square include the second square
@techtycho4752
@techtycho4752 3 жыл бұрын
Why did we add 'y-axis * float(sqrt(3)) / 3' to every y-axis value in the vertices array?
@VictorGordan
@VictorGordan 3 жыл бұрын
Just because I wanted to make the triangle equilateral. You can put any value there. Sqrt(3) is the length of the height of an equilateral triangle with sides of length 2. And for the bottom vertices I divide it by 3 because that's the distance from the center of the triangle to the bottom side, while for the top vertex I divide it by 3 and multiply by 2 cause that's the distance from the top of the triangle to the center of it. So basically...just maths haha
@techtycho4752
@techtycho4752 3 жыл бұрын
@@VictorGordan Many Thanks!
@VictorGordan
@VictorGordan 3 жыл бұрын
@@techtycho4752 No problem :)
@MKR30
@MKR30 2 жыл бұрын
There is a memory leak in this program. Do you know if it is an OpenGL bug or something different? ~207k bytes in ~2700 blocks still reachable according to valgrind.
@VictorGordan
@VictorGordan 2 жыл бұрын
I doubt OpenGL has a bug. Might be GLFW or my code
@danlol2720
@danlol2720 3 жыл бұрын
I'm doing the exercises, and I can't understand question 1 on Medium. Why 6 coordinates? And why do some of them repeat?
@VictorGordan
@VictorGordan 3 жыл бұрын
Well there is no square primitive. The only polygon primitive in OpenGL is the triangle. So that means that everything has to be rendered using triangles. In this case you learnt how to draw a triangle by specifying three positions for the vertices of the triangle. So if you want to make a square, you need to specify 2 triangles x 3 vertices each = 6 vertices ;) Hope that helps!
@danlol2720
@danlol2720 3 жыл бұрын
@@VictorGordan Oh I see thank you!
@Byynx
@Byynx Жыл бұрын
When i use the function glEnableVertexAttribArray() i get an Access Violation error but if i remove it i have no errors. Can someone help me?
@Byynx
@Byynx Жыл бұрын
It was because i did'nt set the Vertex Array Object "VAO".
@utilizator1701
@utilizator1701 2 жыл бұрын
I have errors like glCreateShader, GL_VERTEX_SHADER, GL_FRAGMENT_SHADER is udentified. I included iostream, glad/glad.h and GLFW/glfw3.h. What library should I use?
@VictorGordan
@VictorGordan 2 жыл бұрын
Sounds like you didn't integrate GLAD properly. Did you follow the installation tutorial?
@utilizator1701
@utilizator1701 2 жыл бұрын
@@VictorGordan Initially no. After following your first tutorial, all the functions has been found. Thank you!
@sjoerdev
@sjoerdev 3 жыл бұрын
for compute shaders i need opengl version 4.3 or higher. what files would i have to change to opdate the opengl version used in the project?
@VictorGordan
@VictorGordan 3 жыл бұрын
You need to get a newer version of Glad for the specific version of OpenGL you wish to use, and change all the parts of your code that specify a version (so the first few glfw lines and the first line of each shader). Hope that helps :)
@sjoerdev
@sjoerdev 3 жыл бұрын
@@VictorGordan tnx that helped. Also, in the source code for dear imgui i can only find backend files for opengl2 and opengl3, but not for opengl4?
@VictorGordan
@VictorGordan 3 жыл бұрын
The opengl3 should work for opengl4 ;) I believe it is more about the arhitecture than the version itself. From OpenGL 3.0 the arhitecture changed a lot from what I've heard, that's why there are two versions for ImGUI
@sjoerdev
@sjoerdev 3 жыл бұрын
@@VictorGordan thank you so much, this got my so confused lmao. Now i can finally start using compute shaders!
@MustaphaMond-tt3pt
@MustaphaMond-tt3pt Жыл бұрын
Thank you
@VictorGordan
@VictorGordan Жыл бұрын
No problem :)
@TheMangovnik
@TheMangovnik 3 жыл бұрын
Everything works for me, just the triangle is white instead of orange. I checked the fragment shader, but it doesn't look like there is error in it.
@VictorGordan
@VictorGordan 3 жыл бұрын
Hmmm, double check that both your shaders are working fine, otherwise I don't see what else it could be...
@TheMangovnik
@TheMangovnik 3 жыл бұрын
@@VictorGordan I poked around the shaders and it works now. Dunno what I did, probably some obscure typo or something.
@VoidloniXaarii
@VoidloniXaarii Жыл бұрын
Thanks a lot
@dhanushkumarmudupur7287
@dhanushkumarmudupur7287 Жыл бұрын
Why do my triangle comes out as black, even though the code is same as yours??
@VictorGordan
@VictorGordan Жыл бұрын
Most common problem in this case is a typo within the fragment shader 😅
@dhanushkumarmudupur7287
@dhanushkumarmudupur7287 Жыл бұрын
@@VictorGordan I appreciate your reply and look into it. Great work 👍🏼. Keep it up.
@NamelessY
@NamelessY 2 жыл бұрын
Why do we use a f after every number , like 0.5f instead of 0.5
@VictorGordan
@VictorGordan 2 жыл бұрын
In C++ 0.5f is a float while 0.5 is a double. A double has "double" the precision of a float but also double the size, so usually floats are used. In GLSL (inside the shaders) you don't have to write "f" to have it he a float (I didn't know this at the time I made this video)
@NamelessY
@NamelessY 2 жыл бұрын
Ic i have always used doubles so thats why I didn't know! Tysm
@lobstercrab-neverdie
@lobstercrab-neverdie 7 ай бұрын
welp the triangle dont show help how do i fix it
@dokumencik6493
@dokumencik6493 3 ай бұрын
I did everything as You have said, but the triangle does not appear. no errors either
@VictorGordan
@VictorGordan 3 ай бұрын
Sounds like a typo in the shader code
@mindlessmeat4055
@mindlessmeat4055 9 ай бұрын
I don't know if you still read this or not, but my triangle is just a black void. No idea why since pretty sure all my code is the same.
@VictorGordan
@VictorGordan 9 ай бұрын
Most likely you have a typo in your shaders
@mintcud
@mintcud 5 ай бұрын
rewrite shaders
@edipedipbulmaz
@edipedipbulmaz Ай бұрын
i hate myself now but hoorray now i can draw a 2d triangle in a 3d domain
@sharksimo3324
@sharksimo3324 2 жыл бұрын
how can i change the color of the triangle?
@VictorGordan
@VictorGordan 2 жыл бұрын
It's covered in the Shaders tutorial from what I remember
@sharksimo3324
@sharksimo3324 2 жыл бұрын
@@VictorGordan ok thanks
@giorberto3962
@giorberto3962 2 жыл бұрын
Bro speedrunned the triangle
@VictorGordan
@VictorGordan 2 жыл бұрын
💀
@Final_hours
@Final_hours Жыл бұрын
Why is my triangle black?
@VictorGordan
@VictorGordan Жыл бұрын
Your fragment shader probably has a typo
@NexushasTaken
@NexushasTaken Жыл бұрын
bro... The tutorial 1(aka creating a window) is easy and not complex as much, but this one is so difficult AF. i guess ill just go with SDL, lol.
@VictorGordan
@VictorGordan Жыл бұрын
Good luck with SDL haha
@stephb2158
@stephb2158 3 жыл бұрын
Not sure why, but my triangle keeps showing as black.
@VictorGordan
@VictorGordan 3 жыл бұрын
That usually means there is an error in your fragment shader, make sure you have the same code as me for the fragment shader. The code is explained in the Shaders tutorial, so don't worry if u don't understand it yet :)
@jetkhan509
@jetkhan509 3 жыл бұрын
Check fragment shader creation/compiling/attaching: e.g. in glCreateShader, make sure it is GL_FRAGMENT_SHADER and not GL_VERTEX_SHADER, etc.
@D3xt3rity
@D3xt3rity 3 жыл бұрын
Hey! I'm sure you've fixed this by now but I wanted to let anyone know, The Vertex shader code can effect the Fragment shader so make sure to nail both Shader Source codes! :D
@Final_hours
@Final_hours Жыл бұрын
I was trying to learn directx and I was like screw it now I'm learning opengl and it's a lot easier
@OnzeQubit
@OnzeQubit 3 жыл бұрын
Is it normal that my gpu is at 100% after this?
@VictorGordan
@VictorGordan 3 жыл бұрын
Hmmmm, I think you are not limiting the FPS so it renders everything as fast as possible which would use 100% of the GPU. That's my guess at least
@OnzeQubit
@OnzeQubit 3 жыл бұрын
how can I fix this? if this is really the case.
@VictorGordan
@VictorGordan 3 жыл бұрын
I'm sorry about the previous solution I gave you 😅 (I was thinking of another comment haha) The actual solution is to force VSync through your driver settings, or enabling VSync using glfwSwapInterval(1); in the main function after you create the window (but not in the while loop). Hope this helps :)
@OnzeQubit
@OnzeQubit 3 жыл бұрын
@@VictorGordanThank you so much it helped and GPU is now at 10% after adding the function. And thank you for the series btw, I appreciate it.
@NamelessY
@NamelessY 2 жыл бұрын
@@VictorGordan ohk I think I understand that , what I understand by glfwSawpInterval(1) is that don't unnecessarily keep changing btw front and back buffers unless there is minimum one update (Uh I'm sorry I keep asking questions)
@Tayoky
@Tayoky 5 күн бұрын
how to not open a terminal window ?
@ToxicTrack_
@ToxicTrack_ 5 күн бұрын
My project just has a main, (no WinMain) and to disable console, I just set Linker->System->SubSystem to "Windows (/SUBSYSTEM:WINDOWS)" instead of "Console (/SUBSYSTEM:CONSOLE)" and the console goes away.
@sjb8178
@sjb8178 Жыл бұрын
thx sir
@alexandruoporanu8261
@alexandruoporanu8261 2 жыл бұрын
Very good tutorials but IMO the concepts of VBO and VAO are pretty abstract and only explained by example, not rigorously.
@VictorGordan
@VictorGordan 2 жыл бұрын
Yeah, sadly they are abstract by nature. I wouldn't really know how to explain then rigorously. They probably exist in this form because of some technical requirements that only the people who developed OpenGL know... At the end of the day they are just tools, so I don't think u need to know why they exist, but how to use them ;)
@SimplementeNico
@SimplementeNico 2 жыл бұрын
My face when all this is just for a triangle 🙂
@VictorGordan
@VictorGordan 2 жыл бұрын
You should see how much code you need for a triangle in Vulkan... It's not that bad, trust me. It will go faster from here on ;)
@kubolor1234
@kubolor1234 Жыл бұрын
OpenGL is literally frying my brain...I can't get my triangle t render.
@fft2020
@fft2020 7 күн бұрын
when I was programming BASIC in the 80s I could draw a triangle on screen withe 3 commands, not 1000 like here... but hey... progress
@VictorGordan
@VictorGordan 6 күн бұрын
@@fft2020 if you want to just do simple 2D draw calls in a few lines, then this series is not for you. I recommend you check out SDL and SFML, those might suit your needs better
@arithene
@arithene 5 ай бұрын
const char* vs = "#version 330 core layout(location=0) in vec3 p;void main(){gl_Position = vec4(p,1.0);}"; const char* fs = "#version 330 core out vec4 FragColor;void main(){FragColor=vec4(.5f,.0f,1.0f,1.0f);}";
@Jtnn713
@Jtnn713 7 ай бұрын
How come the color of the traingle is orange even though you used the same color that you used for the bg?
@Banaannaa
@Banaannaa 6 ай бұрын
the color was decided in the "Fragment shader" at the top of the code in which it says "FragColor = vec4(0.8f, 0.3f, 0.02f, 1.0f);" which is a orange red color The fragment shader is the code that controlls the triangle and its color
@alexg9771
@alexg9771 Жыл бұрын
Ok, I'm lost
@ADEPS.
@ADEPS. 9 ай бұрын
.
OpenGL Tutorial 3 - Index Buffer
3:09
Victor Gordan
Рет қаралды 45 М.
Introduction to shaders: Learn the basics!
34:50
Barney Codes
Рет қаралды 370 М.
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН
IL'HAN - Qalqam | Official Music Video
03:17
Ilhan Ihsanov
Рет қаралды 651 М.
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 118 МЛН
Animated fireplace on DOS
36:27
FreeDOS
Рет қаралды 26 М.
Vertex Buffers and Drawing a Triangle in OpenGL
20:06
The Cherno
Рет қаралды 388 М.
I Made a Minecraft Clone in C++
10:15
WSAL Evan
Рет қаралды 113 М.
Three.js Shaders (GLSL) Crash Course For Absolute Beginners
2:57:29
Visionary 3D
Рет қаралды 104 М.
What Is A Graphics Programmer?
30:21
Acerola
Рет қаралды 460 М.
When Optimisations Work, But for the Wrong Reasons
22:19
SimonDev
Рет қаралды 1,1 МЛН
I made the same game in Assembly, C and C++
4:20
Nathan Baggs
Рет қаралды 827 М.
I Made a Drawing Software From Scratch (C++ & OpenGL)
11:05
iamwassim
Рет қаралды 41 М.
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН