mirror of
https://github.com/aap/librw.git
synced 2024-11-25 05:05:42 +00:00
runtime caps for opengl
This commit is contained in:
parent
7e80d45cdb
commit
cea326a4ce
@ -19,4 +19,6 @@ ECODE(ERR_ENGINESTART,
|
||||
ECODE(ERR_INVRASTER,
|
||||
"Invalid raster format"),
|
||||
ECODE(ERR_NOTEXTURE,
|
||||
"Could not create texture")
|
||||
"Could not create texture"),
|
||||
ECODE(ERR_FORMAT_UNSUPPORTED,
|
||||
"Unsupported raster format")
|
||||
|
@ -59,6 +59,8 @@ struct GlGlobals
|
||||
const char *winTitle;
|
||||
} glGlobals;
|
||||
|
||||
Gl3Caps gl3Caps;
|
||||
|
||||
int32 alphaFunc;
|
||||
float32 alphaRef;
|
||||
|
||||
@ -1498,6 +1500,18 @@ stopGLFW(void)
|
||||
static int
|
||||
initOpenGL(void)
|
||||
{
|
||||
memset(&gl3Caps, 0, sizeof(gl3Caps));
|
||||
int numExt;
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &numExt);
|
||||
for(int i = 0; i < numExt; i++){
|
||||
const char *ext = (const char*)glGetStringi(GL_EXTENSIONS, i);
|
||||
if(strcmp(ext, "GL_EXT_texture_compression_s3tc") == 0)
|
||||
gl3Caps.dxtSupported = true;
|
||||
else if(strcmp(ext, "GL_KHR_texture_compression_astc_ldr") == 0)
|
||||
gl3Caps.astcSupported = true;
|
||||
// printf("%d %s\n", i, ext);
|
||||
}
|
||||
|
||||
#ifndef RW_GL_USE_UBOS
|
||||
u_alphaRef = registerUniform("u_alphaRef");
|
||||
u_fogData = registerUniform("u_fogData");
|
||||
|
@ -769,6 +769,11 @@ readNativeTexture(Stream *stream)
|
||||
Raster *raster;
|
||||
Gl3Raster *natras;
|
||||
if(flags & 2){
|
||||
if(!gl3Caps.dxtSupported){
|
||||
tex->destroy();
|
||||
RWERROR((ERR_FORMAT_UNSUPPORTED));
|
||||
return nil;
|
||||
}
|
||||
raster = Raster::create(width, height, depth, format | Raster::TEXTURE | Raster::DONTALLOCATE, PLATFORM_GL3);
|
||||
allocateDXT(raster, compression, numLevels, flags & 1);
|
||||
}else{
|
||||
|
@ -246,6 +246,14 @@ struct Gl3Raster
|
||||
Raster *fboMate; // color or zbuffer raster mate of this one
|
||||
};
|
||||
|
||||
struct Gl3Caps
|
||||
{
|
||||
// TODO: put more stuff into this
|
||||
bool dxtSupported;
|
||||
bool astcSupported; // not used yet
|
||||
};
|
||||
extern Gl3Caps gl3Caps;
|
||||
|
||||
void allocateDXT(Raster *raster, int32 dxt, int32 numLevels, bool32 hasAlpha);
|
||||
|
||||
Texture *readNativeTexture(Stream *stream);
|
||||
|
@ -419,6 +419,9 @@ d3d_to_gl3(rw::Raster *ras)
|
||||
#ifdef RW_GL3
|
||||
using namespace rw;
|
||||
|
||||
if(!gl3::gl3Caps.dxtSupported)
|
||||
return nil;
|
||||
|
||||
int dxt = 0;
|
||||
d3d::D3dRaster *d3dras = GETD3DRASTEREXT(ras);
|
||||
if(d3dras->customFormat){
|
||||
|
Loading…
Reference in New Issue
Block a user