Vertex Attributes and Layouts in OpenGL

  Рет қаралды 241,599

The Cherno

The Cherno

Күн бұрын

Пікірлер: 286
@bgzdevtips3762
@bgzdevtips3762 7 жыл бұрын
I think what separates cherno vids from others on KZbin are his more in depth explanations of how things actually work at a low level. Sometimes other tutorials try and keep things so high level that, in the end, u really never truly grasp the concepts. Very well done.
@JasonEwton
@JasonEwton 7 жыл бұрын
I agree with you, but feel a simple click on a thumbs up isn't enough and that society is losing the complex interactions of actual social interaction... so here's a click and a comment. :D
@vertigo6982
@vertigo6982 6 жыл бұрын
Its why I love watching Jason Turner's videos.. he breaks down the machine cold to see what the registers are doing in the various compilers used in production to examine optimization and compiler warnings. (like Cherno does)
@PixelThorn
@PixelThorn 5 жыл бұрын
@@vertigo6982 what's his channel?
@AkhilNairjedi18
@AkhilNairjedi18 5 жыл бұрын
@Abigail Jones Whaaat? Chili is amazing and definitely not hard to listen to.
@anullptr7496
@anullptr7496 4 жыл бұрын
Jason Ewton I agree with you.
@MellowWater
@MellowWater 6 жыл бұрын
17mins to explain a function, I have not seen anyone go so in-depth before. You're amazing at teaching.
@arkemal
@arkemal Жыл бұрын
That man is a legend!
@resantic2256
@resantic2256 7 жыл бұрын
17:24 When you realize you typed 2 lines of code for the last 17 minutes lmaoo
@rcookie5128
@rcookie5128 7 жыл бұрын
so true.. but that's programming in a nutshell I would say haha.. understanding what the 2 lines do and how they affect the outcome of the programm is the essential key part; even though simply writing or copy pasting the 2 lines would be so much faster.
@n4rzul
@n4rzul 4 жыл бұрын
Programming is 90% problem solving and only about 10% typey-typey.
@piyushphodu
@piyushphodu 4 жыл бұрын
Well, i spent money on Udemy for 2 courses [Ben Cook and there was one was by Frahaan Hussain]. Both of them are nowhere as compared to Cherno. They just write and write code for 30 min and explain very little. Ultimately i gave up on their course and now i am using this tutorial and God it is a life saver.
@punktdotcom
@punktdotcom 2 жыл бұрын
8:40 You explained this SO GOOD! It clearly shows your expertise and deep understanding in all of this. Thank you so much for the videos!
@chendadon7168
@chendadon7168 4 жыл бұрын
I would prefer sizeof(position[0]) instead of sizeof(float), because if you are changing the type to double for example, it will not affect this functions.
@bobdagamer640
@bobdagamer640 Жыл бұрын
You would need to change the GL_FLOAT parameter anyway. You could possibly use some kind of data structure to store it though
@rylanjohnson9049
@rylanjohnson9049 Жыл бұрын
@@bobdagamer640 it still would be two changes which could add up if you have a lot of code
@mrmastaofdesasta6994
@mrmastaofdesasta6994 6 жыл бұрын
Cherno: "Now if we had a Shader, we'd be able to see our Triangle." Me: *randomly compiles the program... Giant Triangle on screen. ... Now I'm confused...
@2001herne
@2001herne 4 жыл бұрын
I guess that OpenGL has some sort of default shader - flat, and useless, but something that is put there to avoid crashes.
@anonymousgaming911
@anonymousgaming911 4 жыл бұрын
@@2001herne no. OpenGL does NOT have a default shader. If you see a triangle on your screen , that means that your graphics drivers have a default shader just for debugging
@beachforestmountain4269
@beachforestmountain4269 4 жыл бұрын
@@anonymousgaming911 Cheers
@ViktorWingqvist
@ViktorWingqvist 4 жыл бұрын
I think it is undefined behaviour, so you'd get different result on a different machine
@djukicdev
@djukicdev 4 жыл бұрын
@@ViktorWingqvist Yeah, depending on your GPU and its graphics driver.
@viniciusmachado4422
@viniciusmachado4422 7 жыл бұрын
The depth of your explanation is amazing o/
@WookieTekkit
@WookieTekkit 7 жыл бұрын
I think the hand motions in the first few seconds tell us why he knows so much about this..... he's really a wizard. I mean, look at the hair.
@thefallenfool
@thefallenfool 7 жыл бұрын
Literally came here to comment, is he casting a learning spell on us?
@yolopolo5783
@yolopolo5783 6 жыл бұрын
I have also started using the same hand motions while explaining others. and people started understanding more about want i am saying. It a jutsu.
@vertigo6982
@vertigo6982 6 жыл бұрын
The hands move around the code of the Matrix.
@xriccardo1831
@xriccardo1831 6 жыл бұрын
I'm italian and we do that a lot xD
@anicsr
@anicsr 7 жыл бұрын
Much love for this series and for you
@TheMonyarm
@TheMonyarm 6 жыл бұрын
I'm loving this series, i'm currently following it on linux with CLion.
@willecode7062
@willecode7062 4 жыл бұрын
same here :D
@DagreenApple
@DagreenApple 2 жыл бұрын
i m too late, opengl 2 Xcode on mac :o
@kasufert
@kasufert 10 ай бұрын
@@DagreenApple Currently following along with VSCODE on windows, but I am using SFML instead of GLFW
@Ngserdna
@Ngserdna 7 жыл бұрын
Hey Cherno! I discovered your videos a loooooong time ago, and I am really happy to see that you have continued to do what you love!
@Игор-ь9щ
@Игор-ь9щ 7 жыл бұрын
I would suggest using some kind of drawing application because I would imagine it would probably be easier for viewers to see what you are talking about
@PratikAnand
@PratikAnand 3 жыл бұрын
The layout could have really used some illustrations
@DiffyMC
@DiffyMC 8 ай бұрын
Love ur tutorials! You actually teach the concepts and explain everything, instead of just telling the viewer to write this and write that like others do. Not only does this show that you are a great teacher, but also that you actually know what you're talking about
@Brahvim
@Brahvim 2 жыл бұрын
I spent 4 hours writing notes in my code to better understand (and remember) what was taught in this _almost_ 19 minute video. Nowhere could I have gotten SO much knowledge! Thank you; Yan, ":D!
@enderger5308
@enderger5308 Жыл бұрын
9:09 - stride is basically just sizeof(vertex), which I know from encoding it in the Rust type system where Bytemuck is used to just get the plain bytes of any input type (currently, arrays of 2 f32s) as packed raw data. Makes it so much easier than having to compute it yourself.
@IDontWannaSayMyName1995
@IDontWannaSayMyName1995 4 жыл бұрын
Oh my god, stride and pointer JUST clicked for me after months of trying this. Oh my god I'm so excited haha, you are the BEST Cherno!
@a1r592
@a1r592 5 жыл бұрын
Great explanation, especially with the stride and pointer parameters from the glVertexAttribPointer function. I was able to understand it quickly, even without visualization. I can imagine some people would need more visualization though. But overall it was very helpful!
@hidayatrzayev6603
@hidayatrzayev6603 Жыл бұрын
Man, you have a serious power of boiling down complex concepts into something very simple and on top of that explaining it in simple words to a person who has absolutely zero clue about graphics programming. This is amazing!
@vishwasmane4
@vishwasmane4 5 жыл бұрын
The Cherno.. This is the best, clearly and simply explained tutorial about the Vertex Attributes and Buffer layout required for modern OpenGL. Thank You!!
@markeyboi6545
@markeyboi6545 7 жыл бұрын
The triangle rendered for me, even without the shader :).
@prezadent1
@prezadent1 7 жыл бұрын
Are you using an Nvidia card?
@markeyboi6545
@markeyboi6545 7 жыл бұрын
Yes, a GTX 1060 (6GB edition).
@cloudboysmusic5223
@cloudboysmusic5223 6 жыл бұрын
Same
@DanielLiljeberg
@DanielLiljeberg 6 жыл бұрын
Same here
@mallock8529
@mallock8529 6 жыл бұрын
The superiority of NVIDIA proven yet again.
@johanrojassoderman5590
@johanrojassoderman5590 3 жыл бұрын
Very effective and clear in-depth explanations. Watching this I feel like any other attempt at entering OpenGL would have left me so confused that I might not have had the energy to continue. Now however, I feel like I am grounded and on the right track with no concepts or functions (so far) leaving me clueless to their workings or implementations.
@lupinedreamexpress
@lupinedreamexpress 4 жыл бұрын
I can see so plainly how OpenGL became very useful for hardware accelerated data processing. Passing data through vertex buffers, telling OpenGL what that data is by defining its attributes, enabling those attributes...then using a shader to process that buffer on the GPU, with a backbuffer as the output area. Say I wanted to perform some really complicated math that's slow on my CPU... I can send the data to be processed through my GPU's OpenGL implimenetation over a buffer, to a shader that I wrote, and it would come back to the GPU's backbuffer, and I could read my results from the backbuffer. The trick sort of voids OpenGL's intended use to display graphics, to blit raw data using a shader. This reminds me very much of what nvidia's CUDA does, and helps me to see why it works so cleanly with OpenGL. You get control over everything. Which is really really useful to make OpenGL do stuff it really wasn't intended to do, like perform physics or finish your calculus homework fast. :^)
@IEatFish005
@IEatFish005 28 күн бұрын
Thank you for explaining all this. Every other KZbin creator making a video series about opengl just show what you need to type and nothing else which you choose not to do.
@GeorgeTsiros
@GeorgeTsiros 5 жыл бұрын
Generally, vertex means 'point'. It can be the point of an intersection, an extremum of a function, a node in a graph, etcetcetc. The entity named 'vertex' in the context of opengl is just an ordered list of values (ie 1,2,3 is different to 2,3,1 ). It may represent anything, *but* it can *always* represent a point in n-dimensional space where n is the count of values in that vertex. It's probably also a vector, but considering they (might?) not inherently have the properties of vectors, I would avoid calling them as such. It is likely that the name 'vertex' was chosen instead of 'vector' exactly for this reason.
@tuantranluuquoc2910
@tuantranluuquoc2910 2 жыл бұрын
Damn, Yan explains stuff even better than my paid Udemy course (at least till this point), this vid came out at the time where I haven't realized my passion for coding and still does incredible job at the time it is needed. Thanks the Cherno !!!
@aprithul
@aprithul 5 жыл бұрын
I'd like to add that if you are on Mac you can't create your openGL context with compatibility profile, you have to use the core profile. And if you do that, the code will cause a GL_INVALID_OPERATION error. You will find this error if you poll it using the glGetError() function. To resolve that you also need a vertex array object and you need to bind it as well. A simple example would be the following after you bind your vertex buffer (found this snippet on stackoverflow) : GLuint vao; glGenVertexArrays(1, &vao); glBindVertexArray(vao);
@lucasfreire1090
@lucasfreire1090 4 ай бұрын
I was just about to comment the same, but I might as well up your comment. I'm on windows as well, but compiling with mingw64's g++. If I set glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE), the code actually runs just like his. But if I keep the default or just set GLFW_OPENGL_CORE_PROFILE, all I get is a black screen.
@raghavsrivastava2910
@raghavsrivastava2910 2 жыл бұрын
Mind-blowing video as always. Get to learn in so much much much much detail.
@markelishaev617
@markelishaev617 4 жыл бұрын
Phenomenal explanation about the vertex attributes. Was struggling with them
@daginganinja4075
@daginganinja4075 4 жыл бұрын
4:15 *long tangent about semantics involving referring to vertices as positions* "...anyway so we have these three vertices..."
@arkemal
@arkemal Жыл бұрын
Thanks so much for all these explanations. It's very helpful!
@dylanhetzel
@dylanhetzel 5 ай бұрын
Wow, 20 minutes for 2 lines of code. Very thorough, thanks.
@altermetax
@altermetax 7 жыл бұрын
How great is this series? All other OpenGL tutorials I followed didn't explain so well.
@Theawesomeking4444
@Theawesomeking4444 4 жыл бұрын
for some reason when i debug from visual studio it just opens a white window and doesnt work but when i run it from the exe file it works?
@SeamusTW
@SeamusTW 3 жыл бұрын
Check your configurations, see if it is on release or debug
@Enanelloor12
@Enanelloor12 7 жыл бұрын
Hey Cherno, your explanations are simply awesome. I would like learn D-bus communication from you. can you make a video on that or please suggest some online stuffs.
@philtype-r810
@philtype-r810 4 жыл бұрын
On the Point Information. Thank you very much! *subscribed*
@abacaabaca8131
@abacaabaca8131 Жыл бұрын
@14:33 how about if we want to specify other vertex's attribute like color, can we just insert the color into the array mixed together with other vertex's attribute like position and texture coordinate ,and normal in one single float array? Later when we have the buffer in the GPU, we can read the buffer by using glvertexattribpointer() ?🎉😢
@laurentiubistrian6372
@laurentiubistrian6372 5 жыл бұрын
Thank you very much for this explanation! :D
@bdinh3130
@bdinh3130 7 жыл бұрын
This video really cleared a lot of things up for me. I am a little unsure of why Vertex Array Objects (VAOs) are used now though. In a lot of tutorials attributes are split up in to their own VBO which gave me a big misconception of how memory is handled and works. I was under the assumption that each attribute (color, normal, etc.) had to be in their own VBO. After watching this video I can only assume that VAOs are used when you want to draw multiple objects in a scene that have their own VBOs. If this is wrong please correct my understanding.
@donsaad
@donsaad 10 ай бұрын
13:20 how did you make Visual Assist show the complete parameter list instead of the macro? anyone knows?
@李景天
@李景天 4 жыл бұрын
In Houdini, a vertex can contain any attribute you throw at it, like position, normal, tangent, color, ID, size, group, and many custom ones you give it.
@ImRiz1
@ImRiz1 7 жыл бұрын
Bruh, U deserve Nobel in teaching...
@Killerkraft975
@Killerkraft975 Жыл бұрын
Great video. Although I did have to make notes to visualize what you were explaining, maybe include a diagram of the structure of the vertices and a vertex and then the explanation of the parameters of glVertexAttribpointer may be easier for others to understand.
@slipperywitcher3724
@slipperywitcher3724 4 жыл бұрын
Other programming videos: 3 separate translation units each having classes and methods. Cherno videos: 2 lines of code in 19 minutes /s
@vertigo6982
@vertigo6982 6 жыл бұрын
05:30 how did you box select that? Normally the selection will carry over to the beginning of the next line highlighting the values to the left as well.. Is that a Vi keybind?
@huseyindinc1931
@huseyindinc1931 6 жыл бұрын
Hold Ctrl+Alt while pressing the up or down arrow keys to add cursors and hold Shift while pressing left or right arrow keys to select.
@vertigo6982
@vertigo6982 6 жыл бұрын
Ctrl+Alt just brings up a little window to the upper right of the screen with the option to switch to the different project tabs, but from your reply I figured out I just hold Alt while pressing up and down and Shift for left and right so thanks!
@vishal1635
@vishal1635 6 жыл бұрын
Vertigo Studios, use Alt+Shift and drag from the top left corner to the bottom right.@@vertigo6982
@azizas9366
@azizas9366 6 жыл бұрын
BTW: Why do you have the line of code on line 44? You already bounded the buffer and stored data in it. Or Are you freeing the buffer?
@IndellableHatesHandles
@IndellableHatesHandles 4 жыл бұрын
I've used OpenGL in many forms, from PyOpenGL to OpenTK to LWJGL, but there's just something magical about the original thing.
@nepp9574
@nepp9574 3 жыл бұрын
"A vertex has nothing to do with a position", meanwhile "float positions[6]" Made me laugh although explained later. Nothing to remark on the playlist tho, awesome series :)
@ninjamonkey4135
@ninjamonkey4135 4 жыл бұрын
Just curious as to the second call to glBindBuffers() underneath the glVertexAttribPointer call. I remember you typing it to explain that the binding of the vertex array tells the call to glDrawArrays where to look for data to draw but idk why it was left in there a second time. I read the page on it in gl.docs and understand it frees the buffer memory when calling it with 0, but I just don't understand it's placement. Anyway I know this comment is quite late but you have such a good teaching style and I love your Programming videos. Thanks a ton for this awesome resource!
@jeypav1961
@jeypav1961 3 жыл бұрын
Hi i have a quick question regarding your code. You said to select or “bind” the buffer you created you must use the glBindBuffer() function and pass in your buffer id variable. You wrote: glBindBuffer(GL_ARRAY_BUFFER, buffer); But later you wrote: glBindBuffer(GL_ARRAY_BUFFER, 0); And I want to know why you wrote 0? I printed out the buffer variable into my console when i run the application and it return 1. So i am a bit confused as to why you put 0 there. Furthermore, when i compile and run the code after i added the vertex attributes, I saw the triangle and that confuses me even more because i followed what you wrote in your code. Thanks anyways!
@cybisz2883
@cybisz2883 3 жыл бұрын
Your videos are absolutely fantastic. Have you ever thought about making courses for Pluralsight?
@soiyodkamal1040
@soiyodkamal1040 Жыл бұрын
I really like that dark black guitar in the background. I wonder which guitar is that
@loctite417
@loctite417 Жыл бұрын
How did you get your function autocomplete to show up at 12:51? Mine does not show that
@adam-markgheczi4577
@adam-markgheczi4577 2 жыл бұрын
How can I toggle VS showing the arguments of a function while typing? Like at 13:24
@jixs4v
@jixs4v 4 жыл бұрын
Me: Wait it's all attributes? TheCherno: Always has been
@RealBrianRussell
@RealBrianRussell Жыл бұрын
I'm sure my 3 weeks of openGL helps, but finally I now understand stride and offset lol.
@ruben7420
@ruben7420 3 жыл бұрын
So fun fact if you run it like it is at the end of the video it actually already render a white triangle :)
@ayushbhardwas
@ayushbhardwas 9 ай бұрын
Am I missing something or that second call to glBindBuffer occurred magically where you are binding it to some buffer having 0 as its id. What is that?
@karanjathoul8895
@karanjathoul8895 5 жыл бұрын
Brilliant. Thankyou.
@SkylerAk
@SkylerAk 4 жыл бұрын
For anyone who gets error 1282 GL_INVALID_OPERATION with glVertexAttribPointer(); There is a simple fix you must generate and bind a vertex array the required code is: glGenVertexArrays(1, &buffer); glBindVertexArray(buffer);
@ynsam
@ynsam 4 жыл бұрын
I am new xcode user. I am not getting automatic opengl function definitions as when I am typing as Cherno is getting in his visual studio. How can I enable them? I am do getting glew functions. My builds and running and I am able to generate triangle as I have Nvidia graphics. Any help here?
@frednginger44
@frednginger44 6 жыл бұрын
Excellent explanation! Very hard to interpret what’s going on using just the OpenGL documentation.
@jangronowski8180
@jangronowski8180 4 жыл бұрын
If the stride is the distance between vertecies than shouldn't it be 0 because their all next to each other? If it's 2 floats shouldn't it jump over the middle vertex? Can someone explain?
@paulzupan3732
@paulzupan3732 2 жыл бұрын
Right? That was my understanding as well. Very confusing, the docs aren't really that helpful either.
@shubhamjain1328
@shubhamjain1328 4 жыл бұрын
at this point the cherno should be called the offical beginner's guide to OpenGL.
@9Blurke9
@9Blurke9 4 жыл бұрын
Why is my triangle rendered even though it is unbounded? It says glBindBuffer(GL_ARRAY_BUFFER, 0). You said that by unbinding it, it would not be rendered.
@TheKingoftheriff
@TheKingoftheriff 5 жыл бұрын
Your style would a massive bore for anything else, but for learning stuff that's actually above my level, I love how you explain the same thing in a lot of different ways. (I'm the type who takes a few lines of code and then runs with it, until I truly understand what each field is doing).
@marcovalentinoalvarado3290
@marcovalentinoalvarado3290 4 жыл бұрын
Vertex is a buffer that can contain a *LOT* of different types of data stored in the VRAM, but it is used by the GPU so it can be understood by a shader?
@ДмитрийШереметьев-я7б
@ДмитрийШереметьев-я7б 9 ай бұрын
how does opengl understand that we bind this attributes to the current buffer, or we bind that for the all buffers?
@yuansizhu6271
@yuansizhu6271 5 жыл бұрын
if you are using iOS GLKit based on OpenGL ES, use GLKBaseEffect so that you dont have to write shaders to see the triangle.
@johnclasing4627
@johnclasing4627 3 жыл бұрын
One thing that's kinda funny is that he goes "oh em gee documentation" and goes to read it and is like "yeah this is confusing, yeah idk why they worded it this way, yeah I dont even want to read this"
@kamilkaya5367
@kamilkaya5367 3 жыл бұрын
Can anyone explain me the last argument of glVertexAttribPointer() function? What it does actually? I couldn't understand it properly.
@MattJohno2
@MattJohno2 7 ай бұрын
How the hell did you make the like button glow when you pointed to it? Genius!
@dylanhetzel
@dylanhetzel 5 ай бұрын
It's a new youtube feature. When a creator says "subscribe" or "like" it makes those things glow.
@yuchen3587
@yuchen3587 6 жыл бұрын
Could anyone tell me please why he wrote glBindBuffer(GL_ARRAY_BUFFER, 0) again after he set the vertex attributes? I tried adding this line and removing this, and I got the same triangle..Thanks
@yuchen3587
@yuchen3587 6 жыл бұрын
I just checked the previous episode. He added this line glBindBuffer(GL_ARRAY_BUFFER, 0) because he wanted to justify that this will unbind our vertex buffer. If doing so, we cannot draw our triangle on the screen anymore(because OpenGL is a state machine). But when I added this line, I still can draw the triangle which I don't understand...
@ОсипПоддерегин
@ОсипПоддерегин 4 жыл бұрын
@@yuchen3587 same. Kinda confusing for me as a begginer.
@yolopolo5783
@yolopolo5783 6 жыл бұрын
I used attrib pointer location 1 in place of 0 and it didn't worked. Why? ( is it because attrib pointer 0 is empty? )
@tunAliUTube
@tunAliUTube Жыл бұрын
I dont understand "glBindBuffer(GL_ARRAY_BUFFER, 0);" statement. Cherno said in his last video if buffer is set to zero, the glDrawArrays() would not able to draw the triangle because nothing is selected to be draw and yet I still see the triangle when building the code.
@thebatchicle3429
@thebatchicle3429 4 ай бұрын
Offsetof is an operator, not a macro. Similar to sizeof (and ‘defined’ in the preprocessor)
@supertonyxd
@supertonyxd 4 жыл бұрын
Thank you so much!
@loganabel9321
@loganabel9321 4 жыл бұрын
if the array of data representing the vertices has equal columns and rows, which are prime, then it is technically possible to know what each vertex is.
@tricky778
@tricky778 4 жыл бұрын
In future videos, when you're explaining the API (here I noticed the problem when explaining pointer) can you leave the function documentation up, and maybe also the relevent bit of code in splitscreen because that would be easier to follow while you talk than watching your hands - their degrees of freedom are too few to model the API concept well.
@h.hristov
@h.hristov 7 жыл бұрын
13:20 What was that hotkey shortcut? Does anyone know?
@happypixls
@happypixls 6 жыл бұрын
I know it's quite late, but it's Ctrl+Shift+Space
@Byynx
@Byynx Жыл бұрын
From the previous video to this one you added the line "glBindBuffer(GL_ARRAY_BUFFER, 0)" in the end without showing or explaining it in the video. Why we have to use again this function?
@jakemeyer8188
@jakemeyer8188 3 жыл бұрын
Huge thanks for making clear sense of this. I also found myself thinking, "why can't this just be a struct?"...and then you said, "Normally you'd just make a struct for this..." and I told myself to sit down and STFU.
@ivanjansevanrensburg5377
@ivanjansevanrensburg5377 3 жыл бұрын
Getting error on mac? Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)?
@DaftHacker
@DaftHacker 7 жыл бұрын
Not sure what video to post this on but you other tutorials that you've had with open gl use: glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); How come we haven't done that in this one ?
@iIO_OIi
@iIO_OIi Жыл бұрын
Oh, now uv makes a lot more sense to me lol. I guess ARB or whoever didn't want them to be mistaken for 3D space or screen coordinates.
@samarthtandale9121
@samarthtandale9121 Жыл бұрын
You are Awesome !!!
@Mitchinator1
@Mitchinator1 7 жыл бұрын
If I want to add more vertices positions to a VAO with another buffer, do I need to redo glVertexAttribPointer? Or is that a one time set-up for each index in a VAO?
@KayVerbruggen
@KayVerbruggen 7 жыл бұрын
Mitchinator1 You only need to redo glVertexAttribPointer if you add another type of data, so normals or uv coordinates. If you want extra positions, just make sure you have enough bytes when using glBufferData, and you should be good
@Mitchinator1
@Mitchinator1 7 жыл бұрын
Kay Verbruggen How do I make sure my buffer has enough bytes? I was making a 16*16 grid of quads, and it ran out about halfway through.
@KayVerbruggen
@KayVerbruggen 7 жыл бұрын
Mitchinator1 Right now it says 6 * sizeof(float), you should replace the 6 with the number of floats you have. Or just replace it altogether with sizeof(yourArray).
@Mitchinator1
@Mitchinator1 7 жыл бұрын
Kay Verbruggen I have replaced it with the size of my array, however it still caps out around half.
@KayVerbruggen
@KayVerbruggen 7 жыл бұрын
Mitchinator1 How did you specify the quads, as two triangles or just four points? If you did the four points method, replace GL_TRIANGLES with GL_QUADS. If this doesn’t solve it, I don’t know what does. edit: GL_QUADS is no longer a thing in modern OpenGL, it used to be a thing when we still used glBegin(from previous epidodes). So you need to specify two triangles to make one quad. Right now that means you need 6 positions for one quad. But I’m sure in later episodes were going to use and index buffer to fix that and only use 4 positions.
@prezadent1
@prezadent1 7 жыл бұрын
If anyone gets a triangle rendering on the screen at this point, please reply with what GPU you have. Thank you if you do this!
@AnAnxiousExtrovert
@AnAnxiousExtrovert 7 жыл бұрын
Worked for me. GTX 1070
@pradyumnkejriwal3007
@pradyumnkejriwal3007 7 жыл бұрын
Intel HD Graphics 5500
@SToddyMr
@SToddyMr 7 жыл бұрын
Intel HD Graphics 4600
@skrauthauser
@skrauthauser 7 жыл бұрын
GTX 1070
@loryon
@loryon 7 жыл бұрын
AMD Radeon 6600M
@andrew1958
@andrew1958 4 жыл бұрын
i didnt understand why the value of the pointer is 0 and if we add 1 float (4 bytes), it become 8 , can anyone explain?
@suap4694
@suap4694 3 жыл бұрын
there is no link up there if I haven't seen the video. :(
@Chris-cs7nv
@Chris-cs7nv Жыл бұрын
If the triangle shows anyway at this point, what does that mean?
@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 Жыл бұрын
I've found a solution. I added these 3 functions and now it's fine. glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 4); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
@asdasd-vj3jr
@asdasd-vj3jr Жыл бұрын
i cant find the part where he add vertexarrayobject to make the program functional
@aqua123670
@aqua123670 6 жыл бұрын
This is so clear and concise, thank you so much
@tek1234
@tek1234 6 жыл бұрын
Best videos ! Thank you
@VivekYadav-ds8oz
@VivekYadav-ds8oz 5 жыл бұрын
I had no idea what I just saw... I really didn't understand much, it's so weird! Please make another video with different attributes within a vertex. (I'm not even sure if to call that buffer a vertex, but it doesn't represent like, the "situation" at a single point, the buffer defines a whole freaking triangle)
@ceskehry
@ceskehry 6 жыл бұрын
14:50 missing link
@siddharthgpta
@siddharthgpta 6 жыл бұрын
I didn't understand the part where you set 8 as the pointer. How does OpenGL tell the data you just gave is the position of the vertex or the texture of the vertex? EDIT: Could someone tell me if this is correct? glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 3, 0); //Specifies that index 0 corresponds to position, but OpenGL can use this only if the shader tells it so. glVertexAttribPointer(1, 1, GL_FLOAT, GL_FALSE, sizeof(float) * 3, 8); //Specifies that index 1 corresponds to texture, but again OpenGL can only use this with the shader.
@Knuckler
@Knuckler 6 жыл бұрын
Not necessarily. The 0 index in glVertexAttribPointer corresponds to the attribute assigned index 0 in the shader. You're specifying the layout and properties of the attribute in the buffer you're passing to opengl. It "may" be position data, it "may" be texture coordinate data, it "may" be normal vector data, it "may" be color data. It's up to you, the programmer, to decide what any particular index is for. By convention, I use 0 for position data, 1 for texture, 2 for normal and 3 for color. Someone else may have their indexes arranged in another way.
@andrewknauss6106
@andrewknauss6106 6 жыл бұрын
Where did glBindBuffer(GL_ARRAY_BUFFER, 0); come from?
@sugg5719
@sugg5719 5 жыл бұрын
The buffer he created for the triangle gets an index of 1. That line is binding 0 which is nothing so it's basically unbinding the triangle buffer.
@a1r592
@a1r592 5 жыл бұрын
After working on the buffer you unbind it again. This way you won't accidentally make changes to the same buffer again unless you want to.
@flTobi
@flTobi 7 жыл бұрын
Why reuploaded?
@flTobi
@flTobi 7 жыл бұрын
Oh, Okay
@evanotoole787
@evanotoole787 2 жыл бұрын
I've got a segmentation fault @ function 'glDrawArrays'.
How Shaders Work in OpenGL
17:37
The Cherno
Рет қаралды 236 М.
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 38 МЛН
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 63 МЛН
Why i think C++ is better than rust
32:48
ThePrimeTime
Рет қаралды 335 М.
Writing a Shader in OpenGL
28:21
The Cherno
Рет қаралды 321 М.
Sqlite Is Getting So Good
28:52
ThePrimeTime
Рет қаралды 214 М.
Is C BETTER than C++ for beginners? // Code Review
31:16
The Cherno
Рет қаралды 81 М.
Why More People Dont Use Linux
18:51
ThePrimeTime
Рет қаралды 332 М.
Vertex Buffers and Drawing a Triangle in OpenGL
20:06
The Cherno
Рет қаралды 388 М.
Dealing with Errors in OpenGL
23:42
The Cherno
Рет қаралды 119 М.
Buffers in OpenGL | How to Code Minecraft Ep. 2
26:56
GamesWithGabe
Рет қаралды 90 М.
How I Deal with Shaders in OpenGL
21:15
The Cherno
Рет қаралды 179 М.
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 188 М.