Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed rendering bug with new resize callback. Added cloud rendering c…

…lass for cloud rendering.
  • Loading branch information...
commit f5e53d274049845d8bbef8e6582eeb9238d0f60f 1 parent 9baeac5
@ptierney authored
View
2  include/Resources.h
@@ -14,3 +14,5 @@
#define RES_VM_FONT CINDER_RESOURCE(../resources/, GothamRounded-Book.ttf, 140, TTF)
#define RES_VM_FONT_BOLD CINDER_RESOURCE(../resources/, GothamRounded-Medium.ttf, 141, TTF)
+
+#define RES_CLOUD_PHOTO CINDER_RESOURCE(../resources/, h_crop.png, 142, IMAGE)
View
33 include/adj/adj_CloudBackground.h
@@ -0,0 +1,33 @@
+
+#pragma once
+
+#include <cinder/Surface.h>
+#include <cinder/gl/gl.h>
+#include <cinder/gl/Texture.h>
+
+namespace adj {
+
+class CloudBackground {
+public:
+ static CloudBackground& instance();
+ static void cleanup();
+
+ void draw();
+
+ void resize_photos();
+
+private:
+ CloudBackground();
+ void init();
+
+ static CloudBackground* instance_;
+
+ ci::Surface cloud_photo_;
+ ci::Surface resized_photo_;
+ ci::gl::Texture cloud_texture_;
+
+ int height_offset_;
+};
+
+
+}
View
2  include/adj/adj_Visualizer.h
@@ -27,12 +27,14 @@ class Visualizer {
bool mouse_drag(ci::app::MouseEvent);
bool key_down(ci::app::KeyEvent);
+ bool resize(ci::app::ResizeEvent);
private:
void add_node();
ci::CallbackId mouse_drag_cb_id_;
ci::CallbackId key_cb_id_;
+ ci::CallbackId resize_id_;
};
}
View
77 src/adj/adj_CloudBackground.cpp
@@ -0,0 +1,77 @@
+
+#include <cinder/app/App.h>
+#include <cinder/ImageIo.h>
+#include <cinder/Surface.h>
+#include <cinder/gl/gl.h>
+#include <cinder/gl/Texture.h>
+#include <cinder/ip/Resize.h>
+
+#include <AdjApp.h>
+#include <adj/adj_CloudBackground.h>
+#include <adj/adj_NowPlayingHeadline.h>
+
+#include <Resources.h>
+
+namespace adj {
+
+CloudBackground* CloudBackground::instance_ = NULL;
+
+
+CloudBackground::CloudBackground() {
+
+}
+
+void CloudBackground::init() {
+ try {
+ cloud_photo_ = ci::loadImage(ci::app::loadResource(RES_CLOUD_PHOTO));
+ } catch (...) {
+ ci::app::console() << "Unable to load cloud." << std::endl;
+ AdjApp::instance().quit();
+ }
+
+ resize_photos();
+}
+
+void CloudBackground::resize_photos() {
+ height_offset_ = NowPlayingHeadline::instance().size().y;
+
+ int photo_width = cloud_photo_.getWidth();
+ int photo_height = cloud_photo_.getHeight();
+
+ int target_height = AdjApp::instance().getWindowHeight() - height_offset_;
+
+ resized_photo_ = ci::ip::resizeCopy(cloud_photo_,
+ ci::Area(0, 0, photo_width, photo_height), ci::Vec2i(
+ static_cast<float>(target_height) /
+ static_cast<float>(photo_height) * static_cast<float>(photo_width),
+ target_height));
+
+ cloud_texture_ = ci::gl::Texture(resized_photo_);
+}
+
+void CloudBackground::draw() {
+ ci::gl::color(ci::ColorA(1.0, 1.0, 1.0, 0.5));
+
+ ci::gl::draw(cloud_texture_, ci::Vec2f(0, height_offset_));
+}
+
+
+
+CloudBackground& CloudBackground::instance() {
+ if (instance_ == NULL) {
+ instance_ = new CloudBackground();
+ instance_->init();
+ }
+
+ return *instance_;
+}
+
+void CloudBackground::cleanup() {
+ if (instance_ == NULL)
+ return;
+
+ delete instance_;
+}
+
+
+}
View
5 src/adj/adj_Renderer.cpp
@@ -17,6 +17,7 @@
#include <adj/adj_GraphNode.h>
#include <adj/adj_GraphicItem.h>
#include <adj/adj_NodeMover.h>
+#include <adj/adj_CloudBackground.h>
namespace adj {
@@ -47,7 +48,7 @@ Renderer::Renderer() {
color_palette_.push_back(ci::ColorA(196.f / 255.f, 38.f / 255.f,
46.f / 255.f, 1.f));
- background_color_ = ci::Color::white();
+ background_color_ = ci::Color::black();
network_color_ = ci::Color::black();
}
@@ -65,6 +66,8 @@ void Renderer::draw() {
ci::gl::setMatricesWindow(AdjApp::instance().getWindowSize());
ci::gl::clear(background_color_);
+ CloudBackground::instance().draw();
+
ci::gl::pushMatrices();
Camera::instance().transform_draw();
View
11 src/adj/adj_Visualizer.cpp
@@ -16,6 +16,7 @@
#include <adj/adj_NowPlayingHeadline.h>
#include <adj/adj_DJController.h>
#include <adj/adj_NodeMover.h>
+#include <adj/adj_CloudBackground.h>
//#include <adj/adj_SocialConnector.h>
@@ -28,6 +29,7 @@ Visualizer::Visualizer() {
Visualizer::~Visualizer() {
AdjApp::instance().unregisterMouseDrag(mouse_drag_cb_id_);
AdjApp::instance().unregisterKeyDown(key_cb_id_);
+ AdjApp::instance().unregisterResize(resize_id_);
}
void Visualizer::setup() {
@@ -35,6 +37,8 @@ void Visualizer::setup() {
this, &Visualizer::mouse_drag);
key_cb_id_ = AdjApp::instance().registerKeyDown(this,
&Visualizer::key_down);
+ resize_id_ = AdjApp::instance().registerResize(this,
+ &Visualizer::resize);
Renderer::instance().setup();
Camera::instance().setup();
@@ -89,6 +93,13 @@ bool Visualizer::mouse_drag(ci::app::MouseEvent) {
return true;
}
+bool Visualizer::resize(ci::app::ResizeEvent) {
+ CloudBackground::instance().resize_photos();
+ Renderer::instance().setup();
+
+ return true;
+}
+
bool Visualizer::key_down(ci::app::KeyEvent key) {
if( key.getChar() == 'f' )
View
BIN  vc10/Resources.rc
Binary file not shown
View
2  vc10/adj.vcxproj
@@ -15,6 +15,7 @@
<ClInclude Include="..\include\adj\adj_Adj.h" />
<ClInclude Include="..\include\adj\adj_CalloutBox.h" />
<ClInclude Include="..\include\adj\adj_Camera.h" />
+ <ClInclude Include="..\include\adj\adj_CloudBackground.h" />
<ClInclude Include="..\include\adj\adj_DJController.h" />
<ClInclude Include="..\include\adj\adj_GraphicItem.h" />
<ClInclude Include="..\include\adj\adj_GraphNode.h" />
@@ -46,6 +47,7 @@
<ClCompile Include="..\src\AdjApp.cpp" />
<ClCompile Include="..\src\adj\adj_CalloutBox.cpp" />
<ClCompile Include="..\src\adj\adj_Camera.cpp" />
+ <ClCompile Include="..\src\adj\adj_CloudBackground.cpp" />
<ClCompile Include="..\src\adj\adj_DJController.cpp" />
<ClCompile Include="..\src\adj\adj_GraphicItem.cpp" />
<ClCompile Include="..\src\adj\adj_GraphNode.cpp" />
View
6 vc10/adj.vcxproj.filters
@@ -126,6 +126,9 @@
<ClInclude Include="..\include\adj\adj_NodeMover.h">
<Filter>Header Files\adj</Filter>
</ClInclude>
+ <ClInclude Include="..\include\adj\adj_CloudBackground.h">
+ <Filter>Header Files\adj</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\AdjApp.cpp">
@@ -215,6 +218,9 @@
<ClCompile Include="..\src\adj\adj_NodeMover.cpp">
<Filter>Source Files\adj</Filter>
</ClCompile>
+ <ClCompile Include="..\src\adj\adj_CloudBackground.cpp">
+ <Filter>Source Files\adj</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Resources.rc">
Please sign in to comment.
Something went wrong with that request. Please try again.