Use RGBA8 frame buffer format when RGB10A2 fails
This commit is contained in:
parent
ef2b588141
commit
ae3d10d3f9
@ -27,6 +27,7 @@ namespace spades {
|
||||
SPLog("Initializing framebuffer manager");
|
||||
|
||||
useMultisample = (int)r_multisamples > 0;
|
||||
useHighPrec = true;
|
||||
|
||||
if(useMultisample){
|
||||
SPLog("Multi-sample Antialiasing Enabled");
|
||||
@ -38,11 +39,22 @@ namespace spades {
|
||||
multisampledColorRenderbuffer = dev->GenRenderbuffer();
|
||||
dev->BindRenderbuffer(IGLDevice::Renderbuffer,
|
||||
multisampledColorRenderbuffer);
|
||||
try{
|
||||
dev->RenderbufferStorage(IGLDevice::Renderbuffer,
|
||||
(int)r_multisamples,
|
||||
IGLDevice::RGB10A2,
|
||||
dev->ScreenWidth(),
|
||||
dev->ScreenHeight());
|
||||
|
||||
}catch(...){
|
||||
SPLog("Renderbuffer creation failed: trying with RGB8");
|
||||
useHighPrec = false;
|
||||
dev->RenderbufferStorage(IGLDevice::Renderbuffer,
|
||||
(int)r_multisamples,
|
||||
IGLDevice::RGBA8,
|
||||
dev->ScreenWidth(),
|
||||
dev->ScreenHeight());
|
||||
}
|
||||
SPLog("MSAA Color Buffer Allocated");
|
||||
|
||||
multisampledDepthRenderbuffer = dev->GenRenderbuffer();
|
||||
@ -82,6 +94,7 @@ namespace spades {
|
||||
renderColorTexture = dev->GenTexture();
|
||||
dev->BindTexture(IGLDevice::Texture2D,
|
||||
renderColorTexture);
|
||||
try{
|
||||
dev->TexImage2D(IGLDevice::Texture2D,
|
||||
0,
|
||||
IGLDevice::RGB10A2,
|
||||
@ -90,6 +103,18 @@ namespace spades {
|
||||
0,
|
||||
IGLDevice::RGBA,
|
||||
IGLDevice::UnsignedByte, NULL);
|
||||
}catch(...){
|
||||
SPLog("Texture creation failed: trying with RGB8");
|
||||
useHighPrec = false;
|
||||
dev->TexImage2D(IGLDevice::Texture2D,
|
||||
0,
|
||||
IGLDevice::RGBA8,
|
||||
dev->ScreenWidth(),
|
||||
dev->ScreenHeight(),
|
||||
0,
|
||||
IGLDevice::RGBA,
|
||||
IGLDevice::UnsignedByte, NULL);
|
||||
}
|
||||
SPLog("Color Buffer Allocated");
|
||||
dev->TexParamater(IGLDevice::Texture2D,
|
||||
IGLDevice::TextureMagFilter,
|
||||
@ -310,7 +335,9 @@ namespace spades {
|
||||
tex);
|
||||
device->TexImage2D(IGLDevice::Texture2D,
|
||||
0,
|
||||
alpha?IGLDevice::RGBA:IGLDevice::RGB10A2,
|
||||
alpha?IGLDevice::RGBA8:
|
||||
(useHighPrec?IGLDevice::RGB10A2:
|
||||
IGLDevice::RGB8),
|
||||
w,
|
||||
h,
|
||||
0,
|
||||
|
@ -49,6 +49,7 @@ namespace spades {
|
||||
};
|
||||
|
||||
bool useMultisample;
|
||||
bool useHighPrec;
|
||||
|
||||
IGLDevice::UInteger multisampledFramebuffer;
|
||||
|
||||
|
@ -142,6 +142,8 @@ namespace spades {
|
||||
R16F,
|
||||
RGB5,
|
||||
RGB5A1,
|
||||
RGB8,
|
||||
RGBA8,
|
||||
|
||||
// Texture wrap
|
||||
ClampToEdge,
|
||||
|
@ -471,6 +471,8 @@ namespace spades {
|
||||
case R16F: return GL_R16F;
|
||||
case RGB5: return GL_RGB5;
|
||||
case RGB5A1: return GL_RGB5_A1;
|
||||
case RGB8: return GL_RGB8;
|
||||
case RGBA8: return GL_RGBA8;
|
||||
default: SPInvalidEnum("v", v);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user