merged gl-reinit, try to fix crash on reiniting

This commit is contained in:
Emil Kabirov 2018-11-29 08:37:06 +05:00
commit 3248d72416
13 changed files with 224 additions and 325 deletions

1
.gitignore vendored
View File

@ -7,6 +7,7 @@
## Build generated
build/
DerivedData/
.idea/
## Various settings
*.pbxuser

View File

@ -1,217 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="34a09786-f26b-40ab-ab95-a13a014633b6" name="Default" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="GradleLocalSettings">
<option name="externalProjectsViewState">
<projects_view />
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="604" />
<option name="width" value="1057" />
<option name="height" value="1004" />
</component>
<component name="ProjectView">
<navigator currentView="AndroidView" proportions="" version="1">
<flattenPackages />
<showMembers />
<showModules />
<showLibraryContents />
<hideEmptyPackages />
<abbreviatePackageNames />
<autoscrollToSource />
<autoscrollFromSource />
<sortByType />
<manualOrder />
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="ProjectPane" />
<pane id="AndroidView">
<subPane>
<expand>
<path>
<item name="double-hit-balls" type="1abcf292:AndroidViewProjectNode" />
<item name="double-hit-balls" type="e9137016:NonAndroidModuleNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="Scratches" />
<pane id="PackagesPane" />
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="android.sdk.path" value="$USER_HOME$/AppData/Local/Android/Sdk" />
<property name="settings.editor.selected.configurable" value="android.sdk-updates" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager">
<configuration default="true" type="AndroidJUnit" factoryName="Android JUnit">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<envs />
<patterns />
</configuration>
<configuration default="true" type="Application" factoryName="Application">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="" />
<envs />
</configuration>
<configuration default="true" type="Remote" factoryName="Remote">
<option name="USE_SOCKET_TRANSPORT" value="true" />
<option name="SERVER_MODE" value="false" />
<option name="SHMEM_ADDRESS" value="javadebug" />
<option name="HOST" value="localhost" />
<option name="PORT" value="5005" />
</configuration>
<configuration default="true" type="TestNG" factoryName="TestNG">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="SUITE_NAME" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="GROUP_NAME" />
<option name="TEST_OBJECT" value="CLASS" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
<option name="OUTPUT_DIRECTORY" />
<option name="ANNOTATION_TYPE" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<option name="USE_DEFAULT_REPORTERS" value="false" />
<option name="PROPERTIES_FILE" />
<envs />
<properties />
<listeners />
</configuration>
<configuration name="&lt;template&gt;" type="Applet" default="true" selected="false">
<option name="MAIN_CLASS_NAME" />
<option name="HTML_FILE_NAME" />
<option name="HTML_USED" value="false" />
<option name="WIDTH" value="400" />
<option name="HEIGHT" value="300" />
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
<option name="VM_PARAMETERS" />
</configuration>
<configuration name="&lt;template&gt;" type="JUnit" default="true" selected="false">
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
</configuration>
<configuration name="&lt;template&gt;" type="#org.jetbrains.idea.devkit.run.PluginConfigurationType" default="true" selected="false">
<option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m -ea" />
</configuration>
</component>
<component name="ShelveChangesManager" show_recycled="false">
<option name="remove_strategy" value="false" />
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="34a09786-f26b-40ab-ab95-a13a014633b6" name="Default" comment="" />
<created>1531738153088</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1531738153088</updated>
</task>
<servers />
</component>
<component name="ToolWindowManager">
<frame x="-9" y="-9" width="1938" height="1060" extended-state="6" />
<layout>
<window_info id="Android Profiler" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Palette&#9;" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Build Variants" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32919955" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Logcat" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Captures" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25349087" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Device File Explorer" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="true" content_ui="tabs" />
<window_info id="Theme Preview" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
<watches-manager />
</component>
</project>

View File

@ -1,7 +1,7 @@
precision mediump float;
in vec2 texCoord;
flat in vec4 color;
varying vec2 texCoord;
varying vec4 color;
uniform sampler2D Texture;

View File

@ -2,8 +2,8 @@ attribute vec3 vPosition;
attribute vec2 vTexCoord;
attribute vec4 vColor;
out vec2 texCoord;
flat out vec4 color;
varying vec2 texCoord;
varying vec4 color;
uniform mat4 ProjectionMatrix;

View File

