-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGLTexture.h
67 lines (61 loc) · 2.45 KB
/
GLTexture.h
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
//////////////////////////////////////////////////////////////////////
//
// OpenGL Texture Class
// by: Matthew Fairfax
//
// GLTexture.h: interface for the GLTexture class.
// This class loads a texture file and prepares it
// to be used in OpenGL. It can open a bitmap or a
// targa file. The min filter is set to mipmap b/c
// they look better and the performance cost on
// modern video cards in negligible. I leave all of
// the texture management to the application. I have
// included the ability to load the texture from a
// Visual Studio resource. The bitmap's id must be
// be surrounded by quotation marks (i.e. "Texture.bmp").
// The targa files must be in a resource type of "TGA"
// (including the quotes). The targa's id must be
// surrounded by quotation marks (i.e. "Texture.tga").
//
// Usage:
// GLTexture tex;
// GLTexture tex1;
// GLTexture tex3;
//
// tex.Load("texture.bmp"); // Loads a bitmap
// tex.Use(); // Binds the bitmap for use
//
// tex1.LoadFromResource("texture.tga"); // Loads a targa
// tex1.Use(); // Binds the targa for use
//
// // You can also build a texture with a single color and use it
// tex3.BuildColorTexture(255, 0, 0); // Builds a solid red texture
// tex3.Use(); // Binds the targa for use
//
//////////////////////////////////////////////////////////////////////
#ifndef GLTEXTURE_H
#define GLTEXTURE_H
#include <windows.h> // Header File For Windows
#include <gl\gl.h> // Header File For The OpenGL32 Library
#include <gl\glu.h> // Header File For The GLu32 Library
#include "GLAUX.H" // Header File For The Glaux Library
#pragma comment(lib, "glaux")
class GLTexture
{
public:
char *texturename; // The textures name
unsigned int texture[1]; // OpenGL's number for the texture
int width; // Texture's width
int height; // Texture's height
void Use(); // Binds the texture for use
void BuildColorTexture(unsigned char r, unsigned char g, unsigned char b); // Sometimes we want a texture of uniform color
void LoadTGAResource(char *name); // Load a targa from the resources
void LoadBMPResource(char *name); // Load a bitmap from the resources
void LoadFromResource(char *name); // Load the texture from a resource
void LoadTGA(char *name); // Loads a targa file
void LoadBMP(char *name); // Loads a bitmap file
void Load(char *name); // Load the texture
GLTexture(); // Constructor
virtual ~GLTexture(); // Destructor
};
#endif GLTEXTURE_H