Builds and runs on windows

This commit is contained in:
Kayne Ruse
2015-09-03 15:36:48 +10:00
parent 0249352ca2
commit da218ee8ab
5 changed files with 29 additions and 6 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ end)
--]] --]]
generator, msg = loadfile("rsc/roguegenerator.lua") generator, msg = loadfile("../rsc/roguegenerator.lua")
if generator == nil then if generator == nil then
print("error: ", msg) print("error: ", msg)
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 540 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

+19 -1
View File
@@ -22,6 +22,7 @@
#include "application.hpp" #include "application.hpp"
#include <chrono> #include <chrono>
#include <iostream>
#include <sstream> #include <sstream>
#include <stdexcept> #include <stdexcept>
@@ -40,6 +41,9 @@ void Application::Init(int argc, char* argv[]) {
msg << "Failed to create the window: " << SDL_GetError(); msg << "Failed to create the window: " << SDL_GetError();
throw(std::runtime_error(msg.str())); throw(std::runtime_error(msg.str()));
} }
else {
std::cout << "Created the window" << std::endl;
}
//create and check the renderer //create and check the renderer
renderer = SDL_CreateRenderer(window, -1, 0); renderer = SDL_CreateRenderer(window, -1, 0);
@@ -49,20 +53,28 @@ void Application::Init(int argc, char* argv[]) {
msg << "Failed to create the renderer: " << SDL_GetError(); msg << "Failed to create the renderer: " << SDL_GetError();
throw(std::runtime_error(msg.str())); throw(std::runtime_error(msg.str()));
} }
else {
std::cout << "Created the renderer" << std::endl;
}
//screen scaling //screen scaling
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best");
SDL_RenderSetLogicalSize(renderer, 800, 600); SDL_RenderSetLogicalSize(renderer, screenWidth, screenHeight);
//set the hook for the renderer //set the hook for the renderer
BaseScene::SetRenderer(renderer); BaseScene::SetRenderer(renderer);
std::cout << "Initialized screen scaling" << std::endl;
//setting up SDL2_ttf //setting up SDL2_ttf
if (TTF_Init()) { if (TTF_Init()) {
std::ostringstream msg; std::ostringstream msg;
msg << "Failed to initialize SDL2_ttf: " << SDL_GetError(); msg << "Failed to initialize SDL2_ttf: " << SDL_GetError();
throw(std::runtime_error(msg.str())); throw(std::runtime_error(msg.str()));
} }
else {
std::cout << "Initialized SDL2_ttf" << std::endl;
}
//setup lua //setup lua
lua = luaL_newstate(); lua = luaL_newstate();
@@ -71,8 +83,13 @@ void Application::Init(int argc, char* argv[]) {
msg << "Failed to create the lua state"; msg << "Failed to create the lua state";
throw(std::runtime_error(msg.str())); throw(std::runtime_error(msg.str()));
} }
else {
std::cout << "Initialized lua" << std::endl;
}
luaL_openlibs(lua); luaL_openlibs(lua);
std::cout << "Initialization sucessful" << std::endl;
} }
void Application::Proc() { void Application::Proc() {
@@ -124,6 +141,7 @@ void Application::Proc() {
} }
void Application::Quit() { void Application::Quit() {
std::cout << "Closing the APIs" << std::endl;
lua_close(lua); lua_close(lua);
TTF_Quit(); TTF_Quit();
+9 -4
View File
@@ -29,13 +29,13 @@ ExampleScene::ExampleScene(lua_State* L) {
lua = L; lua = L;
//TODO: non-hardcoded source //TODO: non-hardcoded source
tileSheet.Load(GetRenderer(), "./rsc/terrain.bmp", 32, 32); tileSheet.Load(GetRenderer(), "../rsc/terrain.png", 32, 32);
//set the pager's hook //set the pager's hook
regionPager.SetLuaState(lua); regionPager.SetLuaState(lua);
//load the file as a chunk //load the file as a chunk
luaL_loadfile(lua, "./rsc/startup.lua"); luaL_loadfile(lua, "../rsc/startup.lua");
//push the pager as an arg //push the pager as an arg
lua_pushlightuserdata(lua, static_cast<void*>(&regionPager)); lua_pushlightuserdata(lua, static_cast<void*>(&regionPager));
@@ -49,8 +49,10 @@ ExampleScene::ExampleScene(lua_State* L) {
camera.scale = 0.25; camera.scale = 0.25;
//DEBUG: testing buttons //DEBUG: testing buttons
buttonBG.Load(GetRenderer(), "./rsc/button.png"); buttonBG.Load(GetRenderer(), "../rsc/button.png");
font = TTF_OpenFont("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 12); //Ubuntu: "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"
font = TTF_OpenFont("C:\\Windows\\Fonts\\Arial.ttf", 12);
if (!font) { if (!font) {
std::ostringstream msg; std::ostringstream msg;
msg << "Failed to load a font: " << SDL_GetError(); msg << "Failed to load a font: " << SDL_GetError();
@@ -70,6 +72,9 @@ ExampleScene::ExampleScene(lua_State* L) {
// //
blankImage.Create(GetRenderer(), 256, 256); blankImage.Create(GetRenderer(), 256, 256);
//
std::cout << "Scene setup finished" << std::endl;
} }
ExampleScene::~ExampleScene() { ExampleScene::~ExampleScene() {