1
#include "glcomptexture.h"
3
glCompTexture* glCompCreateTextureFromRaw(char* filename,int width,int height,int wrap)
12
t=malloc(sizeof(glCompTexture));
13
glGenTextures( 1, &t->id );
16
data = malloc( width * height * 3 );
17
// open and read texture data
18
file = fopen( filename, "rb" );
19
fread( data, width * height * 3, 1, file );
23
// select our current texture
24
glBindTexture( GL_TEXTURE_2D, t->id);
26
// select modulate to mix texture with color for shading
27
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
29
// when texture area is small, bilinear filter the closest mipmap
30
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
31
GL_LINEAR_MIPMAP_NEAREST );
32
// when texture area is large, bilinear filter the first mipmap
33
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
35
// if wrap is true, the texture wraps over at the edges (repeat)
36
// ... false, the texture ends at the edges (clamp)
37
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
38
(GLfloat)wrap ? (GLfloat)GL_REPEAT : GL_CLAMP );
39
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
40
(GLfloat)wrap ? (GLfloat)GL_REPEAT : GL_CLAMP );
42
/* glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,GL_REPEAT );
43
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
44
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
45
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
46
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
49
// build our texture mipmaps
50
glTexImage2D(GL_TEXTURE_2D, 0, 4, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE,data);*/
52
gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, width, height,
53
GL_RGB, GL_UNSIGNED_BYTE, data );
61
int glCompDeleteTexture(glCompTexture* t)