Properly support 16-bit color

This commit is contained in:
Jeffrey Pfau 2014-02-02 02:47:50 -08:00
parent 02aec4fc65
commit ad38ae63ec
3 changed files with 19 additions and 3 deletions

View File

@ -30,6 +30,13 @@ else()
source_group("POSIX-specific code" FILES ${OS_SRC})
endif()
if(BUILD_BBB OR BUILD_RASPI)
enable_language(ASM)
if(NOT BUILD_EGL)
add_definitions(-DCOLOR_16_BIT -DCOLOR_5_6_5)
endif()
endif()
set(DEBUGGER_SRC "${CMAKE_SOURCE_DIR}/src/debugger/debugger.c;${CMAKE_SOURCE_DIR}/src/debugger/memory-debugger.c")
if(USE_CLI_DEBUGGER)

View File

@ -24,8 +24,6 @@ if(BUILD_RASPI AND BUILD_EGL)
set(OPENGL_INCLUDE_DIR "")
add_definitions(-DBUILD_RASPI)
elseif(BUILD_BBB OR BUILD_RASPI)
enable_language(ASM)
add_definitions(-DCOLOR_16_BIT -DCOLOR_5_6_5)
set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/sw-main.c)
else()
set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/gl-main.c)

View File

@ -113,10 +113,21 @@ static int _GBASDLInit(struct GLSoftwareRenderer* renderer) {
#else
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
#endif
#ifndef COLOR_16_BIT
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
#else
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
#ifdef COLOR_5_6_5
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
#else
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
#endif
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
#endif
#if SDL_VERSION_ATLEAST(2, 0, 0)
renderer->window = SDL_CreateWindow("GBAc", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, renderer->viewportWidth, renderer->viewportHeight, SDL_WINDOW_OPENGL);
SDL_GL_CreateContext(renderer->window);