17. OpenGL Texture Coordinate Generation
Examples of places you would use texture generation are: environment mapping and reflection mapping.
The very first thing that you need to do, is of course, enable the use of which texture
generation method you would like. There are four different types of textures you can generate, and they are:
GL_TEXTURE_GEN_S
GL_TEXTURE_GEN_R
GL_TEXTURE_GEN_T
GL_TEXTURE_GEN_Q
Also keep in mind that you can use
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
with paramaters such as:
GL_EYE_LINEAR
GL_OBJECT_LINEAR
GL_SPHERE_MAP
GL_REFLECTION_MAP
Each one of these is used for a different method. But I will not mention them at this point in time, I may in the future if I want to explain more in this tutorial. But every method that is used here, can be done in a GLSL shader program.
Anyway, thats it for using texture coordinate generation, if you have any questions please email me at swiftless@gmail.com
Texture coordinate generation is used when you are looking for particular effects in which it would take too long to work out the required texture coordinates all the time.
Examples of places you would use texture generation are: environment mapping and reflection mapping.
The very first thing that you need to do, is of course, enable the use of which texture
generation method you would like. There are four different types of textures you can generate, and they are:
GL_TEXTURE_GEN_S
GL_TEXTURE_GEN_R
GL_TEXTURE_GEN_T
GL_TEXTURE_GEN_Q
Also keep in mind that you can use
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
with paramaters such as:
GL_EYE_LINEAR
GL_OBJECT_LINEAR
GL_SPHERE_MAP
GL_REFLECTION_MAP
Each one of these is used for a different method. But I will not mention them at this point in time, I may in the future if I want to explain more in this tutorial. But every method that is used here, can be done in a GLSL shader program.
Anyway, thats it for using texture coordinate generation, if you have any questions please email me at swiftless@gmail.com
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99. 100. 101. 102. 103. 104. 105. 106. 107. 108. 109. 110. 111. 112. 113. 114. 115. |
#include <GL/gl.h> #include <GL/glut.h> #include <windows.h> #include <stdio.h> GLuint texture; //the array for our texture GLfloat angle = 0.0; GLuint LoadTexture( const char * filename, int width, int //The following code will read in our RAW file glGenTextures( 1, &texture ); //generate the texture //here we are setting what textures to use and when. The //The qualities are (in order from worst to best) //And if you go and use extensions, you can use Anisotropic //Here we are setting the parameter to repeat the texture //Generate the texture with mipmaps void FreeTexture( GLuint texture ) void cube (void) { void display (void) { void reshape (int w, int h) { int main (int argc, char **argv) { |