Hope you guys enjoy this (slightly longer) video! We're definitely going to talk more about how textures work and what we can do with them in the future, this is more of an introductory video as well as an example. :) Also one little mistake I made was with the m_BPP member in the texture class; I keep saying that this is the *bits* per pixel however really it's storing the *bytes* per pixel, which in this case is 4 since our texture is RGBA.
@hamseiggeh63316 жыл бұрын
TheChernoProject hello i want to know what is the framework.....thankz
@AmeshaSpentaArmaiti6 жыл бұрын
There is no framework! This is as close to "made from scratch" as you're going to get.
@TheLavaBlock6 жыл бұрын
Great work. Enjoyed it :)
@ratwalsh87946 жыл бұрын
May I ask you sir, I have gone over the code several times and it appears to be exactly like yours and I have no warnings or errors, yet the texture appears as a black square. Could this be a library or png related issue? if you have any idea how to fix, I would greatly appreciate the help. Thank you, Keep up the good work!
@sauravstark26876 жыл бұрын
@@ratwalsh8794 Try checking if you have spelled the location of image correctly, it worked in my case. While we're at it does anyone know what to do with 'Warning u_Color not found' message?
@namhto945 жыл бұрын
Guys if your texture is not showing (like me...), make sure you are using glTexParameteri() and not glTextureParameteri() in the Texture constructor ! I just rewatched the full video to find what was wrong... Thanks for this great API OpenGL lol
@vishwasbhaskar10065 жыл бұрын
Thanks man you really fixed my problem.
@mieyeombe32014 жыл бұрын
Thanks a lot! You helped me out
@gullideckel49024 жыл бұрын
same problem. Thank you!
@isaiasdimitri41104 жыл бұрын
Hey man, you are the man.
@dawidlubczynski75024 жыл бұрын
Thankfully I read this comment. Thanks!
@ucmRich6 жыл бұрын
Time=23:07="Detailed in-depth video on [how the rasterization works] and how [texture sampling works]" ^--Yes Plz 0:-)
@DJNecktron4 жыл бұрын
When the content of this entire series is basically everything I need for my Real Time Graphics course at university, just a bit of special requierments for the assignments. Very nice for getting knowledge, (both new and refreshed), for my further projects with OpenGL!
@DanipBlog5 жыл бұрын
This is so awesome dude, thank you for making these series!! You don't know how much you're helping people!
@kristyii80085 жыл бұрын
Hey, looks like you succeed at this point, can you send me code please, mine just do not working, i will be very grateful))))
@cghost4yt3 жыл бұрын
Just a small tip if you want stb_image to print out error messages: In the stb_image.cpp file after you have defined "STB_IMAGE_IMPLEMENTATION" you also define "STBI_FAILURE_USERMSG" and then in the Texture.cpp file you could do something similar to this: if (m_LocalBuffer) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_LocalBuffer); glBindTexture(GL_TEXTURE_2D, 0); stbi_image_free(m_LocalBuffer); } else { std::cout
@hermysfancy95143 жыл бұрын
For the flipped texture issue, you can also invert the 1s and 0s in the Y direction for the texture coordinates. So if your vertexBuffer starts like this : [-0.5,-0.5, 0.0, 0.0], [ 0.5,-0.5, 1.0, 0.0], [0.5, 0.5, 1.0, 1.0], [-0.5, 0.5, 0.0, 1.0] you change it to this: [-0.5,-0.5, 0.0, 1.0], [ 0.5,-0.5, 1.0, 1.0], [0.5, 0.5, 1.0, 0.0], [-0.5, 0.5, 0.0, 0.0] and the shader will read the texture upside down with no overhead as far as I can tell. Somebody correct me if this as some wacky downstream effect or something. I'm just some guy along for the ride hear.
@Kroschinsky2 жыл бұрын
if you do that the image will be draw upside down
@hiderr68054 жыл бұрын
I realy love how you explain everything! Thank you for all the videos on your channel!! I'm waiting for all the 'In depth videos ' XD
@DBbombed4 жыл бұрын
Just in case anyone else ran into this issue if you are trying to load a png with sdbi_load and it returned an empty image, At least in my case, it was because the png I was using was an indexed png and the stb_image header can not handle it just pull it into an image editor change the type and save the png again and it worked.
@juanx7834 жыл бұрын
You're right, dude! Png is tricky. Your words here helped me save tons of time.
@seba_mestre_ips6 жыл бұрын
Your couch has the most cinematic lighting ever
@Micha-mj7vg3 жыл бұрын
*Possible errors:* > You forgot to bind your shader before setting u_Texture > Program can't find your u_Color uniform because shader's compiler ignored it due to being useless ( do something like: --> color = u_Color * texColor; You got no errors and still black screen because you put somewhere "0" instead of "m_renderer_id" > You forgot to change the "f" letter while copying SetUniform1f function (propably not) > In VertexBufferLayout::Push you forgot to multiply "m_stride" by "count" ( example: m_stride += VertexBufferElement::getSizeOfType(SOME_GL_TYPE_IDK) * count )
@theantonlulz3 жыл бұрын
I swear you are a life saver, I was look at Texture::bind for a while thinking that there was no way glBindTexture was always supposed to bind to 0, and once I changed it it worked.
@Micha-mj7vg3 жыл бұрын
Ha! knew it
@coopikoop2 жыл бұрын
Another possible error: You decided to go to ms paint to draw a quick png file and it is black coloring on a transparent background. Call "glClearColor(1.0f, 1.0f, 1.0, 1.0f);" just before renderer.clear(); in your loop. This will make the background white so you can see it
@wrawler Жыл бұрын
i had missing semicolons in shader files 😅
@theo-dr2dz Жыл бұрын
It;s not necessary to have different names for the set_uniform functions (yes, I change the names, I don't like all those capital letters sprinkled all over the place). You can just make overloads with the same name. The compiler will select the right one based on the function parameters. Like: void set_uniform (const std::string& name, float f0, float f1, float f2, float f3); void set_uniform (const std::string& name, int i); Also, in the vertex array, nowadays we can use constexpr if instead of all those template specialisations. That looks a lot better and it costs nothing, the compiler wil figure it all out at compile time.
@NoodleFlame3 жыл бұрын
in the fragment shader you can multiply the color by the call to texture: vec4 texColor = texture(u_Texture, v_TexCoord) * u_Color;
@yannickmonjeamb34696 жыл бұрын
This Videos was really great. I like your explanations and how clean your code is. I hope you start with the GameEngine Series soon. I'm verey exited.
@ekhalips69726 жыл бұрын
been searching for those kind of tutorials for 2 years, found Cherno few months ago, and learned so much, Thank You!
@Finkelfunk8 ай бұрын
"Hey what's up guys, I know this intro is confusing but I will make a detailed video explaining it - my name is the Cherno and I should probably make another video on why I am called Cherno. Anyway, today we are using OpenGL - which I really should be making a video about - to render a texture. Now I will make detailed videos about rendering and textures in the future so look out for those!"
@the_zed60982 жыл бұрын
If you're by any chance getting a solid color when you're using a texture, make sure that in the AddBuffer function in the VertexArray class that you're passing the index into glEnableVertexAttribArray(), so it'd be glEnableVertexAttribArray(i). Missed it, silly me.
@fappylp2574 Жыл бұрын
Woah, thanks. Would have never found that!
@olavschioett4101 Жыл бұрын
thank you verry mouch i did the same thing
@quanta3968 Жыл бұрын
u saved my life xd
@philip_love_you Жыл бұрын
Thanks bro, you saved my life. XD
@euvictorguedes Жыл бұрын
Had to log in to my account just to say how much I love you! Spent the entire afternoon viewing and reviewing the code, comparing and everything. Even ChatGPT couldn't figure out. Thank you so much!
@diegosandoval20434 жыл бұрын
Everyone: Drawing Cherno: Drawering
@asarcagatay4 жыл бұрын
I am not sure, it is like 'drawring'
@MGSncB3 жыл бұрын
That's how a lot of Brits and Australians speak.
@weewoo37682 жыл бұрын
I'm just glad I wasn't the only one distracted by this
@Kevin-f4h6l8 ай бұрын
@@MGSncB *All Brits and Australians if they are not trying to sound American
@beachforestmountain42694 жыл бұрын
If you are having trouble with the texture not showing up, check that in the Basic.shader file you have the line "uniform sampler2D u_Texture;" and NOT "uniform sampler2d u_Texture;". (I had a lowercase "d" instead of an uppercase "D") I had to go through the whole video again to find my mistake.
@miles2354 Жыл бұрын
2 years later but thanks
@beachforestmountain4269 Жыл бұрын
@@miles2354 No worries man.
@aryesegal19886 жыл бұрын
Wow! a video half an hour long! NICEEE! :) Thanks, Cherno bruh!
@mathewmccloskey82426 жыл бұрын
Has anyone made a list of all the promised episodes?
@XxAl3X3IxX6 жыл бұрын
About 20 promised videos just for this series
@Dodo17sky6 жыл бұрын
Look at his profile videos list! At his age I think he made a lot of episodes from what he promised. Just pe patient !
@erlemusv6 жыл бұрын
"I promise one day I'll do an episode to make a list of all the promised episodes". Just kidding. This man rocks
@Fobber926 жыл бұрын
great episode mate! love the long videos too!
@MoMo-hh1zt2 жыл бұрын
Hi Cherno!Thanks for your video!It helps me solve a lots of problems with OpenGL.And I think it's the best video I have seen in OpenGL!A lots of gratitude for you!
@johnbarnhill3866 ай бұрын
If your texture isn't showing, also make sure that your texCoord is being correctly sent to the fragment shader. You can test if its sampling from the texture at all by using an image that doesn't have the color at (0, 0) as black like I was doing
@lucaaaa6382 Жыл бұрын
If I could like this a million times I would. You have effectively become my teacher.
@merle17 Жыл бұрын
Worked right outta the box, amazing video.
@adamodimattia4 жыл бұрын
Wow, finally I thouroughly understood how texture sampling works exactly. You’re amazing man!
@GrandPoobah46 жыл бұрын
So I have followed along with all your code up to this point, but now I'm getting a weird error. Whenever I try to add a texture, the shape only takes on one color. This color seems to be the value of the top left pixel of the PNG. Is this a common issue/ is there an easy fix?
@GrandPoobah46 жыл бұрын
Fixed it - in VertexArray.cpp, glEnableVertexAttribArray has to be called with "i". Looks like reading the docs does help!
@archcisero30496 жыл бұрын
ThanX for this! Very logical and straightforward to see when you pointed it out but didn't notice right away! When push-function is called again (for making space for the u_Texturer floats) another element of the std::vector gets constructed and pushed to m_Elements. Hence it need to be enabled with glEnableVertexAttribArray. I believe Cherno used 0 not "i" at previous tuts when we were only dealing with the positions. Didn't see him change it in this one though so not sure how he got it working. I'm also running theese tuts in ArchLinux setup with Vscode so my push function differs slightly due to the template-specification problem for other envirnments/toolchains than VisualStudio-compiler/Windows.. Great tutorials Cherno! :-)
@FROMANUSSUM6 жыл бұрын
Hot damn! Thanks dude!
@galenzhang31635 жыл бұрын
Wow!Wow!WoW!!!!!!!!!!!!!! Dude! Infinite Thank u to you! I almost bailed on this episode you saved me!
@funnymackerel94324 жыл бұрын
@@GrandPoobah4 You are a Superhero! Thnaks a lot!
@iyappansriram98544 жыл бұрын
And if suppose you want to include stb_image.h in multiple files, you can make sure to #define STB_IMAGE_STATIC before including stb_image.h....... GREAT SERIES CHERNO!
@TheRealFFS4 жыл бұрын
Thanks man, just recently had this issue.
@iyappansriram98544 жыл бұрын
@@TheRealFFS you're welcome😊
@jtaimneas6 жыл бұрын
question: does u_Color do anything now? I keep the CMD screen open and see this "WARNING: uniform 'u_Color' doesn't exist!"
@SasisaPlays5 жыл бұрын
U can blend texture with u_color by multiplication. Example: frag_color = texture(tex, uv) * u_color;
@username172345 жыл бұрын
When the shader compiler detects that a uniform will never be used, it might choose to stripe it off the code. So when you're trying to set that uniform up from your main application, it's not finding it. To fix it, either remove the references you made to it in the main app, or use it (even if banally) in the shader.
@giancedrick5074 жыл бұрын
last time I got this problem is cause I got glDraw parameters wrong
@hiren07ec3 жыл бұрын
if you are getting a weird error. Whenever you try to add a texture, the shape only takes on one color. This color seems to be the value of the top left pixel of the PNG Fixed it - in VertexArray.cpp, VertexArray::AddBuffer, inside for loop glEnableVertexAttribArray has to be called with "i". in previous video cherno used 0 so that it's not working
@drammsleo16242 жыл бұрын
Thank you! This worked for me.
@I_hate_HANDLES Жыл бұрын
thank you so much !! now i can go to eat junk food without worrying about the bug !! how
@osamaxz5720Ай бұрын
IDK if still someone watching this golden course but if your textures doesn't get rendered in the screen instead you got a black screen check the bind function specially the GLCall(glActiveTexture(GL_TEXTURE0 + slot)); I wrote it GLCall(glActiveTexture(GL_TEXTURE8 + slot)); by mistake so make sure to write GL_TEXTURE0 not GL_TEXTURE8
@TinoBurset4 жыл бұрын
Fantastic content as usual! (Huge) Thanks for sharing your knowledge Yan! 🙌
@afterlife1578 Жыл бұрын
If someone's getting a black screen and tried all the other solutions from the comments, mine was an embarrassing mistake, I miswrote the path to the image, so check if the full path is correct when calling the texture constructor.
@Dr_mafario Жыл бұрын
Im so glad this comment is here. Following the tutorial makes finding errors look pretty simple, and after making this mistake I now know why debugging OpenGL can be a pain sometimes. Really wish OpenGL gave *some* kind of error for messing up the path, but oh well Edit: For context, I named my image "Heh" but called it "Huh" in the file path. Dumb mistake and I shouldnt have named it that, but still
@JJnnaatt Жыл бұрын
I had the same error. I forgot the relative path is based on where the vcxproj file is, and not the source code. Thanks
@ottaviarossini80204 жыл бұрын
Hey, I am still facing some trouble with the textures. Somehow the rectangle takes only the left bottom most part of my texture. Any ideas? Could they have changed sth in the libraries? Maybe my PNG is faulty? ( created it with the export tool of Illustrator)
@tobiaspfatrisch34734 жыл бұрын
Did you found a solution for this problem? I have trouble like since the last 4 hours with exactly this "bug"...
@tobiaspfatrisch34734 жыл бұрын
Found the solution in the comments: VertexArray.cpp: glEnableVertexAttribArray(0) has to be changed to glEnableVertexAttribArray(i)
@spitfxre3 жыл бұрын
@@tobiaspfatrisch3473 i love you thanks dude
@dgmullin12 жыл бұрын
This happened to me and it was because I forgot to change the second layout in Basic.shader to "layout(location = 1)" so it was reading the position coordinates as texture coordinates 😳
@yulozano42946 жыл бұрын
if you don't see anything on your screen, it's might because you have to push to your layout 2 times. layout.Push(2); layout.Push(2);
@Byynx Жыл бұрын
Case you're having access violation error in stbi_load() function, just creat int variables for each parameter after "width". Cast it if you need.
@DragonBlazeXII9 ай бұрын
If anyone is experiencing issues with textures appearing as a single color, ensure that in the VertexArray.cpp file, on the line where it states "offset += element.count * VertexBufferElement::GetSizeOfType(element.type);", you are multiplying element.count by VertexBufferElement::GetSizeOfType(element.type) instead of adding as I mistakenly did.
@ablender57505 жыл бұрын
My texture is displaying weirdly, no matter what I do with the texture coordinates in the vertices the images bottom left (0, 0) is always in the centre of the screen. And likewise the top right of the image (1, 1) is always at the top right of the window, but cut off if the geometry doesn't cover it. Does anyone know why this could be?
@faizahmed49225 жыл бұрын
I have also the same issue, can anyone help
@jimmykonings21274 жыл бұрын
I have this exact problem as well. Did you (or anyone else) find a solution for it already?
@jakobhyer23164 жыл бұрын
I know i am very late, but i fixed it by checking the VertexArray.cpp It turned out that i was resetting the offset every loop, so like this Bind(); vb.Bind(); const auto& elements = layout.GetElements(); for(int i = 0; i < elements.size(); i++) { const auto& element = elements[i]; unsigned int offset = 0; GLCall(glEnableVertexAttribArray(i)); GLCall(glVertexAttribPointer(i, element.count, element.type, element.normalized, layout.GetStride(), (const void*)offset)); offset += element.count * VertexBufferElement::GetSizeOfType(element.type); } But it should be like this Bind(); vb.Bind(); const auto& elements = layout.GetElements(); unsigned int offset = 0; for(int i = 0; i < elements.size(); i++) { const auto& element = elements[i]; GLCall(glEnableVertexAttribArray(i)); GLCall(glVertexAttribPointer(i, element.count, element.type, element.normalized, layout.GetStride(), (const void*)offset)); offset += element.count * VertexBufferElement::GetSizeOfType(element.type); }
@experimentators86994 жыл бұрын
@@jakobhyer2316 i tried this but it doesn't seem to work...
@Bolicubo3 жыл бұрын
@@jakobhyer2316 you saved my life
@anoomage Жыл бұрын
I ran into a problem. My texture either wouldn't show up, either would show as a solid white square. I tried to follow advice from comments section but nothing helped. In fact... I tried some things on my own, like adding a normal field in my vertices, creating a Mesh class with a loader and a Window class, so the debugging was hard. I have a Vertex class and its instances are stored in a std::vector, and components are Position, Normal, TexCoords. So, in the vertex shader, the location of "vec2 texCoords" is 2, not 1 !!! Location 1 will be for normal. I think I did not understand this part at all but after hours of debugging, I think now I got it :') Location stands for VertexAttribPointer number.
@testedpugtato9687 Жыл бұрын
Im getting kind of a weird error. The image is rendering perfectly, but only for one of the two triangles. For the other one, the color is being stretched from the top of the triangle all the way down. Any clues as to why this is happening?
@EECyrpys Жыл бұрын
I managed to recreate this by "mistyping" one of the values in the positions array (the ones he added in this video), so if you get this behavior, that is the first place to check :)
@YagPatry4 ай бұрын
@@EECyrpys damn i really forgot a comma there, thanks man
@siminho69294 жыл бұрын
Hey Guys :) It seems that the code does not working in my case. I am always getting a white rectangle....I checked the Texture.cpp, the Shader file and also the glEnableVertexAttribArray(i). I also debugged the code and there is no error while reading the png-file and so on. Can someone help me?
@siminho69294 жыл бұрын
Okay i found the problem after 2 hours of searching....In VertexArray.cpp the offset wasn't calculated correct, the element count was added with the size of type instead of multiplied... Maybe this helps someone :)
@rajasbondale65123 жыл бұрын
@@siminho6929 I am pretty sure you won't see this comment, but I'd like to give you a kiss
@ilyosbeknajmiddinov67542 жыл бұрын
hello bro help me this string while cout Warning: uniform 'u_Color' doesn't exist! how can I fix this pls help and 2 errors C4430 C2143
@zaca2116 жыл бұрын
Just FYI. If anyone is getting a black screen after creating a PNG in GIMP. Try a different image. It seems to not like the image files exported with GIMP. Hope this helps someone.
@valrossenOliver6 жыл бұрын
Same with Krita. Export settings incorrect?
@JorneDeSmedt6 жыл бұрын
NVidia seems to have a lot of the features already enabled in their implementation of OpenGL. First the basic white shader, now blending... The only downside is that I can't actually confirm if everything also works on a system where those things aren't enabled by default.
@thomasrouch39444 жыл бұрын
If your IDE is automatically formatting your code, you could get a "expected primary-expression before ‘>’ token" error when compiling stb. Simply copy-paste-save the stb code outside the editor and you will be fine.
@cili78004 ай бұрын
If you are getting a black screen, a good source of debugging might be the stbi_load function inside the Texture.cpp file. In my case, the problem was that it couldn't load the picture, even though vs saw it as a png file. had to run it through paint and save it in order to be usable.
@Cabre942 ай бұрын
te amo loko
@nidalbizri4 жыл бұрын
Why include shader.SetUniform1i("u_Texture",0); it has no effect on the final result and produces an error message that "u_Texture" is not found !?
@advayg4 жыл бұрын
Ig you didn't bind your shader before that
@YellCalum6 жыл бұрын
Hey, so you mentioned that most game engines use their own file formats for textures. I was wondering does this also apply to models, sounds, etc? and why? to keep the format similar to the internal one and improve loading times? Any file formats you would suggest not caring about intellectual property protection? also great video! 30 min videos are good :D
@sizzlebae20606 жыл бұрын
Interesting, I have never really thought about this
@blujay36396 жыл бұрын
This was a long time ago, but I still believe that it warrants an answer. Many companies use proprietary (or their own unique) file formats for many reasons. One of these reasons is protection against piracy and/or modding. For instance, Nintendo uses file formats such as .mbn for 3D models in Super Smash Bros. for Nintendo 3DS, to at least slow down the development of texture/model hacks (took the hackers almost three years). Also, when you design the file format from scratch, you are less prone to bugs cropping up if you implement your own unique setup (it would be like designing a car from scratch, you would know where every part was whereas you would need a manual for doing the same thing but for a Toyota). This also plays into the fact that your group alone determines how the file format is created, meaning that there won't be very much variation (if any) in the format (look at the bitmap file format for a counter-example to this).
@koungmeng5 жыл бұрын
@@sizzlebae2060 is that Chitoge?
@sizzlebae20605 жыл бұрын
@@koungmeng yah
@bluescanfly19812 жыл бұрын
It applies to every asset. when making your own game / game engine you know what assets belong together - this lets you compress, pack or otherwise optimize the asset pipeline - this becomes particularly important across multiple platforms. The artists, designers on your team usually work with industry standard tools, however you often write plugins / exporters for these tools to produce your custom formats
@mayankshigaonker77254 жыл бұрын
Hey could anybody help me. I a problem sort of. its that I have to declare my indecies as 0, 2, 4, 4, 6, 0 to get the proper image to be displayed. This is not a problem but just wanted to know why i have to do this rather than doing the normal thing which is 0, 1, 2, 2, 3, 0.
@zink10craft704 жыл бұрын
I think this is because of your vertex position format. I think you specified a type double the size of your actually wanted size, or somehow messed up when setting the values in the vertex buffer.
@themakabrapl22483 жыл бұрын
I had this problem and your comment really helped me, Thanks :D
@TheTruock2 жыл бұрын
Probably you also want to remove the "u_color" uniform handling in the code, since it will be probably get deleted from the shader during the compilation of it. Otherwise you can try to combine the texture together with the blinking effect with a line like this color = texColor * u_color;
@killcode67172 жыл бұрын
you Sir, Are an angel
@johnraz99 Жыл бұрын
Thank you!
@CharmingPotato144 жыл бұрын
stbi_set_flip_vertically_on_load(1) fixed my problem where textures were loading upside down. Thank you so much!
@theashbot4097 Жыл бұрын
What does v stand for? 26:30. Thank you!
@rishimenon56324 жыл бұрын
26:50 The vertex shader runs 4 times because we have 4 vertices, so 4 coordinates are going 'out' of the vertex shader. But the fragment shader gets called for every single pixel. So what value is stored in the v_TexCoord inside the fragment shader ? (i mean which out of the four possible values). Im guessing the value will change obviously so when does the value change ?
@ed_iz_ed4 жыл бұрын
Each fragment gets the interpolated values from the vertex shader, so the fragment in the middle gets the average of all values for example.
@nikoszervo6 жыл бұрын
Cherno, you're really making a good job! I'm an advanced programmer but still its so difficult to learn opengl and the documentation is for those who have done graphics before. I hope next video be about matrices transformations! I really wanna see some motion on the screen and 3d graphics!!!
@giancedrick5074 жыл бұрын
usually before you go into matrices and animations, you have to do some math
@MaraisStephane6 жыл бұрын
So I had a bit of an issue here. Depending of the editor I was using (CLion or VS) I have different complaints with different issues but all related to the same point. On CLion my program was complaining about u_Color, not existing and on VS u_Texture was not existing. My code was matching 100% with Cherno's one. Turned out you NEED to remove shader.SetUniform4f("u_Color", ...); in order to have it working with no errors (you also need to remove the uniform vec4 u_Color; in the Basic.shader file. We are not using it anyway for now. if anyone knows why we can't have multiple uniforms at this stage, I'd really know why.
@jialeichen95066 жыл бұрын
The compiler will optimize and get rid of the unused uniforms, so in this case u_Color doesn't really exist at run-time.
@MaraisStephane6 жыл бұрын
@@jialeichen9506 sure but why would an unused uniform prevent the code from being properly displayed?
@jialeichen95066 жыл бұрын
@@MaraisStephane I'm not sure if this is answering your question but if you just leave the uniform unused in the shader, it wouldn't (I experimented with it a bit) prevent the code from properly rendering. However, if you still assign the output color of your frag shader to color = u_Color then it would be an error. (It might or might not be your issue, but that's as far as I know :)
@NotNazuh Жыл бұрын
If your having a problem where your texture is renderering but displaced, go back to VertexArray.cpp, head into AddBuffer and when you call GLCALL(glVertexAttribPointer()); change the last parameter in glVertexAttribPointer() to (const void*)offset. ex: GLCALL(glVertexAttribPointer(i, element.count, element.type, element.normalized, layout.GetStride(), (const void*)offset));
@YmanYoutube11 ай бұрын
OH my god thank you bro you saved my life! Do you have an idea why this causes a problem?
@Ta5taturta5t36 жыл бұрын
Why is glActiveTexture() not called in the constructor before binding the Texture?
@Bundas1024 жыл бұрын
It doesn't matter which slot it binds to, because you don't want to use it for rendering there.
@tomkohler1609 Жыл бұрын
@@Bundas102 It does matter, because it will break any texture binding in the current active texture slot. Same goes for the Unbind function: texture1.bind(0); // bind texture1 in slot 0 texture2.bind(1); // bind texture2 in slot 1 texture1.unbind(); // which texture will be unbound now?
@cloudirs53 ай бұрын
For some reason I have to set the filepaths to include "OpenGLTutorial/res/shaders" or "OpenGLTutorial/res/textures" in order for it to work.
@Byynx Жыл бұрын
Guy's it's very important to give the same names in inputs(in) and outputs(out) variables between vertex and fragment shader, otherwise opengl could never know how to link them.
@eggmeister66413 жыл бұрын
screen black. how to fix?
@theantonlulz3 жыл бұрын
I'm just getting a black screen, I followed the code exactly and I'm getting nothing but "Warning: uniform 'u_Color' doesn't exist!", which goes away if I simply assign the color as we did before the texture. VS finds the image just fine, the buffer is not null, I even printed the dimensions of the image and they are correct, I have no idea where the problem could possibly be. Edit: fuck me, I'd gone over the video 3 times and didn't notice I called glBindTexture inside Texture::bind on 0 instead of m_RendererID.
@ldmdesign56102 жыл бұрын
These videos are awesome and doing it after going through half of the C++ ones is helping to see and practice using all that stuff over and over. Excited to try the game engine series soon too. Have to wonder though what has changed in 4 years since the videos were made.
@sjscurrell1874 жыл бұрын
Hey The Cherno. I'm really enjoying you're OpenGL series. I'm slightly confused about how the interpolated texture coordinates are being passed from the vertex shader to the fragment/pixel shader. In your episode on shaders you mention the vertex shader is called once per vertex, and the fragment shader called once per pixel. That makes sense, , but what I don't understand is if that is the case would the texture coordinates passed to the fragment shader only ever be the values defined in the vertex buffer? Since the vertex shader only runs 6(?) times how does openGL know to interpolate the texture coordinates before passing them into the fragment shader? Hope that makes sense.
@EECyrpys Жыл бұрын
Ye, I'm new at this, and at this point in the course it feels as if we don't really know exactly how the shaders work ;p
@kumu2024 Жыл бұрын
The problem with this tutorial is that the texture coordinate is written manually to the vertex of the shape. I cannot figure out how to calculate the textur coordinates for shapes that might be loaded dynamically? how would you calculate that? All tutorials assumes that you have a 3x3 vertices ..etc. and they add the texture coordinate to that array. I cannot figure out how to do that.
@TGamingFull6 жыл бұрын
I can't seem to load a PNG file into the program, when I load one file I get a total white mess with a few blue pixels. When I load another file I get an "Access violation reading location" error. I can't seem to figure out what I am doing wrong, I have checked that everything is typed correctly from this video.
@TGamingFull6 жыл бұрын
Nevermind I figured out the problem, I had parsed a GL_UNSIGNED_INT instead of GL_UNSIGNED_BYTE in the glTexImage2D function, which resulted in some strange errors.
@giancedrick5074 жыл бұрын
@@TGamingFull I was going to suggest setting your current working directory right in your IDE or build tool, but good job!
@sv26706 ай бұрын
Hey there! I'm on mac and cannot make this code work (black screen, error 1282 from the Draw function). I commented all the code in main and shader from this class and it works well, but adding the exact same code and gettting this error, has anybody have this issue?
@chrspinto2 жыл бұрын
Here you set the texture coord for each vertex of the quad. How would you manage a complex surface which several triangles. What texture coord would i set for each of them?
@adrielbradley6677 Жыл бұрын
I didn't enable blending, but my image came out fine, any idea why?
@vijaylamkane56194 жыл бұрын
I want to get image from X-ray scanner Data and display it using OpenGL windows in c# how can I achieve this
@giancedrick5074 жыл бұрын
you have to deal with the x-ray scanner API yourself, convert the video/photo format with some library like FFmpeg, and finally display pixel data with OpenGL. I thought of this on the spot but the idea seems okay. :)
@theneuroware40573 жыл бұрын
Very good tutorial! Thx!
@nickkane-dev4 жыл бұрын
holy shit, I just wasted a ton of time debugging code that worked perfectly fine when the problem was my shader code. Opengl didn't throw an error for me. Make sure to check the names of your out parameter vs your in parameter of your vertex and fragment shaders. I feel pretty dumb right now lol
@cloudbeta614 Жыл бұрын
Hello! My vertexArray (The shape of my vertices) is black when i try to render the texture... I tried to copy everything you write but it still does not work, no matter what is do! What should i do? I tried version 3.3 and version 4.6. Didnt work any way!
@Levendo4 жыл бұрын
I'm doing this on a mac, and I keep getting a black screen. -I checked everything. The code is literally the same. I wonder why it's not working. Is it because the png file I'm using isn't compatible with the library? Where can I find an image that works with this program?- Edit: found the reason. I accidentally set glBindTexture to 0 instead of m_RendererID :p
@BlackKillerGamer3 жыл бұрын
he actually wrote it with a 0 in the Texture constructor tho I had the same problem, changed it to m_RendererID and it worked
@kinochdotcom3 жыл бұрын
Doing a lot of debugging, I never found a time when m_RendererID was not 0, because we only ever make 1 instance of the Texture class. Found this doing some m_slot debugging. My problem was. I called glBindTexture() twice by mistake adding code to check if m_LocalBuffer actually was loading the image into memory.
@frosty76743 жыл бұрын
Cherno: BEST programming laptop... Me sees price: *why does it even exist?*
@gower19734 жыл бұрын
My program compiles but no picture when it runs, if you look at the window behind its saying failed to compile the fragment shader even though its written exactly the same as Chernos, I get error C1060 incompatible type, C1056 invalid something, C0000 token color expecting , or ;
@gower19734 жыл бұрын
Nevermind I fixed it one line wasn`t written correctly in the fragment shader, I missed he had texture as a type and a variable name in the texColor line
@yavuzselimcagan52332 жыл бұрын
If VertexShader is called 4 times in this case, which out v_TexCoord is passed to FragmentShader? of 4? And which pixels look out for which vertex's outputs?
@iyappansriram98544 жыл бұрын
Hey Cherno! I tried implementing STB_Image to my openGL project. Worked Great! But when I tried to abstract it into something like a texture class, I get a linker error saying i have redefined STB image functions. Any tips on how to avoid that? I dont think i can rewrite the entire STB_image.h to have a .cpp file of its own. Thank you, much appreciated!
@iyappansriram98544 жыл бұрын
And i know STB image explicitly says for me to include it in one file. But the header is getting circled around. I don't know what to do...
@iyappansriram98544 жыл бұрын
figured it out. I was including stb_image.h in multiple files. Made its own CPP file and defined STB_IMAGE_STATIC before including stb_image.h
@disgust_jpeg18714 жыл бұрын
Idk if i missed it or not but if your texture's not showing up try adding "glBindTexture(GL_TEXTURE_2D, m_RendererID)" in your Bind function for the texture class, fixed it for me
@justaskaulakis82023 жыл бұрын
bruh what did u put before?
@disgust_jpeg18713 жыл бұрын
@@justaskaulakis8202 Idk probably nothing because i am brain dead
@stormsoendergaard30234 жыл бұрын
Can anyone explain to me why my texture is flipped by default, the stbi_set_flip_vertically_on_load(1); call flips it the wrong way?
@thatKurtis4 жыл бұрын
You could have used a different file format or you made a slight "mistake" somewhere like flipping your verticies
@stormsoendergaard30234 жыл бұрын
@@thatKurtis I was flipping my vertices, thx
@thatKurtis4 жыл бұрын
@@stormsoendergaard3023 I am shocked my poor explanation managed to help you
@ben-nh9sn6 ай бұрын
14:25 "this is... this is..." had me weak
@chinmayanand8966 жыл бұрын
we like long videos dear....i always your confidence while you are telling something good.
@jangronowski81804 жыл бұрын
I'm confused about the vertex buffer layout. If the stride is two floats and the offset is 0 should the texture cords be interpreted as positions aka the 0.0 and 0.0 being positions? What's separating positions and textures?
@Byynx Жыл бұрын
With the TexCoordinates attributte now the total Vertex stride is 4 * sizeof(float). 2 float for position and 2 floats for texCoords. And yes texcoords beggins at coord (x0.y0) and ends at (x1,y1). Like a screen coordinates but between 0 and 1.
@SohailSiadat Жыл бұрын
Can you explain more about why game engines use their own format? Do you mean each use their custom format? Or there are industry standard file format suitable for their use (eg mipmapping, certain encoding and size needs etc) makes them suitable for standard implementations.
@adrielbradley6677 Жыл бұрын
Did you ever find an answer to this?
@anonymoussloth66873 жыл бұрын
Does this mean that the texture is now in gpu memory? So suppose we had to make changes to it alot (ex: Each frame in our application) would the texture be modified in the gpu or in the CPU and sent back and forth to the gpu?
@lisandroCT6 жыл бұрын
Hey, Cherno! Really great content, thank you! Quick question? What happens if we call the unbind() method but it turns out we have changed the active texture before (binding another texture, for example), wouldn't that unbind that other texture slot?
@AmeshaSpentaArmaiti6 жыл бұрын
Yes, it would! That's why you have to be careful and make sure you're unbinding the slot you bound to in the first place. You could store the slot the texture is currently in ("currently" because you can rebind slots easily). It's also helpful to unbind immediately after the texture is no longer needed, say, at the end of a draw call so you don't have to worry about that in the first place.
@lisandroCT6 жыл бұрын
Jinzo Okami I thought about caching the slot but that wouldn't allow me to reuse the texture in different slots. What if I keep a texture binded and I don't ever use it again, does that affect the performance?
@AmeshaSpentaArmaiti6 жыл бұрын
Lisandro Crespo if it does affect performance, it's not by much. The texture slots only get used when the shader accesses them. It would actually be less of a performance impact if you never unbound. Also, I can't think of a situation where you would want a single image in multiple slots. Unless you mean rebinding, in which case, just overwrite the current texture slot.
@czdiejengco5 ай бұрын
Can someone please explain to me what this called and what it does actually function(...) : something(something), something(something) {}
@puneethreddyk79754 ай бұрын
This is called an initializer list.Basically it initializes the data members of a class.
@jasonbrown57524 жыл бұрын
Any reason why image would be distorted along a diagonal line corner to corner b-left to t-right? all code works to this point and it isn't an issue in the image file.
@MuscIeBomber20214 жыл бұрын
I'm having this same problem! Did you figure it out, by chance?
@MuscIeBomber20214 жыл бұрын
Nvm, just figured it out. I'm dumb as hell lol
@antopilo74184 жыл бұрын
@@MuscIeBomber2021 what was the solution
@MuscIeBomber20214 жыл бұрын
@@antopilo7418 I don't remember the exact situation anymore, but if your texture is distorted, it's most likely because your index buffer is incorrect.
@antopilo74184 жыл бұрын
@@MuscIeBomber2021 thanks I fixed it :)
@robtroman8186 жыл бұрын
When I try to load the texture file with stbi_load it does not load correctly and warns error reading characters in string I have tried different files and file formats but always get the same result
@padonmurdock85764 ай бұрын
If you are copying the file path of your image and pasting into your program you will have backslashes in your file path "\" which is a line end in C++ change them to forward slashes "/" and you image should load properly.
@JustYesntMan5 жыл бұрын
how to update my render sizes on window resize ? right now they are hard coded as you know
@emanuelkokovics3 жыл бұрын
No matter how I change positions[], it still seems to render just one small portion of the image (small part of bottom left corner). Any ideas, anyone, why? Any suggestions on how to solve this? So I tried another picture, and it seems like my canvas is divided into 4 small rectangles, and the picture is drawn on the right top one (well just a part of the picture (the left bottom corner)). It seems to not even matter what I put in the positions[] array! :(
@batuhanyigit43423 жыл бұрын
I'm having the same problem here I can't seem to figure out why
@xardas45112 жыл бұрын
I found a small solution. But it is not perfect. If you change the order of the position vales. (so firstly the texture coordinate and after 2 position coordinate). After that, I see the full image in the window top right (instead of the middle)
@xardas45112 жыл бұрын
I found the solution. my error was in the shader. The location of texCoord should be 1 instead of 0. So the good result: layout(location = 0) in vec4 position; layout(location = 1) in vec2 texCoord;
@danielkrajnik38174 жыл бұрын
10:52 the only correct origin point
@imcnx15633 жыл бұрын
What’s the difference between stb_image.h and stb_image_write.h?
@milo200602 жыл бұрын
Hmm... Fragment shader failed to compile with the following errors: ERROR: 0:7: error(#132) Syntax error: "uniform" parse error
@GamerCreativo20245 жыл бұрын
I got a big memory leak, I don't know if in some part is necessary to unbind the texture, someone knows?
@evandrorodrigues70914 жыл бұрын
I'm getting the warning from Shader.cpp: "Warning: uniform 'u_Color' doesn't exist!" But everything seems to be working and texture displayed correctly, any ideas?
@Unifrog_4 жыл бұрын
I got this too. It goes away if you remove the uniform and dont set it in your program (since you are now getting the color from the texture) or if you use the uniform in the calculation of the color. Apparently the fragment shader compiler optimizes away uniforms that are declared but not used so you can no longer set them but otherwise the shader still works.
@imankalyanmaity5 жыл бұрын
Though it's working, I'm getting 1 error: 'ERROR::uniformu_Colordoesn't exist'. And I had to give the absolute image path, the relative path didn't work. ... can anybody tell me why?
@JohnnyGintonic5 жыл бұрын
same here
@9y0285 жыл бұрын
Not sure but I think it is because u_Color isn't used in the fragment shader since we're getting the color from the texture. The compiler probably removes that uniform because it is unused or something. It's nothing to worry about
@mariovelez5783 жыл бұрын
I get a breakpoint here: GLCall(glAttachShader(program, fs)); Anyone know how to fix it? thanks
@michaelbuckingham40303 жыл бұрын
Hey, I have the same issue. Did you ever manage to solve the problem?
@masterjj13 жыл бұрын
I also have this issue
@masterjj13 жыл бұрын
Just figured my error out. Turns out I forgot 2 semi colons inside of Basic.shader
@mariovelez5783 жыл бұрын
@@masterjj1 Thanks I'll check it out
@nielsdaemen4 жыл бұрын
what about float textures for fluid simulation?
@cieloabatido7 ай бұрын
it would be helpfull to have the code for all this project
@imankalyanmaity5 жыл бұрын
No error, no warning, still getting a black screen, before and after the blending. 🤷♀️