mirror of
https://github.com/isledecomp/isle-portable.git
synced 2025-09-24 04:26:55 -04:00
Use extensions to probe for 24 or 32bit depth buffer (#329)
This commit is contained in:
parent
3cfa3f5bec
commit
e9c5e5b9ba
@ -2,6 +2,7 @@
|
|||||||
#include "meshutils.h"
|
#include "meshutils.h"
|
||||||
|
|
||||||
#include <GLES2/gl2.h>
|
#include <GLES2/gl2.h>
|
||||||
|
#include <GLES2/gl2ext.h>
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -76,7 +77,18 @@ Direct3DRMRenderer* OpenGLES2Renderer::Create(DWORD width, DWORD height)
|
|||||||
GLuint depthRb;
|
GLuint depthRb;
|
||||||
glGenRenderbuffers(1, &depthRb);
|
glGenRenderbuffers(1, &depthRb);
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, depthRb);
|
glBindRenderbuffer(GL_RENDERBUFFER, depthRb);
|
||||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
|
const char* extensions = (const char*) glGetString(GL_EXTENSIONS);
|
||||||
|
if (extensions) {
|
||||||
|
if (strstr(extensions, "GL_OES_depth24")) {
|
||||||
|
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24_OES, width, height);
|
||||||
|
}
|
||||||
|
else if (strstr(extensions, "GL_OES_depth32")) {
|
||||||
|
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32_OES, width, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
|
||||||
|
}
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRb);
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRb);
|
||||||
|
|
||||||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
||||||
@ -454,6 +466,15 @@ void OpenGLES2Renderer::GetDesc(D3DDEVICEDESC* halDesc, D3DDEVICEDESC* helDesc)
|
|||||||
halDesc->dcmColorModel = D3DCOLORMODEL::RGB;
|
halDesc->dcmColorModel = D3DCOLORMODEL::RGB;
|
||||||
halDesc->dwFlags = D3DDD_DEVICEZBUFFERBITDEPTH;
|
halDesc->dwFlags = D3DDD_DEVICEZBUFFERBITDEPTH;
|
||||||
halDesc->dwDeviceZBufferBitDepth = DDBD_16;
|
halDesc->dwDeviceZBufferBitDepth = DDBD_16;
|
||||||
|
const char* extensions = (const char*) glGetString(GL_EXTENSIONS);
|
||||||
|
if (extensions) {
|
||||||
|
if (strstr(extensions, "GL_OES_depth24")) {
|
||||||
|
halDesc->dwDeviceZBufferBitDepth |= DDBD_24;
|
||||||
|
}
|
||||||
|
if (strstr(extensions, "GL_OES_depth32")) {
|
||||||
|
halDesc->dwDeviceZBufferBitDepth |= DDBD_32;
|
||||||
|
}
|
||||||
|
}
|
||||||
helDesc->dwDeviceRenderBitDepth = DDBD_32;
|
helDesc->dwDeviceRenderBitDepth = DDBD_32;
|
||||||
halDesc->dpcTriCaps.dwTextureCaps = D3DPTEXTURECAPS_PERSPECTIVE;
|
halDesc->dpcTriCaps.dwTextureCaps = D3DPTEXTURECAPS_PERSPECTIVE;
|
||||||
halDesc->dpcTriCaps.dwShadeCaps = D3DPSHADECAPS_ALPHAFLATBLEND;
|
halDesc->dpcTriCaps.dwShadeCaps = D3DPSHADECAPS_ALPHAFLATBLEND;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user