| |||||||||||
|
Main Menu Other |
Tutorials -- Texture Mapping | ||||||||||
|
How To Load a Bitmap to a TextureNow open "main.cpp" and make sure you have these lines at the top: #include "main.h" #include "texture.h" Then add this line to your Init() function (I added the tab for you =]). SetTextureFilter(TF_BILINEAR); The TF_BILINEAR constant is defined in texture.h. You can also set this to TF_NONE for no filtering, or TF_TRILINEAR for trilinear filtering. If you're new to constants, check out my Quick Intro to Constants tutorial. Then come back here and continue this tutorial. First, near the top of your main.cpp or somewhere in main.h you can define constants to reference each texture. Use these as an example. int TEX_TILE; Note that we are not using const ints, just ints, and that we aren't giving them values. This is so that when we load the texture, it will return the identifier of that texture. Now you can add lines like these to your Init() function.
TEX_TILE = LoadTexture("tile1.bmp", false, false);
To find out what the two bool values that need passed to LoadTexture(), open up texture.cpp and check the description of the LoadTexture() function. To make these textures active, just call this function when you want to use it. glBindTexture(GL_TEXTURE_2D, TEX_TILE); That's one heck of a simple way of working with textures, if I do say so myself. Lets move on and draw a set of textured polygons!
|
|||||||||||