Skip to content

0.1 (alpha)

Pre-release
Pre-release
Compare
Choose a tag to compare
@Wallby Wallby released this 15 Aug 15:35

First release of gpu-mini.

To link libgpu-mini.lib/libgpu-mini.a..

  • on windows..
    • add library folder $(VULKAN_SDK)/Lib/
    • add library vulkan-1
  • on chromeos (linux)..
    • add libraries vulkan and X11

To use gpu_mini.h..

  • on windows..
    • add include folder $(VULKAN_SDK)/Include/

Here is an example of using gpu-mini..

#include <window_mini.h>
//#define GM_SAFETY //< uncomment this or manually add ELoadVulkanParametersFlag_Safety to loadVulkanParameters.flags to enable validation layers
#include <gpu_mini.h>


int bQuit = 0;
void on_window_closed(int window)
{
  bQuit = 1;
}

enum
{
  EProgress_LoadedWindowMini = 1,
  EProgress_AddedWindow = 2,
  EProgress_LoadedVulkan = 3,
  EProgress_LoadedVkinstance = 4
};
int main(int argc, char** argv)
{
  int window;

  do
  {
    if(wm_load() != 1)
    {
      break;
    }
    progress = EProgress_LoadedWindowMini;

    wm_set_on_window_closed(&on_window_closed);

    struct wm_info_t infoAboutWindowMini;
    if(wm_get_info(&infoAboutWindowMini) != 1)
    {
      break;
    }

    struct wm_add_window_parameters_t addWindowParameters = wm_add_window_parameters_default;
    struct wm_window_source_t windowSource = wm_window_source_default;
    if(wm_add_window(&addWindowParameters, &windowSource, &window) != 1)
    {
      break;
    }
    progress = EProgress_AddedWindow;

    struct wm_info_about_window_t infoAboutWindow;
    if(wm_get_info_about_window(&infoAboutWindow) != 1)
    {
      break;
    }

    struct gm_load_vulkan_parameters_t loadVulkanParameters = gm_load_vulkan_parameter_default;
    if(gm_load_vulkan(&loadVulkanParameters) != 1)
    {
      break;
    }
    progress = EProgress_LoadedVulkan;

    struct gm_load_vkinstance_parameters_t loadVkinstanceParameters;
#if defined(_WIN32)
    loadVkinstanceParameters.win32.hinstance.a = infoAboutWindowMini.win32.hinstance.a;
    loadVkinstanceParameters.win32.hwnd.a = infoAboutWindowMini.win32.hwnd.a;
#else //< #elif defined(__linux__)
    loadVkinstanceParameters.xlib.display.a = infoAboutWindowMini.xlib.display.a;
    loadVkinstanceParameters.xlib.window.a = infoAboutWindowMini.xlib.window.a;
    if(gm_load_vkinstance(&loadVkinstanceParameters) != 1)
    {
      break;
    }
    progress = EProgress_LoadedVkinstance;

    while(bQuit != 1)
    {
      wm_poll();
    }
  } while(0);
  if(progress >= EProgress_LoadedVkinstance)
  {
    gm_unload_vkinstance();
  }
  if(progress >= EProgress_LoadedVulkan)
  {
    gm_unload_vulkan();
  }
  if(progress >= EProgress_AddedWindow)
  {
    wm_remove_window(window);
  }
  if(progress >= EProgress_LoadedWindowMini)
  {
    wm_unload();
  }

  return 0;
}