First result

This commit is contained in:
Vladislav Khorev Dev committed 2017-12-22 23:35:11 +05:00
1 parent 9096f79f5a
commit 93e171ec5b
11 files changed
+276 -21

No files matched your search

+42 -13
View File
@@ -7,6 +7,8 @@
#include "include/Engine.h"
#include <boost/property_tree/json_parser.hpp>
TMyApplication* Application;
@@ -34,32 +36,53 @@ void TMyApplication::InnerInit()
srand (static_cast<size_t>(time(NULL)));
ResourceManager->ShaderManager.AddShader("DefaultShader", "texture-shader.vertex", "texture-shader.fragment");
Renderer->PushShader("DefaultShader");
ResourceManager->ShaderManager.AddShader("ColorShader", "color-shader.vertex", "color-shader.fragment");
ResourceManager->ShaderManager.AddShader(ParticleEffect::PARTICLE_SHADER, "particle-shader.vertex", "particle-shader.fragment");
Renderer->PushShader("ColorShader");
ResourceManager->FrameManager.AddFrameRenderBuffer("FrameBuffer", Renderer->GetMatrixWidth(), Renderer->GetMatrixHeight());
float width = Renderer->GetScreenWidth();
float height = Renderer->GetScreenHeight();
Renderer->SetOrthoProjection();
Renderer->PushProjectionMatrix(width, height, -1, 1);
//Renderer->SetFullScreenViewport();
boost::property_tree::ptree JSONsource;
boost::property_tree::json_parser::read_json(ST::PathToResources + "test.json", JSONsource);
sparkler.parse(JSONsource); // parse JSON
sparkler.load(); // load textures
sparkler.setCoords({ width / 2, height / 2, 0 });
}
void TMyApplication::InnerDeinit()
{
}
void TMyApplication::InnerOnTapDown(Vector2f p)
{
}
void TMyApplication::InnerOnTapUp(Vector2f p)
{
}
void TMyApplication::InnerOnTapUpAfterMove(Vector2f p)
void TMyApplication::InnerOnMouseDown(TMouseState& mouseState)
{
if (mouseState.LeftButtonPressed)
{
sparkler.setCoords({ (float)mouseState.X, (float)mouseState.Y, 0 });
}
else if (mouseState.RightButtonPressed)
{
if (sparkler.isSpawning())
{
sparkler.stopSpawn();
}
else
{
sparkler.startSpawn();
}
}
}
void TMyApplication::InnerOnMove(Vector2f p, Vector2f shift)
{
sparkler.setCoords({ p[0], p[1], 0 });
}
void TMyApplication::InnerDraw()
@@ -69,10 +92,16 @@ void TMyApplication::InnerDraw()
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
sparkler.draw();
}
void TMyApplication::InnerUpdate(size_t dt)
{
if (dt > 50)
{
dt = 50;
}
sparkler.update(dt / 1000.f);
}
+3 -5
View File
@@ -39,6 +39,8 @@ extern boost::signals2::signal<void()> OnDrawSignal;
class TMyApplication : public TApplication
{
protected:
ParticleEffect sparkler;
public:
TMyApplication() : TApplication() { }
@@ -50,11 +52,7 @@ public:
virtual void InnerUpdate(size_t dt);
virtual void InnerOnTapDown(Vector2f p);
virtual void InnerOnTapUp(Vector2f p);
virtual void InnerOnTapUpAfterMove(Vector2f p);
virtual void InnerOnMouseDown(TMouseState& mouseState);
virtual void InnerOnMove(Vector2f p, Vector2f shift);