Changeset 7fc5e27 in opengl-game


Ignore:
Timestamp:
Sep 3, 2019, 7:07:39 PM (5 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
b6e60b4
Parents:
1ce9afe
Message:

Change all game-gui function names to lower camel case

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • game-gui-glfw.cpp

    r1ce9afe r7fc5e27  
    1111bool GameGui_GLFW::s_keyDown[NUM_KEYS];
    1212
    13 string& GameGui_GLFW::GetError() {
     13string& GameGui_GLFW::getError() {
    1414   return GameGui_GLFW::s_errorMessage;
    1515}
    1616
    17 bool GameGui_GLFW::Init() {
     17bool GameGui_GLFW::init() {
    1818   GameGui_GLFW::s_errorMessage = "No error";
    1919   glfwSetErrorCallback(glfw_error_callback);
     20
     21   windowWidth = -1;
     22   windowHeight = -1;
    2023
    2124   return glfwInit() == GLFW_TRUE ? RTWO_SUCCESS : RTWO_ERROR;
    2225}
    2326
    24 void GameGui_GLFW::Shutdown() {
     27void GameGui_GLFW::shutdown() {
    2528   glfwTerminate();
    2629}
    2730
    28 void* GameGui_GLFW::CreateWindow(const string& title, unsigned int width, unsigned int height, bool fullscreen) {
     31void* GameGui_GLFW::createWindow(const string& title, int width, int height, bool fullscreen) {
    2932   GLFWwindow* window = nullptr;
    3033   GLFWmonitor* mon = nullptr;
     
    4952      const GLFWvidmode* vmode = glfwGetVideoMode(mon);
    5053
    51       width = vmode->width;
    52       height = vmode->height;
    53 
    54       // TODO: Should probably enable some way to retrieve this from outside this class
    55       // and print it out there
    56       cout << "Fullscreen resolution " << vmode->width << "x" << vmode->height << endl;
     54      windowWidth = vmode->width;
     55      windowHeight = vmode->height;
     56   } else {
     57      windowWidth = width;
     58      windowHeight = height;
    5759   }
    5860
    59    window = glfwCreateWindow(width, height, title.c_str(), mon, nullptr);
     61   window = glfwCreateWindow(windowWidth, windowHeight, title.c_str(), mon, nullptr);
    6062   //glfwMakeContextCurrent(window);
    6163
     
    6870}
    6971
    70 void GameGui_GLFW::DestroyWindow() {
     72void GameGui_GLFW::destroyWindow() {
    7173   // TODO: This function can throw some errors. They should be handled
    7274   glfwDestroyWindow(window);
     
    7577#ifdef GAMEGUI_INCLUDE_VULKAN
    7678
    77 bool GameGui_GLFW::CreateVulkanSurface(VkInstance instance, VkSurfaceKHR* surface) {
     79bool GameGui_GLFW::createVulkanSurface(VkInstance instance, VkSurfaceKHR* surface) {
    7880   return glfwCreateWindowSurface(instance, window, nullptr, surface) == VK_SUCCESS ?
    7981      RTWO_SUCCESS : RTWO_ERROR;
     
    8284#endif
    8385
    84 vector<const char*> GameGui_GLFW::GetRequiredExtensions() {
     86vector<const char*> GameGui_GLFW::getRequiredExtensions() {
    8587   uint32_t glfwExtensionCount = 0;
    8688   const char** glfwExtensions;
     
    9395}
    9496
    95 void GameGui_GLFW::GetWindowSize(int* width, int* height) {
    96    glfwGetFramebufferSize(window, width, height);
     97void GameGui_GLFW::getWindowSize(int* width, int* height) {
     98   // This function segfaults on OSX, check other platforms
     99   //glfwGetFramebufferSize(window, width, height);
     100
     101   *width = windowWidth;
     102   *height = windowHeight;
    97103}
    98104
  • game-gui-glfw.hpp

    r1ce9afe r7fc5e27  
    2121      static bool s_keyDown[NUM_KEYS];
    2222
    23       string& GetError();
     23      string& getError();
    2424
    25       bool Init();
    26       void Shutdown();
     25      bool init();
     26      void shutdown();
    2727
    28       void* CreateWindow(const string& title, unsigned int width, unsigned int height, bool fullscreen);
    29       void DestroyWindow();
     28      void* createWindow(const string& title, int width, int height, bool fullscreen);
     29      void destroyWindow();
    3030
    3131#ifdef GAMEGUI_INCLUDE_VULKAN
    32       bool CreateVulkanSurface(VkInstance instance, VkSurfaceKHR* surface);
     32      bool createVulkanSurface(VkInstance instance, VkSurfaceKHR* surface);
    3333#endif
    3434
    35       vector<const char*> GetRequiredExtensions();
    36       void GetWindowSize(int* width, int* height);
     35      vector<const char*> getRequiredExtensions();
     36      void getWindowSize(int* width, int* height);
    3737
    3838   private:
    3939      GLFWwindow* window;
     40
     41      int windowWidth, windowHeight;
    4042};
    4143
  • game-gui-sdl.cpp

    r1ce9afe r7fc5e27  
    55string GameGui_SDL::s_errorMessage;
    66
    7 string& GameGui_SDL::GetError() {
     7string& GameGui_SDL::getError() {
    88   GameGui_SDL::s_errorMessage = SDL_GetError();
    99
     
    1111}
    1212
    13 bool GameGui_SDL::Init() {
     13bool GameGui_SDL::init() {
    1414   // may want to define SDL_INIT_NOPARACHUTE when I start handling crashes since it
    1515   // prevents SDL from setting up its own handlers for SIG_SEGV and stuff like that
     
    3333}
    3434
    35 void GameGui_SDL::Shutdown() {
     35void GameGui_SDL::shutdown() {
    3636   SDL_Quit();
    3737}
    3838
    39 void* GameGui_SDL::CreateWindow(const string& title, unsigned int width, unsigned int height, bool fullscreen) {
    40    cout << "About to go fullscreen in SDL..." << endl;
    41 
     39void* GameGui_SDL::createWindow(const string& title, int width, int height, bool fullscreen) {
    4240   // TODO: Make an OpenGL version of the SDL_CreateWindow call as well
    4341
    4442   // On Apple's OS X you must set the NSHighResolutionCapable Info.plist property to YES,
    4543   // otherwise you will not receive a High DPI OpenGL canvas.
     44
     45   uint32_t flags = SDL_WINDOW_VULKAN;
     46
     47   flags |= fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_RESIZABLE;
     48
    4649   window = SDL_CreateWindow(title.c_str(),
    4750               SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
    48                width, height,
    49                SDL_WINDOW_VULKAN | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
     51               width, height, flags);
    5052
    5153   return window;
    5254}
    5355
    54 void GameGui_SDL::DestroyWindow() {
     56void GameGui_SDL::destroyWindow() {
    5557   // TODO: This function can throw some errors. They should be handled
    5658   SDL_DestroyWindow(window);
     
    5961#ifdef GAMEGUI_INCLUDE_VULKAN
    6062
    61 bool GameGui_SDL::CreateVulkanSurface(VkInstance instance, VkSurfaceKHR* surface) {
     63bool GameGui_SDL::createVulkanSurface(VkInstance instance, VkSurfaceKHR* surface) {
    6264   return SDL_Vulkan_CreateSurface(window, instance, surface) ?
    6365      RTWO_SUCCESS : RTWO_ERROR;
     
    6668#endif
    6769
    68 vector<const char*> GameGui_SDL::GetRequiredExtensions() {
     70vector<const char*> GameGui_SDL::getRequiredExtensions() {
    6971   uint32_t extensionCount = 0;
    7072   SDL_Vulkan_GetInstanceExtensions(window, &extensionCount, nullptr);
     
    7678}
    7779
    78 void GameGui_SDL::GetWindowSize(int* width, int* height) {
     80void GameGui_SDL::getWindowSize(int* width, int* height) {
    7981   SDL_GetWindowSize(window, width, height);
    8082}
  • game-gui-sdl.hpp

    r1ce9afe r7fc5e27  
    1111class GameGui_SDL : public GameGui {
    1212   public:
    13       string& GetError();
     13      string& getError();
    1414
    15       bool Init();
    16       void Shutdown();
     15      bool init();
     16      void shutdown();
    1717
    18       void* CreateWindow(const string& title, unsigned int width, unsigned int height, bool fullscreen);
    19       void DestroyWindow();
     18      void* createWindow(const string& title, int width, int height, bool fullscreen);
     19      void destroyWindow();
    2020
    2121#ifdef GAMEGUI_INCLUDE_VULKAN
    22       bool CreateVulkanSurface(VkInstance instance, VkSurfaceKHR* surface);
     22      bool createVulkanSurface(VkInstance instance, VkSurfaceKHR* surface);
    2323#endif
    2424
    25       vector<const char*> GetRequiredExtensions();
    26       void GetWindowSize(int* width, int* height);
     25      vector<const char*> getRequiredExtensions();
     26      void getWindowSize(int* width, int* height);
    2727
    2828   private:
  • game-gui.hpp

    r1ce9afe r7fc5e27  
    1818      virtual ~GameGui() {};
    1919
    20       virtual string& GetError() = 0;
     20      virtual string& getError() = 0;
    2121
    22       virtual bool Init() = 0;
    23       virtual void Shutdown() = 0;
     22      virtual bool init() = 0;
     23      virtual void shutdown() = 0;
    2424
    25       virtual void* CreateWindow(const string& title, unsigned int width, unsigned int height, bool fullscreen) = 0;
    26       virtual void DestroyWindow() = 0;
     25      virtual void* createWindow(const string& title, int width, int height, bool fullscreen) = 0;
     26      virtual void destroyWindow() = 0;
    2727
    2828#ifdef GAMEGUI_INCLUDE_VULKAN
    29       virtual bool CreateVulkanSurface(VkInstance instance, VkSurfaceKHR* surface) = 0;
     29      virtual bool createVulkanSurface(VkInstance instance, VkSurfaceKHR* surface) = 0;
    3030#endif
    3131
    32       virtual vector<const char*> GetRequiredExtensions() = 0;
    33       virtual void GetWindowSize(int* width, int* height) = 0;
     32      virtual vector<const char*> getRequiredExtensions() = 0;
     33      virtual void getWindowSize(int* width, int* height) = 0;
    3434};
    3535
  • vulkan-ref.cpp

    r1ce9afe r7fc5e27  
    1919#include <chrono>
    2020
     21#include "consts.hpp"
    2122#include "utils.h"
    2223
     
    226227         // TODO: Put all fonts, textures, and images in the assets folder
    227228
    228          if (gui->Init() == RTWO_ERROR) {
     229         if (gui->init() == RTWO_ERROR) {
    229230            cout << "UI library could not be initialized!" << endl;
    230231            cout << SDL_GetError() << endl;
     
    233234         cout << "GUI init succeeded" << endl;
    234235
    235          window = (SDL_Window*) gui->CreateWindow("Vulkan Game", SCREEN_WIDTH, SCREEN_HEIGHT);
     236         window = (SDL_Window*) gui->createWindow("Vulkan Game", SCREEN_WIDTH, SCREEN_HEIGHT, false);
    236237         if (window == nullptr) {
    237238            cout << "Window could not be created!" << endl;
     
    459460
    460461      vector<const char*> getRequiredExtensions() {
    461          vector<const char*> extensions = gui->GetRequiredExtensions();
     462         vector<const char*> extensions = gui->getRequiredExtensions();
    462463
    463464         if (enableValidationLayers) {
     
    488489
    489490      void createSurface() {
    490          if (gui->CreateVulkanSurface(instance, &surface) == RTWO_ERROR) {
     491         if (gui->createVulkanSurface(instance, &surface) == RTWO_ERROR) {
    491492            throw runtime_error("failed to create window surface!");
    492493         }
     
    710711         else {
    711712            int width, height;
    712             gui->GetWindowSize(&width, &height);
     713            gui->getWindowSize(&width, &height);
    713714
    714715            VkExtent2D actualExtent = {
     
    18121813         int width = 0, height = 0;
    18131814
    1814          gui->GetWindowSize(&width, &height);
     1815         gui->getWindowSize(&width, &height);
    18151816
    18161817         while (width == 0 || height == 0 ||
    18171818            (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED) != 0) {
    18181819            SDL_WaitEvent(nullptr);
    1819             gui->GetWindowSize(&width, &height);
     1820            gui->getWindowSize(&width, &height);
    18201821         }
    18211822
     
    19081909         gRenderer = nullptr;
    19091910
    1910          gui->DestroyWindow();
    1911          gui->Shutdown();
     1911         gui->destroyWindow();
     1912         gui->shutdown();
    19121913         delete gui;
    19131914      }
Note: See TracChangeset for help on using the changeset viewer.