1 /************************************************************************* 2 3 "I Have No Tomatoes" 4 Copyright (c) 2004, Mika Halttunen 5 6 This software is provided 'as-is', without any express or implied 7 warranty. In no event will the authors be held liable for any damages 8 arising from the use of this software. 9 10 Permission is granted to anyone to use this software for any purpose, 11 including commercial applications, and to alter it and redistribute 12 it freely, subject to the following restrictions: 13 14 1. The origin of this software must not be misrepresented; you must 15 not claim that you wrote the original software. If you use this 16 software in a product, an acknowledgment in the product documentation 17 would be appreciated but is not required. 18 19 2. Altered source versions must be plainly marked as such, and must 20 not be misrepresented as being the original software. 21 22 3. This notice may not be removed or altered from any source 23 distribution. 24 25 26 Mika Halttunen <lsoft@mbnet.fi> 27 28 *************************************************************************/ 29 30 #ifndef TEXTURE_H 31 #define TEXTURE_H 32 33 // Macro for texture binding (yes, I'm *that* lazy!) 34 #define BIND_TEXTURE(x) glBindTexture(GL_TEXTURE_2D, x) 35 36 37 // Load a PNG 38 GLuint load_png(char *file, bool alpha = false, bool repeat = false, bool mipmaps = true); 39 40 // Load a JPG 41 GLuint load_jpg(char *file, bool alpha = false, bool repeat = false, bool mipmaps = true); 42 43 44 // Load a image file using SDL_Image and 45 // convert it to OpenGL texture. 46 // If alpha == true -> RGBA alpha texture 47 // If repeat == true -> texture can be tiled 48 // If mipmaps == true -> Mipmaps will be generated 49 // Return texture ID 50 GLuint load_texture(char *file, char *type, bool alpha = false, bool repeat = false, bool mipmaps = true); 51 52 // Same as load_texture(), but loads into the specified texture index 53 void load_texture_into(GLuint tex, char *file, char *img_type, bool alpha, bool repeat, bool mipmaps); 54 55 // Grab texture contents from the frame buffer. 56 // Assuming that 'tex' is a valid texture ID 57 // sized w*h 58 void grab_texture(GLuint tex, int w, int h, int mode); 59 60 // Create an empty OpenGL texture 61 GLuint create_empty_texture(int w, int h, int mode); 62 63 #endif 64 65 66