working on opengl resources reinitialization
This commit is contained in:
parent
ce905daa85
commit
55b042a979
@ -918,6 +918,9 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
|
||||
}
|
||||
|
||||
// :::::::::::
|
||||
*SE::Console << BkgTexture;
|
||||
*SE::Console << std::to_string(ResourceManager->TexList[BkgTexture]);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[BkgTexture]);
|
||||
//Renderer->DrawRect(Vector2f(xlOffset, ylOffset), Vector2f(xlOffset+tSW, ylOffset+tSH),Vector2f(0.f, 0.f), Vector2f(1.f, 1.f));
|
||||
Renderer->DrawRect(Vector2f(bkgSWO, bkgSHO), Vector2f(bkgSWO + bkgSW, bkgSHO + bkgSH), Vector2f(0.f, 0.f), Vector2f(1.f, 1.f));
|
||||
|
@ -152,8 +152,6 @@ void TMyApplication::InnerInit()
|
||||
ST::PathToResources = "";
|
||||
#endif
|
||||
|
||||
LoadUserProgress();
|
||||
|
||||
if (Console != NULL)
|
||||
{
|
||||
*Console<<"APP INIT\n";
|
||||
@ -162,59 +160,62 @@ void TMyApplication::InnerInit()
|
||||
GameState = CONST_GAMESTATE_PRELOADING;
|
||||
StateTimer = 0.f;
|
||||
|
||||
/*
|
||||
ResourceManager->ShaderManager.AddShader("DefaultShader", "shader1vertex", "shader1fragment.txt");
|
||||
ResourceManager->ShaderManager.AddShader("FrameShader", "frameshader_vertex.txt", "frameshader_fragment.txt");
|
||||
ResourceManager->ShaderManager.AddShader("BrickShader", "brickshader_vertex.txt", "brickshader_fragment.txt");
|
||||
Renderer->PushShader("DefaultShader");
|
||||
*/
|
||||
|
||||
//ResourceManager->ShaderManager.AddShader("DefaultShader", "shaders/texture-shader.vertex", "shaders/texture-shader.fragment");
|
||||
ResourceManager->ShaderManager.AddShader("DefaultShader", "shaders/gui_transparent.vertex", "shaders/gui_transparent.fragment");
|
||||
ResourceManager->ShaderManager.AddShader("HoverableButtonShader", "shaders/gui_transparent.vertex", "shaders/hoverable-button.fragment");
|
||||
ResourceManager->ShaderManager.AddShader("BlackAndWhiteShader", "shaders/gui_transparent_blackandwhite.vertex", "shaders/gui_transparent_blackandwhite.fragment");
|
||||
ResourceManager->ShaderManager.AddShader("ColorShader", "shaders/color-shader.vertex", "shaders/color-shader.fragment");
|
||||
ResourceManager->ShaderManager.AddShader("FrameShader", "shaders/frameshader_vertex.txt", "shaders/frameshader_fragment.txt");
|
||||
ResourceManager->ShaderManager.AddShader("BrickShader", "shaders/brickshader_vertex.txt", "shaders/brickshader_fragment.txt");
|
||||
ResourceManager->ShaderManager.AddShader(ParticleEffect::PARTICLE_SHADER, "shaders/particle-shader.vertex", "shaders/particle-shader.fragment");
|
||||
Renderer->PushShader("DefaultShader");
|
||||
Renderer->PushShader("DefaultShader");
|
||||
|
||||
//ResourceManager->TexList.AddTexture(CONST_LOADING_BACKGROUND_BLACK + ".png", CONST_LOADING_BACKGROUND_BLACK);
|
||||
//ResourceManager->TexList.AddTexture(CONST_LOADING_TEXTURE + ".png", CONST_LOADING_TEXTURE);
|
||||
//ResourceManager->TexList.AddTexture(CONST_LOGO_SMALL_TEXTURE + ".png", CONST_LOGO_SMALL_TEXTURE);
|
||||
ResourceManager->TexList.AddTexture("console_bkg.bmp");
|
||||
ResourceManager->TexList.AddTexture("white.bmp");
|
||||
|
||||
ResourceManager->TexList.AddTexture("console_bkg.bmp");
|
||||
ResourceManager->TexList.AddTexture("white.bmp");
|
||||
ResourceManager->FontManager.AddFont("arial32", "arial32.png", "arial32.txt");
|
||||
ResourceManager->FontManager.AddFont("lucon12", "lucon12.png", "lucon12.txt");
|
||||
ResourceManager->FontManager.PushFont("lucon12");
|
||||
|
||||
Renderer->SetOrthoProjection();
|
||||
|
||||
ResourceManager->FrameManager.AddFrameRenderBuffer("LevelBuffer", 256, 256);
|
||||
Renderer->SetFullScreenViewport();
|
||||
|
||||
//OnDrawSignal.connect(boost::bind(&TGameLoading::Draw, boost::ref(GameLoading)));
|
||||
Inited = true;
|
||||
ResourceManager->newGuiManager.LoadFromConfig("gui_loading.json");
|
||||
|
||||
Renderer->SetOrthoProjection();
|
||||
skipUpdateToUpdateScreen = true;
|
||||
StateTimer = 0.f;
|
||||
}
|
||||
|
||||
Renderer->SetFullScreenViewport();
|
||||
Application->SetGameLevelScreenScale();
|
||||
//GameLevel.SetLevelScale();
|
||||
EffectsInit();
|
||||
void TMyApplication::InnerReinitGLResources()
|
||||
{
|
||||
RenderLevelSnapshots();
|
||||
|
||||
// ------- UI -------
|
||||
ResourceManager->FontManager.AddFont("arial32", "arial32.png", "arial32.txt");
|
||||
ResourceManager->FontManager.AddFont("lucon12", "lucon12.png", "lucon12.txt");
|
||||
ResourceManager->FontManager.PushFont("lucon12");
|
||||
//ResourceManager->newGuiManager.LoadFromConfig("gui_main_menu.json");
|
||||
ResourceManager->newGuiManager.LoadFromConfig("gui_loading.json");
|
||||
lsparkler.reinitGlResources();
|
||||
rsparkler.reinitGlResources();
|
||||
tsparkler.reinitGlResources();
|
||||
bsparkler.reinitGlResources();
|
||||
lvlFirework.reinitGlResources();
|
||||
}
|
||||
|
||||
// ------- UI -------
|
||||
void TMyApplication::RenderLevelSnapshots()
|
||||
{
|
||||
Renderer->SwitchToFrameBuffer("LevelBuffer");
|
||||
|
||||
// TESTS of menu
|
||||
if (Menu.GalaxMenu.InitGalaxyMenu("levels/galaxy_ptree.json")) {
|
||||
std::cout << "ok" << std::endl;
|
||||
}
|
||||
else {
|
||||
std::cout << "menu error" << std::endl;
|
||||
}
|
||||
Renderer->SetProjectionMatrix(768, 480);
|
||||
|
||||
Renderer->LoadIdentity();
|
||||
|
||||
for (auto &star : Menu.GalaxMenu.galaxies[0].Stars)
|
||||
{
|
||||
for (auto level : star.selectionMenu.gameLevels)
|
||||
{
|
||||
level->DrawSnapshot("LevelBuffer", false);
|
||||
|
||||
Renderer->PushShader("BlackAndWhiteShader");
|
||||
|
||||
level->DrawSnapshot("LevelBuffer", true);
|
||||
|
||||
Renderer->PopShader();
|
||||
}
|
||||
}
|
||||
|
||||
Renderer->SwitchToScreen();
|
||||
|
||||
Renderer->SetOrthoProjection();
|
||||
}
|
||||
|
||||
void TMyApplication::InnerDeinit()
|
||||
@ -494,10 +495,48 @@ void TMyApplication::InnerUpdate(size_t dt)
|
||||
StateTimer += dt/1000.f;
|
||||
if (StateTimer >= 1.f)
|
||||
{
|
||||
LoadResources();
|
||||
GameState = CONST_GAMESTATE_LOADING;
|
||||
StateTimer = 0.f;
|
||||
StateTimer -= 1.f;
|
||||
skipUpdateToUpdateScreen = false;
|
||||
}
|
||||
|
||||
if (skipUpdateToUpdateScreen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LoadUserProgress();
|
||||
|
||||
ResourceManager->ShaderManager.AddShader("HoverableButtonShader", "shaders/gui_transparent.vertex", "shaders/hoverable-button.fragment");
|
||||
ResourceManager->ShaderManager.AddShader("BlackAndWhiteShader", "shaders/gui_transparent_blackandwhite.vertex", "shaders/gui_transparent_blackandwhite.fragment");
|
||||
ResourceManager->ShaderManager.AddShader("ColorShader", "shaders/color-shader.vertex", "shaders/color-shader.fragment");
|
||||
ResourceManager->ShaderManager.AddShader("FrameShader", "shaders/frameshader_vertex.txt", "shaders/frameshader_fragment.txt");
|
||||
ResourceManager->ShaderManager.AddShader("BrickShader", "shaders/brickshader_vertex.txt", "shaders/brickshader_fragment.txt");
|
||||
ResourceManager->ShaderManager.AddShader(ParticleEffect::PARTICLE_SHADER, "shaders/particle-shader.vertex", "shaders/particle-shader.fragment");
|
||||
|
||||
|
||||
ResourceManager->FrameManager.AddFrameRenderBuffer("LevelBuffer", 256, 256);
|
||||
|
||||
|
||||
//OnDrawSignal.connect(boost::bind(&TGameLoading::Draw, boost::ref(GameLoading)));
|
||||
Inited = true;
|
||||
Application->SetGameLevelScreenScale();
|
||||
//GameLevel.SetLevelScale();
|
||||
EffectsInit();
|
||||
|
||||
// ------- UI -------
|
||||
|
||||
// TESTS of menu
|
||||
if (Menu.GalaxMenu.InitGalaxyMenu("levels/galaxy_ptree.json")) {
|
||||
std::cout << "ok" << std::endl;
|
||||
}
|
||||
else {
|
||||
std::cout << "menu error" << std::endl;
|
||||
}
|
||||
|
||||
RenderLevelSnapshots();
|
||||
|
||||
LoadResources();
|
||||
GameState = CONST_GAMESTATE_LOADING;
|
||||
}
|
||||
else if (GameState == CONST_GAMESTATE_LOADING)
|
||||
{
|
||||
@ -516,31 +555,6 @@ void TMyApplication::InnerUpdate(size_t dt)
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Renderer->SwitchToFrameBuffer("LevelBuffer");
|
||||
|
||||
Renderer->SetProjectionMatrix(768, 480);
|
||||
|
||||
Renderer->LoadIdentity();
|
||||
|
||||
for (auto &star : Menu.GalaxMenu.galaxies[0].Stars)
|
||||
{
|
||||
for (auto level : star.selectionMenu.gameLevels)
|
||||
{
|
||||
level->DrawSnapshot("LevelBuffer", false);
|
||||
|
||||
Renderer->PushShader("BlackAndWhiteShader");
|
||||
|
||||
level->DrawSnapshot("LevelBuffer", true);
|
||||
|
||||
Renderer->PopShader();
|
||||
}
|
||||
}
|
||||
|
||||
Renderer->SwitchToScreen();
|
||||
|
||||
Renderer->SetOrthoProjection();
|
||||
|
||||
GameState = CONST_GAMESTATE_MENU;
|
||||
ApplySignalsToMenu();
|
||||
|
||||
|
@ -89,6 +89,8 @@ const int CONST_GAMESTATE_PRELOADING = 7;
|
||||
class TMyApplication : public TApplication
|
||||
{
|
||||
protected:
|
||||
bool skipUpdateToUpdateScreen;
|
||||
|
||||
int levelScreenWidth;
|
||||
int levelScreenHeight;
|
||||
float levelScreenRatio = 1.6;
|
||||
@ -143,6 +145,10 @@ public:
|
||||
|
||||
virtual void InnerInit();
|
||||
|
||||
virtual void RenderLevelSnapshots();
|
||||
|
||||
virtual void InnerReinitGLResources();
|
||||
|
||||
virtual void InnerDeinit();
|
||||
|
||||
virtual void InnerDraw();
|
||||
|
@ -65,7 +65,7 @@ public class GL2JNIActivity extends Activity
|
||||
@Override
|
||||
protected void onPause()
|
||||
{
|
||||
EngineWrapper.CallDestroy();
|
||||
//EngineWrapper.CallDestroy();
|
||||
super.onPause();
|
||||
mView.onPause();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user