Changeset 6bfd91c in opengl-game for vulkan-game.cpp


Ignore:
Timestamp:
Jun 10, 2020, 9:47:29 PM (4 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master
Children:
aa7707d
Parents:
f809ae6
Message:

Remove unused variables from the VulkanGame class after they were moved to the game Screen classes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-game.cpp

    rf809ae6 r6bfd91c  
    2121   this->gui = nullptr;
    2222   this->window = nullptr;
    23    this->font = nullptr;
    24    this->fontSDLTexture = nullptr;
    25    this->imageSDLTexture = nullptr;
    2623
    2724   this->currentFrame = 0;
     
    146143   // TODO: Print the filename of the font in the error message
    147144
    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) {
    150147      cout << "Failed to load lazy font! SDL_ttf Error: " << TTF_GetError() << endl;
    151148      return RTWO_ERROR;
    152149   }
    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 instead
    170    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);
    184150
    185151   proggyFont = TTF_OpenFont("assets/fonts/ProggyClean.ttf", 16);
     
    11421108   delete screens[SCREEN_GAME];
    11431109
    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   }
    11591114
    11601115   if (proggyFont != nullptr) {
Note: See TracChangeset for help on using the changeset viewer.