source: opengl-game/new-vulkan-game.cpp@ aeedfb3

feature/imgui-sdl points-test
Last change on this file since aeedfb3 was aeedfb3, checked in by Dmitry Portnoy <dmp1488@…>, 5 years ago

Add minor updates to the Vulkan code

  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[71876b9]1#include <SDL2/SDL.h>
2#include <SDL2/SDL_vulkan.h>
3
4#define _USE_MATH_DEFINES // Will be needed when/if I need to # include <cmath>
5
6#define GLM_FORCE_RADIANS
7#define GLM_FORCE_DEPTH_ZERO_TO_ONE
8#include <glm/vec4.hpp>
9#include <glm/mat4x4.hpp>
10
11#include <iostream>
12#include <vector>
13
14using namespace std;
15using namespace glm;
16
17const int SCREEN_WIDTH = 800;
18const int SCREEN_HEIGHT = 600;
19
20int main(int argc, char* argv[]) {
21 cout << "Starting Vulkan SDL game..." << endl;
22
23 SDL_Window* window = nullptr;
24 //SDL_Surface* screenSurface = nullptr;
25
26 if (SDL_Init(SDL_INIT_VIDEO) < 0) {
27 cout << "SDL could not initialize! SDL_Error: " << SDL_GetError() << endl;
28 } else {
29 window = SDL_CreateWindow("Vulkan Game",
30 SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
31 SCREEN_WIDTH, SCREEN_HEIGHT,
32 SDL_WINDOW_VULKAN);
33
34 if (window == nullptr) {
35 cout << "Window could not be created! SDL_Error: " << SDL_GetError() << endl;
36 } else {
37 //screenSurface = SDL_GetWindowSurface(window);
38
39 //SDL_FillRect(screenSurface, nullptr, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));
40
41 SDL_UpdateWindowSurface(window);
42
43 uint32_t extensionCount;
44
[aeedfb3]45 //vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr);
[71876b9]46
[aeedfb3]47 //cout << "Vulkan extensions (" << extensionCount << "):" << endl;
48 //cout << endl;
[71876b9]49
50 SDL_Vulkan_GetInstanceExtensions(window, &extensionCount, nullptr);
51
52 vector<const char*> extensionNames(extensionCount);
53 SDL_Vulkan_GetInstanceExtensions(window, &extensionCount, extensionNames.data());
54
[aeedfb3]55 cout << "SDL Vulkan extensions (" << extensionCount << "):" << endl;
[71876b9]56
57 for (vector<const char*>::iterator it = extensionNames.begin(); it != extensionNames.end(); it++) {
58 cout << *it << endl;
59 }
60
61 SDL_Delay(2000);
62 }
63 }
64
65 SDL_DestroyWindow( window );
66
67 SDL_Quit();
68
69 cout << "Finished" << endl;
70
71 exit(0);
72}
Note: See TracBrowser for help on using the repository browser.