Add git version/tag/commit to window title
This commit is contained in:
parent
1809dafb73
commit
6052c41376
3 changed files with 19 additions and 6 deletions
|
@ -1,12 +1,20 @@
|
|||
cmake_minimum_required(VERSION 2.8.9)
|
||||
cmake_minimum_required(VERSION 3.4)
|
||||
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
|
||||
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
|
||||
|
||||
execute_process(
|
||||
COMMAND git describe --tags --always
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_COMMIT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
file(WRITE "src/gitparams.h" "#define GIT_CUR_COMMIT ${GIT_COMMIT}")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
|
||||
|
||||
project(dungeon)
|
||||
project(dungeon LANGUAGES CXX)
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_package(GLEW REQUIRED)
|
||||
|
|
|
@ -81,7 +81,9 @@ bool App::init() {
|
|||
SDL_LogVerbose(SDL_LOG_CATEGORY_SYSTEM, "Config Loaded.\n");
|
||||
|
||||
renderer = new Renderer();
|
||||
if (!renderer->Init("Dungeon", config.window.width, config.window.height)) {
|
||||
std::string title = "Dungeon ";
|
||||
title += version;
|
||||
if (!renderer->Init(title, config.window.width, config.window.height)) {
|
||||
const char* error = SDL_GetError();
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "%s", error);
|
||||
SDL_ShowSimpleMessageBox(0, "Error", error, nullptr);
|
||||
|
@ -108,6 +110,7 @@ int App::start() {
|
|||
double currentTime = currTime();
|
||||
double accumulator = dt;
|
||||
|
||||
bool show_log = false;
|
||||
bool running = true;
|
||||
Gamestate* nextstate = nullptr;
|
||||
|
||||
|
@ -190,7 +193,6 @@ int App::start() {
|
|||
|
||||
accumulator -= dt;
|
||||
}
|
||||
|
||||
renderer->Clear();
|
||||
current->draw(accumulator / dt);
|
||||
renderer->Present();
|
||||
|
|
|
@ -5,14 +5,17 @@
|
|||
#ifndef DUNGEON_APP_H
|
||||
#define DUNGEON_APP_H
|
||||
|
||||
#pragma once
|
||||
|
||||
class Gamestate;
|
||||
class Renderer;
|
||||
class Input;
|
||||
|
||||
#include "gitparams.h"
|
||||
#define ADD_QUOTES_HELPER(s) #s
|
||||
#define ADD_QUOTES(s) ADD_QUOTES_HELPER(s)
|
||||
|
||||
class App {
|
||||
public:
|
||||
const char* version = ADD_QUOTES(GIT_CUR_COMMIT);
|
||||
Gamestate* current;
|
||||
Renderer* renderer;
|
||||
Input* input;
|
||||
|
|
Loading…
Reference in a new issue