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.
@JasonEwton7 жыл бұрын
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
@vertigo69826 жыл бұрын
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)
@PixelThorn5 жыл бұрын
@@vertigo6982 what's his channel?
@AkhilNairjedi185 жыл бұрын
@Abigail Jones Whaaat? Chili is amazing and definitely not hard to listen to.
@anullptr74964 жыл бұрын
Jason Ewton I agree with you.
@MellowWater6 жыл бұрын
17mins to explain a function, I have not seen anyone go so in-depth before. You're amazing at teaching.
@arkemal Жыл бұрын
That man is a legend!
@resantic22567 жыл бұрын
17:24 When you realize you typed 2 lines of code for the last 17 minutes lmaoo
@rcookie51287 жыл бұрын
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.
@n4rzul4 жыл бұрын
Programming is 90% problem solving and only about 10% typey-typey.
@piyushphodu4 жыл бұрын
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.
@punktdotcom2 жыл бұрын
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!
@chendadon71684 жыл бұрын
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 Жыл бұрын
You would need to change the GL_FLOAT parameter anyway. You could possibly use some kind of data structure to store it though
@rylanjohnson9049 Жыл бұрын
@@bobdagamer640 it still would be two changes which could add up if you have a lot of code
@mrmastaofdesasta69946 жыл бұрын
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...
@2001herne4 жыл бұрын
I guess that OpenGL has some sort of default shader - flat, and useless, but something that is put there to avoid crashes.
@anonymousgaming9114 жыл бұрын
@@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
@beachforestmountain42694 жыл бұрын
@@anonymousgaming911 Cheers
@ViktorWingqvist4 жыл бұрын
I think it is undefined behaviour, so you'd get different result on a different machine
@djukicdev4 жыл бұрын
@@ViktorWingqvist Yeah, depending on your GPU and its graphics driver.
@viniciusmachado44227 жыл бұрын
The depth of your explanation is amazing o/
@WookieTekkit7 жыл бұрын
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.
@thefallenfool7 жыл бұрын
Literally came here to comment, is he casting a learning spell on us?
@yolopolo57836 жыл бұрын
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.
@vertigo69826 жыл бұрын
The hands move around the code of the Matrix.
@xriccardo18316 жыл бұрын
I'm italian and we do that a lot xD
@anicsr7 жыл бұрын
Much love for this series and for you
@TheMonyarm6 жыл бұрын
I'm loving this series, i'm currently following it on linux with CLion.
@willecode70624 жыл бұрын
same here :D
@DagreenApple2 жыл бұрын
i m too late, opengl 2 Xcode on mac :o
@kasufert10 ай бұрын
@@DagreenApple Currently following along with VSCODE on windows, but I am using SFML instead of GLFW
@Ngserdna7 жыл бұрын
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щ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
@PratikAnand3 жыл бұрын
The layout could have really used some illustrations
@DiffyMC8 ай бұрын
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
@Brahvim2 жыл бұрын
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 Жыл бұрын
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.
@IDontWannaSayMyName19954 жыл бұрын
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!
@a1r5925 жыл бұрын
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 Жыл бұрын
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!
@vishwasmane45 жыл бұрын
The Cherno.. This is the best, clearly and simply explained tutorial about the Vertex Attributes and Buffer layout required for modern OpenGL. Thank You!!
@markeyboi65457 жыл бұрын
The triangle rendered for me, even without the shader :).
@prezadent17 жыл бұрын
Are you using an Nvidia card?
@markeyboi65457 жыл бұрын
Yes, a GTX 1060 (6GB edition).
@cloudboysmusic52236 жыл бұрын
Same
@DanielLiljeberg6 жыл бұрын
Same here
@mallock85296 жыл бұрын
The superiority of NVIDIA proven yet again.
@johanrojassoderman55903 жыл бұрын
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.
@lupinedreamexpress4 жыл бұрын
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. :^)
@IEatFish00528 күн бұрын
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.
@GeorgeTsiros5 жыл бұрын
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.
@tuantranluuquoc29102 жыл бұрын
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 !!!
@aprithul5 жыл бұрын
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);
@lucasfreire10904 ай бұрын
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.
@raghavsrivastava29102 жыл бұрын
Mind-blowing video as always. Get to learn in so much much much much detail.
@markelishaev6174 жыл бұрын
Phenomenal explanation about the vertex attributes. Was struggling with them
@daginganinja40754 жыл бұрын
4:15 *long tangent about semantics involving referring to vertices as positions* "...anyway so we have these three vertices..."
@arkemal Жыл бұрын
Thanks so much for all these explanations. It's very helpful!
@dylanhetzel5 ай бұрын
Wow, 20 minutes for 2 lines of code. Very thorough, thanks.
@altermetax7 жыл бұрын
How great is this series? All other OpenGL tutorials I followed didn't explain so well.
@Theawesomeking44444 жыл бұрын
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?
@SeamusTW3 жыл бұрын
Check your configurations, see if it is on release or debug
@Enanelloor127 жыл бұрын
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-r8104 жыл бұрын
On the Point Information. Thank you very much! *subscribed*
@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() ?🎉😢
@laurentiubistrian63725 жыл бұрын
Thank you very much for this explanation! :D
@bdinh31307 жыл бұрын
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.
@donsaad10 ай бұрын
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.
@ImRiz17 жыл бұрын
Bruh, U deserve Nobel in teaching...
@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.
@slipperywitcher37244 жыл бұрын
Other programming videos: 3 separate translation units each having classes and methods. Cherno videos: 2 lines of code in 19 minutes /s
@vertigo69826 жыл бұрын
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?
@huseyindinc19316 жыл бұрын
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.
@vertigo69826 жыл бұрын
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!
@vishal16356 жыл бұрын
Vertigo Studios, use Alt+Shift and drag from the top left corner to the bottom right.@@vertigo6982
@azizas93666 жыл бұрын
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?
@IndellableHatesHandles4 жыл бұрын
I've used OpenGL in many forms, from PyOpenGL to OpenTK to LWJGL, but there's just something magical about the original thing.
@nepp95743 жыл бұрын
"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 :)
@ninjamonkey41354 жыл бұрын
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!
@jeypav19613 жыл бұрын
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!
@cybisz28833 жыл бұрын
Your videos are absolutely fantastic. Have you ever thought about making courses for Pluralsight?
@soiyodkamal1040 Жыл бұрын
I really like that dark black guitar in the background. I wonder which guitar is that
@loctite417 Жыл бұрын
How did you get your function autocomplete to show up at 12:51? Mine does not show that
@adam-markgheczi45772 жыл бұрын
How can I toggle VS showing the arguments of a function while typing? Like at 13:24
@jixs4v4 жыл бұрын
Me: Wait it's all attributes? TheCherno: Always has been
@RealBrianRussell Жыл бұрын
I'm sure my 3 weeks of openGL helps, but finally I now understand stride and offset lol.
@ruben74203 жыл бұрын
So fun fact if you run it like it is at the end of the video it actually already render a white triangle :)
@ayushbhardwas9 ай бұрын
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?
@karanjathoul88955 жыл бұрын
Brilliant. Thankyou.
@SkylerAk4 жыл бұрын
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);
@ynsam4 жыл бұрын
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?
@frednginger446 жыл бұрын
Excellent explanation! Very hard to interpret what’s going on using just the OpenGL documentation.
@jangronowski81804 жыл бұрын
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?
@paulzupan37322 жыл бұрын
Right? That was my understanding as well. Very confusing, the docs aren't really that helpful either.
@shubhamjain13284 жыл бұрын
at this point the cherno should be called the offical beginner's guide to OpenGL.
@9Blurke94 жыл бұрын
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.
@TheKingoftheriff5 жыл бұрын
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).
@marcovalentinoalvarado32904 жыл бұрын
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б9 ай бұрын
how does opengl understand that we bind this attributes to the current buffer, or we bind that for the all buffers?
@yuansizhu62715 жыл бұрын
if you are using iOS GLKit based on OpenGL ES, use GLKBaseEffect so that you dont have to write shaders to see the triangle.
@johnclasing46273 жыл бұрын
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"
@kamilkaya53673 жыл бұрын
Can anyone explain me the last argument of glVertexAttribPointer() function? What it does actually? I couldn't understand it properly.
@MattJohno27 ай бұрын
How the hell did you make the like button glow when you pointed to it? Genius!
@dylanhetzel5 ай бұрын
It's a new youtube feature. When a creator says "subscribe" or "like" it makes those things glow.
@yuchen35876 жыл бұрын
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
@yuchen35876 жыл бұрын
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.
@yolopolo57836 жыл бұрын
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 Жыл бұрын
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.
@thebatchicle34294 ай бұрын
Offsetof is an operator, not a macro. Similar to sizeof (and ‘defined’ in the preprocessor)
@supertonyxd4 жыл бұрын
Thank you so much!
@loganabel93214 жыл бұрын
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.
@tricky7784 жыл бұрын
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.hristov7 жыл бұрын
13:20 What was that hotkey shortcut? Does anyone know?
@happypixls6 жыл бұрын
I know it's quite late, but it's Ctrl+Shift+Space
@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?
@jakemeyer81883 жыл бұрын
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.
@ivanjansevanrensburg53773 жыл бұрын
Getting error on mac? Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)?
@DaftHacker7 жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
You are Awesome !!!
@Mitchinator17 жыл бұрын
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?
@KayVerbruggen7 жыл бұрын
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
@Mitchinator17 жыл бұрын
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.
@KayVerbruggen7 жыл бұрын
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).
@Mitchinator17 жыл бұрын
Kay Verbruggen I have replaced it with the size of my array, however it still caps out around half.
@KayVerbruggen7 жыл бұрын
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.
@prezadent17 жыл бұрын
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!
@AnAnxiousExtrovert7 жыл бұрын
Worked for me. GTX 1070
@pradyumnkejriwal30077 жыл бұрын
Intel HD Graphics 5500
@SToddyMr7 жыл бұрын
Intel HD Graphics 4600
@skrauthauser7 жыл бұрын
GTX 1070
@loryon7 жыл бұрын
AMD Radeon 6600M
@andrew19584 жыл бұрын
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?
@suap46943 жыл бұрын
there is no link up there if I haven't seen the video. :(
@Chris-cs7nv Жыл бұрын
If the triangle shows anyway at this point, what does that mean?
@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 Жыл бұрын
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 Жыл бұрын
i cant find the part where he add vertexarrayobject to make the program functional
@aqua1236706 жыл бұрын
This is so clear and concise, thank you so much
@tek12346 жыл бұрын
Best videos ! Thank you
@VivekYadav-ds8oz5 жыл бұрын
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)
@ceskehry6 жыл бұрын
14:50 missing link
@siddharthgpta6 жыл бұрын
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.
@Knuckler6 жыл бұрын
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.
@andrewknauss61066 жыл бұрын
Where did glBindBuffer(GL_ARRAY_BUFFER, 0); come from?
@sugg57195 жыл бұрын
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.
@a1r5925 жыл бұрын
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.
@flTobi7 жыл бұрын
Why reuploaded?
@flTobi7 жыл бұрын
Oh, Okay
@evanotoole7872 жыл бұрын
I've got a segmentation fault @ function 'glDrawArrays'.