I managed to create a sphere (calculating all the vertices etc etc). Now I want to apply a texture on it. I have no idea how. I googled some "OpenGL 3 texture tutorials" but I can't seem to find anything simple. I am using shaders btw. Is there anywhere a very basic step by step tutorial on how to implement a texture? A texture is just an image that wraps around a shape right? Sounds simple, but from what I have seen on the web it's kinda complicated.
There are three main components to basic texturing.
First you need to create a texture object, which is done with
Then, you need to provide UVs. These are normally part of the vertex buffer, so you should include a float2 component in your vertex struct for this. The UVs would usually be created by an artist using modeling software, but they can be generated programmatically as well. In any case, getting the right UVs to the right vertices is your responsibility. Assuming you're using vertex arrays / buffers, you'll use
Finally, in the shader you'll need to declare a
When you do the draw call on the application side, don't forget to do
I assume you can google the GL calls I mentioned to find out all the details. There are a bunch of moving pieces here but really it's not that complicated. Most of the work is just getting your data to the right place at the right time.
|show 4 more comments|