developer console working. can reload or change the background image now with network connection.
This commit is contained in:
parent
ed32f515a3
commit
14e08db4ca
4 changed files with 47 additions and 5 deletions
|
@ -66,4 +66,9 @@ namespace developer {
|
|||
|
||||
return it->second(payload);
|
||||
}
|
||||
|
||||
DeveloperConsole::CallbackResult resultOkay()
|
||||
{
|
||||
return DeveloperConsole::CallbackResult::createOkay();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@ namespace developer {
|
|||
CallbackResult(bool okay, const std::string &answer);
|
||||
|
||||
public:
|
||||
static CallbackResult createError(const std::string &answer);
|
||||
static CallbackResult createOkay(const std::string &answer);
|
||||
static CallbackResult createError(const std::string &answer="");
|
||||
static CallbackResult createOkay(const std::string &answer="");
|
||||
|
||||
public:
|
||||
// read-only interface to result data
|
||||
|
@ -44,4 +44,6 @@ namespace developer {
|
|||
private:
|
||||
std::map<std::string, callback_t> m_callbacks;
|
||||
};
|
||||
|
||||
DeveloperConsole::CallbackResult resultOkay();
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#include "state/events/missile_event.hpp"
|
||||
#include "state/events/ship_event.hpp"
|
||||
|
||||
#include "developer_console.hpp"
|
||||
|
||||
namespace endofthejedi {
|
||||
void RendererPolygon3d::setup()
|
||||
{
|
||||
|
@ -39,20 +41,50 @@ namespace endofthejedi {
|
|||
addModel("../data/mesh/planet_128.stl", &m_planetModel);
|
||||
addModel("../data/mesh/ship_ufo.stl", &m_shipModel);
|
||||
|
||||
m_texture = nullptr;
|
||||
m_backgroundTexturePath = "../data/img/test.png";
|
||||
loadBackgroundTexture();
|
||||
|
||||
developer::DeveloperConsole::instance().addCallback("reload_bg", [=](const std::string &)
|
||||
{
|
||||
loadBackgroundTexture();
|
||||
return developer::resultOkay();
|
||||
});
|
||||
|
||||
developer::DeveloperConsole::instance().addCallback("set_bg", [=](const std::string &str)
|
||||
{
|
||||
std::string token;
|
||||
std::string rest;
|
||||
util::splitIntoTokenAndRest(str, token, rest);
|
||||
|
||||
m_backgroundTexturePath = token;
|
||||
loadBackgroundTexture();
|
||||
return developer::resultOkay();
|
||||
});
|
||||
}
|
||||
|
||||
void RendererPolygon3d::loadBackgroundTexture()
|
||||
{
|
||||
//m_texture = new ImageTexture("../data/img/test.png");
|
||||
m_texture = new ImageTexture("../data/img/stars_nebular.png");
|
||||
if (m_texture != nullptr) {
|
||||
delete(m_texture);
|
||||
}
|
||||
|
||||
//"../data/img/stars_nebular.png");
|
||||
m_texture = new ImageTexture(m_backgroundTexturePath);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
m_texture->loadPng();
|
||||
|
||||
std::cout<<"texture loading: " << m_texture->valid() << std::endl;
|
||||
if (!m_texture->valid()) {
|
||||
exit(-1);
|
||||
std::cout<<"loading failed!";
|
||||
return;
|
||||
//exit(-1);
|
||||
}
|
||||
|
||||
glm::vec2 s = m_texture->size();
|
||||
std::cout<<"texture size is " << s.x << " X " << s.y << std::endl;
|
||||
//exit(0);
|
||||
}
|
||||
|
||||
void RendererPolygon3d::renderBackgroundImage()
|
||||
|
|
|
@ -64,6 +64,8 @@ namespace endofthejedi {
|
|||
|
||||
void renderBackgroundImage();
|
||||
|
||||
void loadBackgroundTexture();
|
||||
|
||||
private:
|
||||
// all models are also here (for easy reloading etc.)
|
||||
std::vector<PolygonModel*> m_models;
|
||||
|
@ -92,6 +94,7 @@ namespace endofthejedi {
|
|||
std::list<const game::Missile*> m_missiles;
|
||||
std::list<const game::Ship*> m_ships;
|
||||
|
||||
std::string m_backgroundTexturePath;
|
||||
ImageTexture *m_texture;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue