2019-09-16 17:35:04 +00:00
# pragma once
# include <stdlib.h>
# include <algorithm>
2019-09-16 20:56:48 +00:00
# include <vector>
2019-09-17 17:03:42 +00:00
# include <map>
2019-09-16 21:28:26 +00:00
# include "gl_samplers.h"
2019-09-17 17:03:42 +00:00
# include "gl_hwtexture.h"
2019-09-16 20:56:48 +00:00
class FSamplerManager ;
2019-09-16 17:35:04 +00:00
struct BaseVertex
{
float x , y , z ;
float u , v ;
void SetVertex ( float _x , float _y , float _z = 0 )
{
x = _x ;
y = _y ;
z = _z ;
}
void SetTexCoord ( float _u = 0 , float _v = 0 )
{
u = _u ;
v = _v ;
}
2019-09-16 19:08:42 +00:00
void Set ( float _x , float _y , float _z = 0 , float _u = 0 , float _v = 0 )
{
x = _x ;
y = _y ;
z = _z ;
u = _u ;
v = _v ;
}
2019-09-16 17:35:04 +00:00
} ;
enum EDrawType
{
DT_TRIANGLES ,
DT_TRIANGLE_STRIP ,
DT_TRIANGLE_FAN ,
DT_QUADS ,
DT_LINES
} ;
class GLInstance
{
2019-09-17 17:03:42 +00:00
enum
{
MAX_TEXTURES = 15 , // slot 15 is used internally and not available.
THCACHESIZE = 200 ,
} ;
2019-09-16 20:56:48 +00:00
std : : vector < BaseVertex > Buffer ; // cheap-ass implementation. The primary purpose is to get the GL accesses out of polymost.cpp, not writing something performant right away.
2019-09-17 17:03:42 +00:00
unsigned int LastBoundTextures [ MAX_TEXTURES ] ;
unsigned TextureHandleCache [ THCACHESIZE ] ;
int currentindex = THCACHESIZE ;
2019-09-16 17:35:04 +00:00
public :
2019-09-16 20:56:48 +00:00
FSamplerManager * mSamplers ;
void Init ( ) ;
void Deinit ( ) ;
2019-09-17 17:03:42 +00:00
static int GetTexDimension ( int value )
{
//if (value > gl.max_texturesize) return gl.max_texturesize;
return value ;
}
2019-09-16 17:35:04 +00:00
std : : pair < size_t , BaseVertex * > AllocVertices ( size_t num ) ;
void Draw ( EDrawType type , size_t start , size_t count ) ;
2019-09-17 17:03:42 +00:00
int GetTextureID ( ) ;
2019-09-18 18:44:21 +00:00
FHardwareTexture * NewTexture ( ) ;
void BindTexture ( int texunit , FHardwareTexture * texid , int sampler = NoSampler ) ;
2019-09-17 17:03:42 +00:00
void UnbindTexture ( int texunit ) ;
void UnbindAllTextures ( ) ;
2019-09-16 20:56:48 +00:00
2019-09-16 17:35:04 +00:00
} ;
extern GLInstance GLInterface ;