Changeset f809ae6 in opengl-game
- Timestamp:
- Jun 10, 2020, 9:44:02 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master
- Children:
- 6bfd91c
- Parents:
- 699e83a
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
gui/game-screen.cpp
r699e83a rf809ae6 9 9 #include "button.hpp" 10 10 #include "panel.hpp" 11 #include "ui-value.hpp" 11 12 12 13 using namespace std; … … 20 21 Screen(renderer, gameInfo) { 21 22 Panel *statsPanel = new Panel(10, 50, 95, 46, 0x161616FF, this->renderer); 23 24 statsPanel->addUIElement(new UIValue(0, 0, "Score: ", this->gameInfo.score, 25 this->gameInfo.proggyFont, 0xFFFFFFFF, this->renderer)); 26 statsPanel->addUIElement(new UIValue(14, 19, "FPS: ", this->gameInfo.fps, 27 this->gameInfo.proggyFont, 0xFFFFFFFF, this->renderer)); 22 28 23 29 // TODO: Add the button to the panel it's in, not directly to the window -
makefile
r699e83a rf809ae6 60 60 61 61 GUI_SRC_FILES = gui/screen.cpp gui/main-screen.cpp gui/game-screen.cpp gui/ui-element.cpp gui/button.cpp gui/panel.cpp 62 GUI_HEADER_FILES = gui/screen.hpp gui/main-screen.hpp gui/game-screen.hpp gui/ui-element.hpp gui/button.hpp gui/panel.hpp 62 GUI_HEADER_FILES = gui/screen.hpp gui/main-screen.hpp gui/game-screen.hpp gui/ui-element.hpp gui/button.hpp gui/panel.hpp gui/ui-value.hpp 63 63 64 64 SRC_FILES = main-vulkan.cpp vulkan-game.cpp crash-logger.cpp logger.cpp vulkan-utils.cpp utils.cpp game-gui-sdl.cpp $(GUI_SRC_FILES) -
vulkan-game.cpp
r699e83a rf809ae6 44 44 45 45 cout << "Vulkan Game" << endl; 46 47 this->score = 0; 46 48 47 49 if (initUI(width, height, guiFlags) == RTWO_ERROR) { … … 674 676 curTime = duration<float, seconds::period>(high_resolution_clock::now() - this->startTime).count(); 675 677 678 this->fpsStartTime = curTime; 679 this->frameCount = 0; 680 676 681 lastSpawn_asteroid = curTime; 677 682 … … 681 686 curTime = duration<float, seconds::period>(high_resolution_clock::now() - this->startTime).count(); 682 687 this->elapsedTime = curTime - this->prevTime; 688 689 if (curTime - this->fpsStartTime >= 1.0f) { 690 this->fps = (float)frameCount / (curTime - this->fpsStartTime); 691 692 this->frameCount = 0; 693 this->fpsStartTime = curTime; 694 } 695 696 this->frameCount++; 683 697 684 698 gui->processEvents(); … … 818 832 } 819 833 820 // renderUI();821 834 currentScreen->renderUI(); 822 835 … … 877 890 addExplosion(model_mat, 0.5f, curTime); 878 891 879 // TODO: Increment player's score here892 this->score++; 880 893 } else if ((objCenter.z - asteroid.radius) > -NEAR_CLIP) { 881 894 asteroid.ssbo.deleted = true; … … 1022 1035 1023 1036 VulkanUtils::copyDataToMemory(device, uniformBuffersMemory_explosionPipeline[currentImage], 0, explosion_UBO); 1024 }1025 1026 void VulkanGame::renderUI() {1027 SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0x00);1028 SDL_RenderClear(renderer);1029 1030 SDL_Rect rect = {280, 220, 100, 100};1031 SDL_SetRenderDrawColor(renderer, 0x00, 0xFF, 0x00, 0xFF);1032 SDL_RenderFillRect(renderer, &rect);1033 1034 rect = {10, 10, 0, 0};1035 SDL_QueryTexture(fontSDLTexture, nullptr, nullptr, &(rect.w), &(rect.h));1036 SDL_RenderCopy(renderer, fontSDLTexture, nullptr, &rect);1037 1038 rect = {10, 80, 0, 0};1039 SDL_QueryTexture(imageSDLTexture, nullptr, nullptr, &(rect.w), &(rect.h));1040 SDL_RenderCopy(renderer, imageSDLTexture, nullptr, &rect);1041 1042 SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0xFF, 0xFF);1043 SDL_RenderDrawLine(renderer, 50, 5, 150, 500);1044 1045 VulkanUtils::populateVulkanImageFromSDLTexture(device, physicalDevice, commandPool, uiOverlay, renderer,1046 sdlOverlayImage, graphicsQueue);1047 1037 } 1048 1038 -
vulkan-game.hpp
r699e83a rf809ae6 204 204 TTF_Font* proggyFont; 205 205 206 int score; 207 float fps; 208 206 209 GraphicsPipeline_Vulkan<OverlayVertex, void*> overlayPipeline; 207 210 … … 345 348 float prevTime, elapsedTime; 346 349 350 float fpsStartTime; 351 int frameCount; 352 347 353 float shipSpeed = 0.5f; 348 354 float asteroidSpeed = 2.0f; … … 363 369 void mainLoop(); 364 370 void updateScene(uint32_t currentImage); 365 void renderUI();366 371 void renderScene(); 367 372 void cleanup();
Note:
See TracChangeset
for help on using the changeset viewer.