38 lines
736 B
C
38 lines
736 B
C
#include "main.h"
|
|
#include <GL/glew.h>
|
|
|
|
#define TYPE GL_TEXTURE_2D_ARRAY
|
|
|
|
id_t config_texture( unsigned short type )
|
|
{
|
|
id_t texture;
|
|
|
|
glGenTextures( 1, &texture );
|
|
glBindTexture( TYPE, texture );
|
|
|
|
{
|
|
glTexParameteri( TYPE, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
|
glTexParameteri( TYPE, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
|
}
|
|
|
|
return texture;
|
|
}
|
|
|
|
void use_texture( id_t texture )
|
|
{
|
|
return glBindTexture( TYPE, texture );
|
|
}
|
|
|
|
void destroy_texture( unsigned int texture )
|
|
{
|
|
return glDeleteTextures( 1, &texture );
|
|
}
|
|
|
|
id_t create_palette_texture( const unsigned char * colors )
|
|
{
|
|
id_t texture = config_texture( TYPE );
|
|
glTexImage3D( TYPE, 0, GL_RGBA,
|
|
1, 1, (*colors)/4, 0, GL_RGBA, GL_UNSIGNED_BYTE, colors+1);
|
|
return texture;
|
|
}
|