mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 19:45:23 -04:00
remove depth/stencil fields from graphicsmode
This commit is contained in:
parent
58c19a38b7
commit
479ce38b8d
42
src/Window.c
42
src/Window.c
@ -56,15 +56,9 @@ static void Window_DefaultDisableRawMouse(void) {
|
|||||||
Cursor_SetVisible(true);
|
Cursor_SetVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphicsMode_MakeDefault(struct GraphicsMode* m) {
|
||||||
/*########################################################################################################################*
|
int bpp = Display_BitsPerPixel;
|
||||||
*------------------------------------------------------GraphicsMode-------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
void GraphicsMode_Make(struct GraphicsMode* m, int bpp, int depth, int stencil) {
|
|
||||||
m->DepthBits = depth;
|
|
||||||
m->StencilBits = stencil;
|
|
||||||
m->IsIndexed = bpp < 15;
|
m->IsIndexed = bpp < 15;
|
||||||
m->BitsPerPixel = bpp;
|
|
||||||
|
|
||||||
m->A = 0;
|
m->A = 0;
|
||||||
switch (bpp) {
|
switch (bpp) {
|
||||||
@ -85,9 +79,6 @@ void GraphicsMode_Make(struct GraphicsMode* m, int bpp, int depth, int stencil)
|
|||||||
Logger_Abort2(bpp, "Unsupported bits per pixel"); break;
|
Logger_Abort2(bpp, "Unsupported bits per pixel"); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void GraphicsMode_MakeDefault(struct GraphicsMode* m) {
|
|
||||||
GraphicsMode_Make(m, Display_BitsPerPixel, 24, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
@ -2758,6 +2749,7 @@ static void GLContext_SelectGraphicsMode(struct GraphicsMode* mode) {
|
|||||||
pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER;
|
pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER;
|
||||||
/* TODO: PFD_SUPPORT_COMPOSITION FLAG? CHECK IF IT WORKS ON XP */
|
/* TODO: PFD_SUPPORT_COMPOSITION FLAG? CHECK IF IT WORKS ON XP */
|
||||||
pfd.cColorBits = mode->R + mode->G + mode->B;
|
pfd.cColorBits = mode->R + mode->G + mode->B;
|
||||||
|
pfd.cDepthBits = GLCONTEXT_DEFAULT_DEPTH;
|
||||||
|
|
||||||
pfd.iPixelType = mode->IsIndexed ? PFD_TYPE_COLORINDEX : PFD_TYPE_RGBA;
|
pfd.iPixelType = mode->IsIndexed ? PFD_TYPE_COLORINDEX : PFD_TYPE_RGBA;
|
||||||
pfd.cRedBits = mode->R;
|
pfd.cRedBits = mode->R;
|
||||||
@ -2765,9 +2757,6 @@ static void GLContext_SelectGraphicsMode(struct GraphicsMode* mode) {
|
|||||||
pfd.cBlueBits = mode->B;
|
pfd.cBlueBits = mode->B;
|
||||||
pfd.cAlphaBits = mode->A;
|
pfd.cAlphaBits = mode->A;
|
||||||
|
|
||||||
pfd.cDepthBits = mode->DepthBits;
|
|
||||||
pfd.cStencilBits = mode->StencilBits;
|
|
||||||
|
|
||||||
int modeIndex = ChoosePixelFormat(win_DC, &pfd);
|
int modeIndex = ChoosePixelFormat(win_DC, &pfd);
|
||||||
if (modeIndex == 0) { Logger_Abort("Requested graphics mode not available"); }
|
if (modeIndex == 0) { Logger_Abort("Requested graphics mode not available"); }
|
||||||
|
|
||||||
@ -2913,13 +2902,7 @@ static void GLContext_GetAttribs(struct GraphicsMode* mode, int* attribs) {
|
|||||||
attribs[i++] = GLX_GREEN_SIZE; attribs[i++] = mode->G;
|
attribs[i++] = GLX_GREEN_SIZE; attribs[i++] = mode->G;
|
||||||
attribs[i++] = GLX_BLUE_SIZE; attribs[i++] = mode->B;
|
attribs[i++] = GLX_BLUE_SIZE; attribs[i++] = mode->B;
|
||||||
attribs[i++] = GLX_ALPHA_SIZE; attribs[i++] = mode->A;
|
attribs[i++] = GLX_ALPHA_SIZE; attribs[i++] = mode->A;
|
||||||
|
attribs[i++] = GLX_DEPTH_SIZE; attribs[i++] = GLCONTEXT_DEFAULT_DEPTH;
|
||||||
if (mode->DepthBits) {
|
|
||||||
attribs[i++] = GLX_DEPTH_SIZE; attribs[i++] = mode->DepthBits;
|
|
||||||
}
|
|
||||||
if (mode->StencilBits) {
|
|
||||||
attribs[i++] = GLX_STENCIL_SIZE; attribs[i++] = mode->StencilBits;
|
|
||||||
}
|
|
||||||
|
|
||||||
attribs[i++] = GLX_DOUBLEBUFFER;
|
attribs[i++] = GLX_DOUBLEBUFFER;
|
||||||
attribs[i++] = 0;
|
attribs[i++] = 0;
|
||||||
@ -3001,13 +2984,7 @@ static void GLContext_GetAttribs(struct GraphicsMode* mode, int* attribs, bool f
|
|||||||
attribs[i++] = AGL_GREEN_SIZE; attribs[i++] = mode->G;
|
attribs[i++] = AGL_GREEN_SIZE; attribs[i++] = mode->G;
|
||||||
attribs[i++] = AGL_BLUE_SIZE; attribs[i++] = mode->B;
|
attribs[i++] = AGL_BLUE_SIZE; attribs[i++] = mode->B;
|
||||||
attribs[i++] = AGL_ALPHA_SIZE; attribs[i++] = mode->A;
|
attribs[i++] = AGL_ALPHA_SIZE; attribs[i++] = mode->A;
|
||||||
|
attribs[i++] = AGL_DEPTH_SIZE; attribs[i++] = GLCONTEXT_DEFAULT_DEPTH;
|
||||||
if (mode->DepthBits) {
|
|
||||||
attribs[i++] = AGL_DEPTH_SIZE; attribs[i++] = mode->DepthBits;
|
|
||||||
}
|
|
||||||
if (mode->StencilBits) {
|
|
||||||
attribs[i++] = AGL_STENCIL_SIZE; attribs[i++] = mode->StencilBits;
|
|
||||||
}
|
|
||||||
|
|
||||||
attribs[i++] = AGL_DOUBLEBUFFER;
|
attribs[i++] = AGL_DOUBLEBUFFER;
|
||||||
if (fullscreen) { attribs[i++] = AGL_FULLSCREEN; }
|
if (fullscreen) { attribs[i++] = AGL_FULLSCREEN; }
|
||||||
@ -3144,8 +3121,8 @@ void GLContext_Init(struct GraphicsMode* mode) {
|
|||||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, mode->B);
|
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, mode->B);
|
||||||
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, mode->A);
|
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, mode->A);
|
||||||
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, mode->DepthBits);
|
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, GLCONTEXT_DEFAULT_DEPTH);
|
||||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, mode->StencilBits);
|
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0);
|
||||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, true);
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, true);
|
||||||
|
|
||||||
win_ctx = SDL_GL_CreateContext(win_handle);
|
win_ctx = SDL_GL_CreateContext(win_handle);
|
||||||
@ -3195,7 +3172,8 @@ void GLContext_Init(struct GraphicsMode* mode) {
|
|||||||
static EGLint attribs[19] = {
|
static EGLint attribs[19] = {
|
||||||
EGL_RED_SIZE, 0, EGL_GREEN_SIZE, 0,
|
EGL_RED_SIZE, 0, EGL_GREEN_SIZE, 0,
|
||||||
EGL_BLUE_SIZE, 0, EGL_ALPHA_SIZE, 0,
|
EGL_BLUE_SIZE, 0, EGL_ALPHA_SIZE, 0,
|
||||||
EGL_DEPTH_SIZE,0, EGL_STENCIL_SIZE,0,
|
EGL_DEPTH_SIZE, GLCONTEXT_DEFAULT_DEPTH,
|
||||||
|
EGL_STENCIL_SIZE, 0,
|
||||||
EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER,
|
EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER,
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||||
@ -3204,8 +3182,6 @@ void GLContext_Init(struct GraphicsMode* mode) {
|
|||||||
|
|
||||||
attribs[1] = mode->R; attribs[3] = mode->G;
|
attribs[1] = mode->R; attribs[3] = mode->G;
|
||||||
attribs[5] = mode->B; attribs[7] = mode->A;
|
attribs[5] = mode->B; attribs[7] = mode->A;
|
||||||
attribs[9] = mode->DepthBits;
|
|
||||||
attribs[11] = mode->StencilBits;
|
|
||||||
|
|
||||||
ctx_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
ctx_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||||
eglInitialize(ctx_display, NULL, NULL);
|
eglInitialize(ctx_display, NULL, NULL);
|
||||||
|
@ -36,10 +36,7 @@ enum WindowState { WINDOW_STATE_NORMAL, WINDOW_STATE_MINIMISED, WINDOW_STATE_MAX
|
|||||||
extern int Display_BitsPerPixel;
|
extern int Display_BitsPerPixel;
|
||||||
extern Rect2D Display_Bounds;
|
extern Rect2D Display_Bounds;
|
||||||
|
|
||||||
struct GraphicsMode {
|
struct GraphicsMode { int R, G, B, A, IsIndexed; };
|
||||||
int R, G, B, A, BitsPerPixel, IsIndexed; /* Colour buffer data */
|
|
||||||
int DepthBits, StencilBits; /* Z buffer data */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Client bounds of the window in screen coordinates. */
|
/* Client bounds of the window in screen coordinates. */
|
||||||
/* Essentially, this is the area that can draw to (i.e. content area) */
|
/* Essentially, this is the area that can draw to (i.e. content area) */
|
||||||
@ -52,8 +49,6 @@ extern bool Window_Focused;
|
|||||||
|
|
||||||
/* Initalises state for window. Also sets Display_ members. */
|
/* Initalises state for window. Also sets Display_ members. */
|
||||||
void Window_Init(void);
|
void Window_Init(void);
|
||||||
/* Creates a new GraphicsMode from the given data. */
|
|
||||||
void GraphicsMode_Make(struct GraphicsMode* m, int bpp, int depth, int stencil);
|
|
||||||
/* Creates a GraphicsMode compatible with the default display device. */
|
/* Creates a GraphicsMode compatible with the default display device. */
|
||||||
void GraphicsMode_MakeDefault(struct GraphicsMode* m);
|
void GraphicsMode_MakeDefault(struct GraphicsMode* m);
|
||||||
|
|
||||||
@ -132,6 +127,7 @@ void GLContext_Update(void);
|
|||||||
/* NOTE: This also unattaches the OpenGL context from the window. */
|
/* NOTE: This also unattaches the OpenGL context from the window. */
|
||||||
void GLContext_Free(void);
|
void GLContext_Free(void);
|
||||||
|
|
||||||
|
#define GLCONTEXT_DEFAULT_DEPTH 24
|
||||||
#define GLContext_IsInvalidAddress(ptr) (ptr == (void*)0 || ptr == (void*)1 || ptr == (void*)-1 || ptr == (void*)2)
|
#define GLContext_IsInvalidAddress(ptr) (ptr == (void*)0 || ptr == (void*)1 || ptr == (void*)-1 || ptr == (void*)2)
|
||||||
/* Returns the address of a function pointer for the given OpenGL function. */
|
/* Returns the address of a function pointer for the given OpenGL function. */
|
||||||
/* NOTE: The platform may still return an address for unsupported functions.
|
/* NOTE: The platform may still return an address for unsupported functions.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user