Basic Texture Mapping // OpenGL Tutorial #16

preview_player
Показать описание
In this video we will go over the details of getting basic texture mapping working in OpenGL using C++.

If you want to get the same version that was used in the video checkout the tag TUT_16_TEX_MAP.

Timecodes:
0:00 Intro
0:40 Challenges
1:02 Texture coordinates
2:00 Number of texture axes
2:32 Naming the texture axes
2:58 Minification and magnification
4:53 Filter types
6:08 Texture mapping arch in OpenGL
8:28 Texture mapping TODO list
10:34 Star of code review
10:37 Getting STB image
12:18 The Texture class
13:44 Loading the texture
17:22 Setting texture state
18:11 The bind function of the texture class
18:36 Shader changes
19:42 Handling texture coordinates
20:17 Misc changes to app code
20:55 Changes to the render loop
21:28 Build and run
21:34 Conclusion

Feel free to comment below.

Twitter: @ogldev

My gear (Amazon affiliate links):

Credits:
Images:

Enjoy,

Etay Meiri

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

my college professor gave us this assignment with barely any opengl explanation. He threw around methods like glbindbuffer and other methods around left for us to research. I am so happy this video exists. Thank you so much!

Hansly_rz
Автор

Yes, this was what i was waiting for.

dimension-jixk
Автор

Like it! this tutorial is very clear and easy to understand.

huiminliu
Автор

I loved that slide which listed all the steps of rendering a texture. the whole process exists in multiple domains like the image file/ getting pixels is in user code/stb, the texture object and uploading pixels to it, binding it to a texture image unit in gl code, and finally sampler in a glsl.

otoh, it also feels way more complicated than it needs to be. i don't see the point of texture unit or sampler variable (which is a signed int, if we wanted to select different unit) rather than just use the texture id that you get from genTexture.

coderedart
Автор

Very good video, though I am trying to understand how the interpolated coordinates are mapped to texels; I would like a detailed video explaining

burzum_
Автор

At 10:24 you say the glBindTexture() upon the creation of a texture object it only binds to a target. I know we're saying what type of texture 2D or 3D is, but what is this target? And why if we use the same function after glActivateTexture() we are binding it to a texture unit or it seems to act different ?

Byynx
Автор

Hi, i'm trying to cast a float attribute (tex_ID) to an int in the frag shader to use it as index to texture 2 different meshes, but if i do "int index = int(v_texID);" it doesn't work properly, only if i do "int index = int(round(v_texID));" than it works fine. Do you have an idea why this is happening, why can't i just do "int index = int(v_texID);" ? The float on v_tex_ID is either 0.0f or 1.0f.

Byynx
Автор

If we have cube with 4 vertex texture and 8 vertices and i know uvmap how i can texture this cube?

pphhksq
Автор

Hey I cant find the tut_18assimp. I want to see your texture load function since I load my textures in the constructor so I don't really have a load function.

AlbertRyanstein
Автор

If I make a game and assign some textures to texture unit 25. And the people playing the game dont have 25 units, what happens? Will it not work and so I need to account for this? Or will openGL fix it dynamically

AlbertRyanstein
Автор

I was able to load a 24bit bitmap in OpenGL using only GLUT and C coding. I didn't use any special libraries other than "stdlib.h" & "stdio.h". The code was a very short and simple process. fopen() to fread the file and fclose, then proceed on as normal glEnable(), etc.
BMP texture loaded and created a nice perfect fitting texture even with a size of 400x400, gave nice detailed look.

kspan-xjgs
Автор

how come the texture on two faces of the cube are diagonal?

lawrencekeener
Автор

All talks about statically create texture coordinate, but no one (I couldn't find after many googling) explain how to calculate the texture coordinate for a 3d model.
Don't know if it is difficult or what? why not from begining make it function-based not writing down the texture coordinates (hard-coded) like here?
Look at Hazel game engine. it is the same and many other tutorials .
Still I am struggling to find that text or video tutorials. Thanks anyway for the video

kumu
Автор

Hello, thank you for the tutorial :)
I am using freeglut (I can use other libraries), what is the alternative for glactivetexture() in freeglut? (I can't find it)

darkwings
Автор

I do not really understand how to set texture coordinates for a 3D model. I understand what they mean and i know how to use them in 2D.

hexiram
Автор

Are you russian? you speak with an accent

etejipt