@ -16,7 +16,7 @@ JNIEXPORT void JNICALL Java_fishrungames_doublehitballs_JniWrapper_Init(JNIEnv *
std::stringstream LoadFileFromAndroid(const std::string& fileName)
{
*Console << "LoadFileFromAndroid called \n";
GetConsole() << "LoadFileFromAndroid called \n";
JNIEnv* jEnv;
localJavaVirtualMachine->GetEnv((void**)&jEnv, JNI_VERSION_1_4);
@ -33,14 +33,14 @@ std::stringstream LoadFileFromAndroid(const std::string& fileName)
std::stringstream ss;
ss << jEnv->GetStringUTFChars(jFileContent, &jCopy);
*Console << ss.str();
GetConsole() << ss.str();
return ss;
}
void SaveFileToAndroid(const std::string& fileName, const std::string& fileContent)
{
*Console << "SaveFileToAndroid called \n";
GetConsole() << "SaveFileToAndroid called \n";
JNIEnv* jEnv;
localJavaVirtualMachine->GetEnv((void**)&jEnv, JNI_VERSION_1_4);

View File

@ -259,7 +259,8 @@ void GalaxyMenu::InteractWithGalaxy(size_t dt) {
if (timer_active) {
// ::::::::::::: timer active ::::::::::::::
if (menuState == 0) { // main view
//if (menuState == 0)
{ // main view
//if (currentTapShift(0) == 0.f && currentTapShift(1) == 0.f) {
if (currentTapShift(0) == totalTapShift(0) && currentTapShift(1) == totalTapShift(1)) {
// OnTapDown->
@ -312,7 +313,8 @@ void GalaxyMenu::InteractWithGalaxy(size_t dt) {
else {
// ::::::::::::: timer inactive ::::::::::::::
if (lastTapPos != Eigen::Vector2f(-9999.9f, -9999.9f)) {
if (menuState == 0) {// main view
//if (menuState == 0)
{// main view
// OnTapDown->OnTapUp
@ -325,8 +327,6 @@ void GalaxyMenu::InteractWithGalaxy(size_t dt) {
Application->SetupGalaxyUi(starIndex);
}
timer_active = false;
}/*
@ -384,6 +384,7 @@ void GalaxyMenu::InteractWithGalaxy(size_t dt) {
lastTapPos = Eigen::Vector2f(-9999.9f, -9999.9f); // reset
}
}
void GalaxyMenu::tapDown(Eigen::Vector2f pos) {

View File

@ -872,6 +872,8 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
Renderer->PushMatrix();
Renderer->LoadIdentity();
CheckGlError();
if (LevelState == CONST_LEVELSTATE_LOADING)
{
@ -958,11 +960,16 @@ 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));
//Renderer->DrawRect(Vector2f(0,0), Vector2f(100,100), Vector2f(0.f, 0.f), Vector2f(1.f, 1.f));
CheckGlError();
std::list<TBall>::iterator iBall;
@ -987,17 +994,25 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
Renderer->PushShader("BrickShader");
GetConsole() << "PUSHED BRICK SHADER";
CheckGlError();
for (int i = 0; i < CONST_BRICKMATRIX_WIDTH; i++)
{
for (int j = 0; j < CONST_BRICKMATRIX_HEIGHT; j++)
{
BlockMatrix[i][j].TryDrawAppear(i, j, screenWidth); //Draws only appearing/disappearing blocks
CheckGlError();
}
}
RenderUniform1f("Transparency", 1.f);
CheckGlError();
//Vector2f outlineShift = Vector2f(((screenWidth - Application->GetGameLevelScreenWidth())*0.5f), 0.f);
Renderer->PushMatrix();
Renderer->TranslateMatrix(Vector3f(offset[0], offset[1], 0));
@ -1016,13 +1031,22 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
color(2) = c;
}
RenderUniform4fv("BrickColor", color.data());
CheckGlError();
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[colorBlockIterator->first.second]);
CheckGlError();
Renderer->DrawTriangleList(colorBlockIterator->second);
CheckGlError();
}
DrawBallInstancingList(blackAndWhite);
CheckGlError();
Renderer->PopMatrix();
@ -1031,10 +1055,14 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
for (iBonus = BonusFallingList.begin(); iBonus != BonusFallingList.end(); ++iBonus)
{
iBonus->Draw();
CheckGlError();
}
Application->EffectsDraw();
CheckGlError();
Renderer->PopShader();
//float LEVEL_VIEWPORT_WIDTH = Application->GetGameLevelScreenWidth();
@ -1047,21 +1075,29 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
Renderer->DrawRect(Vector2f(-xRW * 0.5f, -yRH * 0.5f) + matrixSize + offset,
Vector2f(xRW*0.5f, yRH*0.5f) + matrixSize + offset, Vector2f(0.f, 0.f), Vector2f(1.f, 1.f));
CheckGlError();
const Vector2f wallUpPos1(xlOffset, tSH-ylOffset-uWTW);
const Vector2f wallUpPos2(tSW + xlOffset, tSH-ylOffset);
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[CONST_WALL_UP_TEXTURE]);
Renderer->DrawRect(wallUpPos1, wallUpPos2, Vector2f(0.f, 0.f), Vector2f(1.f, 1.f));
CheckGlError();
const Vector2f wallLeftPos1(xlOffset, lrFBO+ylOffset);
const Vector2f wallLeftPos2(lWTW + xlOffset, tSH-ylOffset-(uWTW*0.68f));
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[CONST_WALL_LEFT_TEXTURE]);
Renderer->DrawRect(wallLeftPos1, wallLeftPos2, Vector2f(0.f, 0.f), Vector2f(1.f, 1.f));
CheckGlError();
const Vector2f wallRightPos1(tSW+xlOffset-rWTW, lrFBO+ylOffset);
const Vector2f wallRightPos2(tSW + xlOffset, tSH-ylOffset-(uWTW*0.68f));
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[CONST_WALL_RIGHT_TEXTURE]);
Renderer->DrawRect(wallRightPos1, wallRightPos2, Vector2f(0.f, 0.f), Vector2f(1.f, 1.f));
CheckGlError();
if (BonusFloorTimer>0.f)
{
@ -1075,6 +1111,8 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
Renderer->DrawRect(wallBonusPos1, wallBonusPos2, Vector2f(0.f, 0.f), Vector2f(1.f, 1.f));
}
CheckGlError();
if (!pause && LevelState != CONST_LEVELSTATE_SNAPSHOTTING)
@ -1089,6 +1127,8 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
drawOutline(screenWidth, screenHeight);
CheckGlError();
if (pause && !renderBufferReady)
{

View File

@ -164,7 +164,7 @@ void TMyApplication::InnerInit()
#ifdef TARGET_WIN32
#ifdef NDEBUG
ST::PathToResources = "resources/";
//ST::PathToResources = "resources/";
ST::PathToResources = "../../../assets/";
#else
ST::PathToResources = "../../../assets/";
@ -179,71 +179,68 @@ void TMyApplication::InnerInit()
ST::PathToResources = "";
#endif
LoadUserProgress();
GetConsole() <<"APP INIT\n";
srand (static_cast<size_t>(time(NULL)));
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");
//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->FrameManager.AddFrameRenderBuffer("LevelBuffer", 256, 256);
//OnDrawSignal.connect(boost::bind(&TGameLoading::Draw, boost::ref(GameLoading)));
Inited = true;
ResourceManager->FontManager.AddFont("arial32", "arial32.png", "arial32.txt");
ResourceManager->FontManager.AddFont("lucon12", "lucon12.png", "lucon12.txt");
ResourceManager->FontManager.PushFont("lucon12");
Renderer->SetOrthoProjection();
Renderer->SetFullScreenViewport();
Application->SetGameLevelScreenScale();
//GameLevel.SetLevelScale();
EffectsInit();
// ------- UI -------
boost::property_tree::json_parser::read_json(ST::PathToResources + "gui_game_pause_menu.json", gamePauseMenuUi);
boost::property_tree::json_parser::read_json(ST::PathToResources + "gui_main_menu.json", galaxyMenuUi);
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");
// ------- UI -------
skipUpdateToUpdateScreen = true;
StateTimer = 0.f;
}
// TESTS of menu
if (Menu.GalaxMenu.InitGalaxyMenu("levels/galaxy_ptree.json")) {
std::cout << "ok" << std::endl;
void TMyApplication::InnerReinitGLResources()
{
RenderLevelSnapshots();
lsparkler.reinitGlResources();
rsparkler.reinitGlResources();
tsparkler.reinitGlResources();
bsparkler.reinitGlResources();
lvlFirework.reinitGlResources();
}
void TMyApplication::RenderLevelSnapshots()
{
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();
}
else {
std::cout << "menu error" << std::endl;
}
Renderer->SwitchToScreen();
Renderer->SetOrthoProjection();
}
void TMyApplication::InnerDeinit()
@ -472,7 +469,7 @@ void TMyApplication::LoadResources()
ResourceManager->FontManager.AddFont("droid_sans14", "droid_sans14_font_bitmap.png", "droid_sans14_font_charmap.txt");
ResourceManager->FontManager.PushFont("droid_sans14");
TryLoadSavedGame();
GetConsole() << "LOAD GAME";
}
@ -534,10 +531,67 @@ void TMyApplication::InnerUpdate(size_t dt)
StateTimer += dt/1000.f;
if (StateTimer >= 1.f)
{
StateTimer -= 1.f;
skipUpdateToUpdateScreen = false;
}
if (skipUpdateToUpdateScreen)
{
return;
}
GetConsole() << "INNER UPDATE";
LoadUserProgress();
GetConsole() << "LOAD SHADERS";
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");
GetConsole() << "ADD FRAMEBUFFER";
ResourceManager->FrameManager.AddFrameRenderBuffer("LevelBuffer", 256, 256);
//OnDrawSignal.connect(boost::bind(&TGameLoading::Draw, boost::ref(GameLoading)));
Inited = true;
Application->SetGameLevelScreenScale();
//GameLevel.SetLevelScale();
GetConsole() << "INIT EFFECTS";
EffectsInit();
// ------- UI -------
GetConsole() << "LOAD JSON UI";
gamePauseMenuUi = SE::ReadJsonFile(ST::PathToResources + "gui_game_pause_menu.json");
galaxyMenuUi = SE::ReadJsonFile(ST::PathToResources + "gui_main_menu.json");
GetConsole() << "INIT MENU";
// TESTS of menu
if (Menu.GalaxMenu.InitGalaxyMenu("levels/galaxy_ptree.json")) {
std::cout << "ok" << std::endl;
}
else {
std::cout << "menu error" << std::endl;
}
GetConsole() << "RENDER SNAPSHOTS";
RenderLevelSnapshots();
GetConsole() << "LOAD RESOURCES";
LoadResources();
GameState = CONST_GAMESTATE_LOADING;
StateTimer = 0.f;
}
GetConsole() << "PRELOADING END";
}
else if (GameState == CONST_GAMESTATE_LOADING)
{
@ -547,6 +601,8 @@ void TMyApplication::InnerUpdate(size_t dt)
StateTimer -= 1.f;
}
GetConsole() << "BEFORE LOADING TEXTURES";
if (TextureNamesToLoad.size() != 0)
{
ResourceManager->TexList.AddTexture(TextureNamesToLoad.begin()->first, TextureNamesToLoad.begin()->second);
@ -557,27 +613,27 @@ void TMyApplication::InnerUpdate(size_t dt)
else
{
Renderer->SwitchToFrameBuffer("LevelBuffer");
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();
// Renderer->SwitchToFrameBuffer("LevelBuffer");
//
// 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();
@ -651,7 +707,7 @@ void TMyApplication::InnerUpdate(size_t dt)
});
pauseBackground->onMoveSignal.connect([this](Vector2f, Vector2f shift, int) {
SE::GetConsole() << shift.norm();
SE::GetConsole() << std::to_string(shift.norm());
if (shift.norm() > 15)
{
GameLevel->TryGoToMenu();
@ -841,7 +897,7 @@ void TMyApplication::GoFromGameToMenu()
TrySaveGame();
DisapplySignalsToGame();
ignoreTapUp = true;
//ignoreTapUp = true;
LoadGalaxyUi();
@ -1013,11 +1069,10 @@ void TMyApplication::EffectsDraw() {
Renderer->TranslateMatrix(Vector3f(offset[0], offset[1], 0));
Renderer->ScaleMatrix(scale);
glPushAttrib(GL_ALL_ATTRIB_BITS);
//glPushAttrib(GL_ALL_ATTRIB_BITS);
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
lsparkler.draw();
rsparkler.draw();
@ -1025,9 +1080,12 @@ void TMyApplication::EffectsDraw() {
bsparkler.draw();
lvlFirework.draw();
glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
Renderer->PopMatrix();
glPopAttrib();
//glPopAttrib();
}
void TMyApplication::hitSpark(std::string direct,Vector2f Pos) {

View File

@ -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;
@ -147,6 +149,10 @@ public:
virtual void OnKeyPress(size_t key);
virtual void InnerInit();
virtual void RenderLevelSnapshots();
virtual void InnerReinitGLResources();
virtual void InnerDeinit();
virtual void InnerDraw();

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.4.1)
set(BOOST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../boost_1_67_0)
set(BOOST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../boost_1_68_0)
set(BOOST_GIL_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/boost-gil-extension)
set(ZIP_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/julienr-libzip-android/jni)
set(LIBPNG_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/libpng_1.4.1_android)

View File

@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
android {
compileSdkVersion 28
buildToolsVersion "28.0.0"
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "fishrungames.DoubleHitBalls"
minSdkVersion 19
@ -46,9 +46,9 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28+'
implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation project(':SalmonEngineAndroid')
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

View File

@ -9,6 +9,7 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.util.Log;
import android.view.GestureDetector;
import android.view.KeyEvent;
import android.view.GestureDetector.SimpleOnGestureListener;
@ -28,6 +29,7 @@ public class GL2JNIActivity extends Activity
@Override
protected void onCreate(Bundle icicle)
{
Log.d("DEBUG", "START ACTIVITY");
super.onCreate(icicle);
@ -65,7 +67,7 @@ public class GL2JNIActivity extends Activity
@Override
protected void onPause()
{
EngineWrapper.CallDestroy();
//EngineWrapper.CallDestroy();
super.onPause();
mView.onPause();
}

View File

@ -1,14 +1,22 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.70'
ext {
compileSdkVersion = 28
targetSdkVersion = 28
kotlin_version = "1.3.10"
supportLibraryVersion = "28.0.0"
}
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0-alpha18'
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong