Advanced C++/Graphics Tutorial 9: Interleaved Vertex Data, composition, offsetof

preview_player
Показать описание

In this tutorial we learn how to enhance our vertex data using interleaved vertex data! We also learn about composition and the offsetof macro!

Рекомендации по теме
Комментарии
Автор

Hey Ben, thank you very much for this tutorial series. I have tried several openGL tutorials and books but I haven't been able to get the code to work in a single one except for yours. They did all use many dependencies while offering minimal or no explanation on how to use them in the project.
Getting started with openGL seems to be the hardest part because most tutorials focus on specific concepts and it is very rare to find someone starting at the beginning.

I will definitely work my way through your tutorials during the next days and weeks and I'm also planning use your tutorial/code as starting point to learn 3D openGL!

ManuMum
Автор

This is as relevant now as ever! Great series, your explanation of why things are how they are makes a lot of sense. Thanks

dromn
Автор

Just wanted to put in a comment of praise. Your vids are very well laid out and I love them. I knew a good fair share of this already but going over all of these and seeing your train of thought as you are going through them is extremely interesting haha.

jeremyrichardson
Автор

Hey. The dropbox link is no longer valid. Any chance you can put it back or put it on github?

antoniocs
Автор

finaly a good serie about graphics i asked alot but i getting better and better in c++ i love your series please keep them going ! :)

haedrip
Автор

These tutorials are great, you explain everything so clearly!

BL-dmsz
Автор

Just a handy function I made, under your Vertex Struct, add 
void setColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a)
{
color.r = r;
color.g = g;
color.b = b;
color.a = a;
}

and then you can 
vertexData[1].setColor(0, 0, 255, 255);
vertexData[4].setColor(0, 255, 0, 255);

ConnorMoody
Автор

Edit: Fixed itself after restart, thanks :)

Hey Ben, I can't manage to get this working, I wrote my own version then I copy pasted all of yours. All that I get when I run my program is a black screen in my window, no errors, everything else is working the only thing wrong is the black screen! Any idea what this problem could be ?

benny
Автор

Hey Ben, hope things are going well with you. I have a quick question about what is done in your tutorials. We set data for the vertices to the bottom left and top right twice, which makes sense to make the two triangles. Though, this method seems to use 24 bytes of extra data, which I would assume would hurt performance as the triangle count increases and there are shared edges between two triangles. Is it possible to share vertices between two triangles in order to save on data usage? If this is explained in a later tutorial, then disregard this question as I have only reach this point thus far. Great work on the videos too by the way.

fishj
Автор

Your tutorials are awesome ! Thank you very much !

nyu
Автор

Shader files can be opened in Visual Studio which make them easier to edit. Right click on the project, add "New Filter" (folder), say Shaders, then add the shader files in the new folder.

lastblow
Автор

69 jokes... Classy! Cool tutorials though. I am enjoying a lot

Carlos-isgk
Автор

damn, I moved the glCreateProgram call into compileShaders and now it doesn't work...

edit: oh, apparently it's because I accidentally call initShaders both in initSystems and in run lol

FreeER
Автор

Not sure if anyone ran into this particular issue, but I was getting a white block instead of my shader color. Fixed it by moving my color for loop above the vbo bind function and underneath position specs.

musclesmacaroni
Автор

I got an error from the last tutorial I thought this debug part might fix. It says: "Shaders/colorShading.vert: No such file or directoryFailed to open Shaders/colorShading.vert"not sure what I did wrong, the filepath is right.

IDrawStuffs
Автор

Stack array* Not static array. Having that array static would mean that you can only have one sprite.


Also, you might have covered it or not. But a more "C++" styled way of casting it to a void* would be:

reinterpret_cast<void*>(offsetof(Vertex, position));

instead of:
(void*)offsetof(Vertex, position);

valizeth
Автор

I'm intrigued about performance when using composite data instead of raw numbers, for example, I could have a bunch of floats instead of a Vertex struct. On the other hand, I don't think it would hurt too much because data is only uploaded to GPU once, and having separate data really helps readability (debugging a bunch of floats can be a nightmare). Still...

And... it just came to my mind. I know I may sound silly (or maybe I am), but explaining stuff with graphics (oh the irony) is really awesome. You explained vertices using paint, and believe it or not, seeing the thingies connected visually expands understanding exponentially. Well, at least for me! If you could draw some fancy diagrams to show a conceptual representation of interleaved data, or the pipeline at some point, it could help explaining stuff in a more clear way. Of course, some people learn more from actual coding, I for one love graphics, even the simplest one is enough to take me off the shadows.

By the way, awesome tutorial! Keep it up!

paulocbbf
Автор

First, thank you for these tutorials, I really learned a lot, I came from a C# + XNA 4.0 background and since XNA is already axed, I like to learn something new, C++, SDL and OpenGL seems... challenging. 

I would like to ask, will there be tutorials in the future to convert the Normalized Device Coordinates to something like a Cartesian plane coordinate system (what I used in XNA mostly on 2D rpgs) ?  Also, keep up the good work!

SignumCruxis
Автор

I wrote the exact same code but all I'm getting is the shades of all colors as my output, though I was getting a red square at the bottom left of the window as shown in the previous tutorial.

deepikasinha
Автор

If I put GLuint _programID = glCreateProgram() awat from linking function, I receive breakpoints as I try to compile. Infinit quontity. And if I keep it there, my box is white. Urgh. I don't want to quit this series, but sometimes it seems as I have no choice. So frustrating.

ТайныйЯ-кь
join shbcf.ru