Changeset 6bfd91c in opengl-game
- Timestamp:
- Jun 10, 2020, 9:47:29 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master
- Children:
- aa7707d
- Parents:
- f809ae6
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.cpp
rf809ae6 r6bfd91c 21 21 this->gui = nullptr; 22 22 this->window = nullptr; 23 this->font = nullptr;24 this->fontSDLTexture = nullptr;25 this->imageSDLTexture = nullptr;26 23 27 24 this->currentFrame = 0; … … 146 143 // TODO: Print the filename of the font in the error message 147 144 148 font = TTF_OpenFont("assets/fonts/lazy.ttf", 28);149 if ( font == nullptr) {145 lazyFont = TTF_OpenFont("assets/fonts/lazy.ttf", 28); 146 if (lazyFont == nullptr) { 150 147 cout << "Failed to load lazy font! SDL_ttf Error: " << TTF_GetError() << endl; 151 148 return RTWO_ERROR; 152 149 } 153 154 SDL_Surface* fontSDLSurface = TTF_RenderText_Solid(font, "Great success!", { 255, 255, 255 });155 if (fontSDLSurface == nullptr) {156 cout << "Unable to render text surface! SDL_ttf Error: " << TTF_GetError() << endl;157 return RTWO_ERROR;158 }159 160 fontSDLTexture = SDL_CreateTextureFromSurface(renderer, fontSDLSurface);161 if (fontSDLTexture == nullptr) {162 cout << "Unable to create texture from rendered text! SDL Error: " << SDL_GetError() << endl;163 SDL_FreeSurface(fontSDLSurface);164 return RTWO_ERROR;165 }166 167 SDL_FreeSurface(fontSDLSurface);168 169 // TODO: Load a PNG instead170 SDL_Surface* imageSDLSurface = SDL_LoadBMP("assets/images/spaceship.bmp");171 if (imageSDLSurface == nullptr) {172 cout << "Unable to load image " << "spaceship.bmp" << "! SDL Error: " << SDL_GetError() << endl;173 return RTWO_ERROR;174 }175 176 imageSDLTexture = SDL_CreateTextureFromSurface(renderer, imageSDLSurface);177 if (imageSDLTexture == nullptr) {178 cout << "Unable to create texture from BMP surface! SDL Error: " << SDL_GetError() << endl;179 SDL_FreeSurface(imageSDLSurface);180 return RTWO_ERROR;181 }182 183 SDL_FreeSurface(imageSDLSurface);184 150 185 151 proggyFont = TTF_OpenFont("assets/fonts/ProggyClean.ttf", 16); … … 1142 1108 delete screens[SCREEN_GAME]; 1143 1109 1144 // TODO: Check if any of these functions accept null parameters 1145 // If they do, I don't need to check for that 1146 1147 if (fontSDLTexture != nullptr) { 1148 SDL_DestroyTexture(fontSDLTexture); 1149 fontSDLTexture = nullptr; 1150 } 1151 1152 if (imageSDLTexture != nullptr) { 1153 SDL_DestroyTexture(imageSDLTexture); 1154 imageSDLTexture = nullptr; 1155 } 1156 1157 TTF_CloseFont(font); 1158 font = nullptr; 1110 if (lazyFont != nullptr) { 1111 TTF_CloseFont(lazyFont); 1112 lazyFont = nullptr; 1113 } 1159 1114 1160 1115 if (proggyFont != nullptr) { -
vulkan-game.hpp
rf809ae6 r6bfd91c 12 12 #include <glm/gtc/matrix_transform.hpp> 13 13 14 #include <vulkan/vulkan.h> 15 16 #include <SDL2/SDL_ttf.h> 17 18 #include "consts.hpp" 14 19 #include "vulkan-utils.hpp" 15 20 #include "graphics-pipeline_vulkan.hpp" … … 202 207 Screen* currentScreen; 203 208 209 TTF_Font* lazyFont; 204 210 TTF_Font* proggyFont; 205 211 … … 285 291 VulkanImage laserTextureImage; 286 292 VkDescriptorImageInfo laserTextureImageDescriptor; 287 288 TTF_Font* font;289 SDL_Texture* fontSDLTexture;290 291 SDL_Texture* imageSDLTexture;292 293 293 294 mat4 viewMat, projMat;
Note:
See TracChangeset
for help on using the changeset viewer.