-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgl_texture.h
More file actions
49 lines (41 loc) · 1.24 KB
/
gl_texture.h
File metadata and controls
49 lines (41 loc) · 1.24 KB
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
#ifndef GL_TEXTURE_H
#define GL_TEXTURE_H
//#include "process_image.h"
//#include <GL/glut.h>
typedef struct Rect {
float Left, Right, Bottom, Top;
} Rect;
void Load_Texture(Image* img, const char* path) {
Load_Png(&img->img, &img->w, &img->h, path);
}
void Load_Texture_Swap(Image* img, const char* path) {
Load_Png_Swap(&img->img, &img->w, &img->h, path);
}
void Map_Texture(Image* img) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img->w, img->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, img->img);
}
void Draw_Rect(Rect *Rct) {
glBegin(GL_POLYGON);
glTexCoord2f(0.0f, 0.0f);
glVertex2f((int)Rct->Left, (int)Rct->Bottom);
glTexCoord2f(1.0f, 0.0f);
glVertex2f((int)Rct->Right, (int)Rct->Bottom);
glTexCoord2f(1.0f, 1.0f);
glVertex2f((int)Rct->Right, (int)Rct->Top);
glTexCoord2f(0.0f, 1.0f);
glVertex2f((int)Rct->Left, (int)Rct->Top);
glEnd();
}
//void Draw_Rect(Rect *Rct) {
// glBegin(GL_POLYGON);
// glTexCoord2f(0.0f, 0.0f);
// glVertex2f(Rct->Left, Rct->Bottom);
// glTexCoord2f(1.0f, 0.0f);
// glVertex2f(Rct->Right, Rct->Bottom);
// glTexCoord2f(1.0f, 1.0f);
// glVertex2f(Rct->Right, Rct->Top);
// glTexCoord2f(0.0f, 1.0f);
// glVertex2f(Rct->Left, Rct->Top);
// glEnd();
//}
#endif