Changeset c8c6da8 in opengl-game


Ignore:
Timestamp:
Aug 21, 2019, 8:19:09 PM (5 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
e5d4aca
Parents:
ad31ec7
Message:

Create the overlay texture using different flags based on the SDL version (2.0.9 vs 2.0.10) and change compile.sh to compile all .vert and .frag files inside the shaders folder

Files:
2 added
4 edited
2 moved

Legend:

Unmodified
Added
Removed
  • README.txt

    rad31ec7 rc8c6da8  
    8787Download the vulkan sdk (make sure VULKAN_SDK_PATH in the makefile points to it)
    8888
    89 brew install sdl2
    90 brew install sdl2_image
    91 brew install sdl2_ttf
     89brew install sdl2 sdl2_image sdl2_ttf
    9290
    9391make vulkangame && ./vulkangame
  • compile.sh

    rad31ec7 rc8c6da8  
    1212echo $VULKAN_SDK_PATH
    1313
    14 $VULKAN_SDK_PATH/bin/glslangValidator -V shader.vert
    15 $VULKAN_SDK_PATH/bin/glslangValidator -V shader.frag
     14shopt -s nullglob
     15shopt -s extglob
     16
     17FILES=./!(*.spv)
     18
     19for f in $FILES
     20do
     21   shaderName=$(echo $f | sed 's/\.\/\(.*\)\..*/\1/')
     22   shaderType=$(echo $f | sed 's/\.\/.*\.\(.*\)/\1/')
     23   fOut="$shaderName-$shaderType.spv"
     24
     25   $VULKAN_SDK_PATH/bin/glslangValidator -V $f -o $fOut
     26done
  • makefile

    rad31ec7 rc8c6da8  
    5656
    5757.PHONY: shaders
    58 shaders: shaders/shader.vert shaders/shader.frag
     58shaders:
    5959        cd shaders && ../compile.sh && cd ..
    6060
  • vulkan-game.cpp

    rad31ec7 rc8c6da8  
    164164   private:
    165165      GameGui* gui = new GameGui_SDL();
     166      SDL_version sdlVersion;
    166167      SDL_Window* window = nullptr;
    167168
     
    260261         }
    261262
    262          uiOverlay = SDL_CreateTexture(gRenderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, SCREEN_WIDTH, SCREEN_HEIGHT);
     263         SDL_VERSION(&sdlVersion);
     264
     265         // In SDL 2.0.10 (currently, the latest), SDL_TEXTUREACCESS_TARGET is required to get a transparent overlay working
     266         // However, the latest SDL version available through homebrew on Mac is 2.0.9, which requires SDL_TEXTUREACCESS_STREAMING
     267         // I tried building sdl 2.0.10 (and sdl_image and sdl_ttf) from source on Mac, but had some issues, so this is easier
     268         // until the homebrew recipe is updated
     269         if (sdlVersion.major == 2 && sdlVersion.minor == 0 && sdlVersion.patch == 9) {
     270            uiOverlay = SDL_CreateTexture(gRenderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, SCREEN_WIDTH, SCREEN_HEIGHT);
     271         } else {
     272            uiOverlay = SDL_CreateTexture(gRenderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, SCREEN_WIDTH, SCREEN_HEIGHT);
     273         }
     274
    263275         if (uiOverlay == nullptr) {
    264276            cout << "Unable to create blank texture! SDL Error: " << SDL_GetError() << endl;
     
    18331845         createRenderPass();
    18341846
    1835          createGraphicsPipeline("shaders/vert.spv", "shaders/frag.spv", scenePipeline);
    1836          createGraphicsPipeline("shaders/vert.spv", "shaders/frag.spv", overlayPipeline);
     1847         createGraphicsPipeline("shaders/scene-vert.spv", "shaders/scene-frag.spv", scenePipeline);
     1848         createGraphicsPipeline("shaders/overlay-vert.spv", "shaders/overlay-frag.spv", overlayPipeline);
    18371849
    18381850         createDepthResources();
Note: See TracChangeset for help on using the changeset viewer.