Permalink
Browse files

Show minimap in helperscreen1

  • Loading branch information...
vlj
vlj committed Jun 22, 2014
1 parent c377bdf commit bb1b039aa36496a9decc3d90bd0d21c19375f096
View
@@ -295,7 +295,7 @@ FrameBuffer* RTT::render(scene::ICameraSceneNode* camera, float dt)
irr_driver->computeCameraMatrix(camera, 512, 512);
unsigned plc = irr_driver->UpdateLightsInfo(camera, dt);
irr_driver->renderScene(camera, plc, glows, dt, false, true);
- FrameBuffer* frame_buffer = irr_driver->getPostProcessing()->render(camera, false);
+ FrameBuffer* frame_buffer = &(irr_driver->getFBO(FBO_COLORS));//irr_driver->getPostProcessing()->render(camera, false);
glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height);
irr_driver->setRTT(NULL);
@@ -17,6 +17,13 @@
#include "states_screens/help_screen_1.hpp"
+
+#include "tracks/quad_graph.hpp"
+
+
+#include "graphics/glwrap.hpp"
+
+
#include "challenges/unlock_manager.hpp"
#include "config/player_manager.hpp"
#include "config/user_config.hpp"
@@ -46,8 +53,37 @@ HelpScreen1::HelpScreen1() : Screen("help1.stkgui")
void HelpScreen1::loadedFromFile()
{
+QuadGraph::create("C:/Users/vljn_000/Documents/GitHub/stk-assets/tracks/hacienda/quads.xml",
+"C:/Users/vljn_000/Documents/GitHub/stk-assets/tracks/hacienda/graph.xml", false);
+
} // loadedFromFile
+
+void HelpScreen1::onUpdate(float dt)
+{
+ core::dimension2du size(512, 512);
+ video::ITexture* oldRTT = NULL;
+ FrameBuffer* newRTT = NULL;
+ QuadGraph::get()->makeMiniMap(size, "minimaptest", video::SColor(127, 255, 255, 255),
+ &oldRTT, &newRTT);
+
+
+ core::rect<s32> dest(10, 10, 522, 522);
+
+ if (oldRTT != NULL)
+ {
+ core::rect<s32> source(core::position2di(0, 0), oldRTT->getOriginalSize());
+ draw2DImage(oldRTT, dest, source, NULL, NULL, true);
+ }
+ else if (newRTT != NULL)
+ {
+ core::rect<s32> source(0, 0, newRTT->getWidth(), newRTT->getHeight());
+ draw2DImageFromRTT(newRTT->getRTT()[0], 512, 512,
+ dest, source, NULL, true);
+ }
+// delete newRTT;
+}
+
// -----------------------------------------------------------------------------
void HelpScreen1::eventCallback(Widget* widget, const std::string& name, const int playerID)
@@ -42,6 +42,7 @@ class HelpScreen1 : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void init() OVERRIDE;
+ virtual void onUpdate(float dt) OVERRIDE;
};
#endif
@@ -970,6 +970,7 @@ int QuadGraph::findOutOfRoadSector(const Vec3& xyz,
//-----------------------------------------------------------------------------
/** Takes a snapshot of the driveline quads so they can be used as minimap.
*/
+static RTT* newRttProvider = NULL;
void QuadGraph::makeMiniMap(const core::dimension2du &origdimension,
const std::string &name,
const video::SColor &fill_color,
@@ -981,15 +982,15 @@ void QuadGraph::makeMiniMap(const core::dimension2du &origdimension,
const core::dimension2du dimension = origdimension * 2;
- RTT* newRttProvider = NULL;
+
IrrDriver::RTTProvider* oldRttProvider = NULL;
- if (irr_driver->isGLSL())
+ if (!newRttProvider)
{
newRttProvider = new RTT(512, 512);
}
else
{
- oldRttProvider = new IrrDriver::RTTProvider(dimension, name, true);
+ //oldRttProvider = new IrrDriver::RTTProvider(dimension, name, true);
}
video::SColor red(128, 255, 0, 0);
@@ -1070,7 +1071,7 @@ void QuadGraph::makeMiniMap(const core::dimension2du &origdimension,
frame_buffer = newRttProvider->render(camera, GUIEngine::getLatestDt());
// TODO: leak
- //delete newRttProvider;
+
}
else
{

0 comments on commit bb1b039

Please sign in to comment.