Created
March 29, 2016 07:54
-
-
Save gaborpapp/997a1fb616f2ac09a7f8 to your computer and use it in GitHub Desktop.
ContextSharingTestApp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ContextSharingTestApp | |
cmake_minimum_required( VERSION 2.8 FATAL_ERROR ) | |
set( CMAKE_VERBOSE_MAKEFILE on ) | |
get_filename_component( CINDER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../.." ABSOLUTE ) | |
include( ${CINDER_DIR}/linux/cmake/Cinder.cmake ) | |
project( ContextSharingTest ) | |
get_filename_component( SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../src" ABSOLUTE ) | |
get_filename_component( INC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../include" ABSOLUTE ) | |
if( NOT TARGET cinder${CINDER_LIB_SUFFIX} ) | |
find_package( cinder REQUIRED | |
PATHS ${PROJECT_SOURCE_DIR}/../../../linux/${CMAKE_BUILD_TYPE}/${CINDER_OUT_DIR_PREFIX} | |
$ENV{Cinder_DIR}/linux/${CMAKE_BUILD_TYPE}/${CINDER_OUT_DIR_PREFIX} | |
) | |
endif() | |
# Use PROJECT_NAME since CMAKE_PROJET_NAME returns the top-level project name. | |
set( EXE_NAME ${PROJECT_NAME} ) | |
set( SRC_FILES | |
${SRC_DIR}/ContextSharingTestApp.cpp | |
) | |
add_executable( "${EXE_NAME}" ${SRC_FILES} ) | |
target_include_directories( | |
"${EXE_NAME}" | |
PUBLIC ${INC_DIR} | |
) | |
target_link_libraries( "${EXE_NAME}" cinder${CINDER_LIB_SUFFIX} ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "cinder/app/App.h" | |
#include "cinder/app/RendererGl.h" | |
#include "cinder/gl/gl.h" | |
using namespace ci; | |
using namespace ci::app; | |
using namespace std; | |
class ContextSharingTest : public App | |
{ | |
public: | |
void setup() override; | |
void update() override; | |
protected: | |
app::WindowRef mWindow0; | |
app::WindowRef mWindow1; | |
void draw0(); | |
void draw1(); | |
gl::FboRef mFbo; | |
}; | |
void ContextSharingTest::setup() | |
{ | |
mFbo = gl::Fbo::create( 400, 400 ); | |
mWindow0 = getWindow(); | |
mWindow0->getSignalDraw().connect( std::bind( &ContextSharingTest::draw0, this ) ); | |
mWindow1 = createWindow( Window::Format().size( 400, 400 ) ); | |
mWindow1->getSignalDraw().connect( std::bind( &ContextSharingTest::draw1, this ) ); | |
} | |
void ContextSharingTest::update() | |
{ | |
gl::ScopedFramebuffer fbo( mFbo ); | |
gl::ScopedViewport viewport( mFbo->getSize() ); | |
gl::ScopedMatrices matrices; | |
gl::setMatricesWindow( mFbo->getSize() ); | |
gl::clear( Color( 0, 1, 0 ) ); | |
gl::ScopedColor color( Color::white() ); | |
gl::drawSolidCircle( vec2( 200 ), 100 ); | |
} | |
void ContextSharingTest::draw0() | |
{ | |
gl::ScopedViewport viewport( getWindowSize() ); | |
gl::setMatricesWindow( getWindowSize() ); | |
gl::clear( Color( 0, 0, 1 ) ); | |
gl::draw( mFbo->getColorTexture(), getWindowBounds() ); | |
} | |
void ContextSharingTest::draw1() | |
{ | |
gl::ScopedViewport viewport( getWindowSize() ); | |
gl::setMatricesWindow( getWindowSize() ); | |
gl::clear( Color( 1, 0, 0 ) ); | |
gl::draw( mFbo->getColorTexture(), getWindowBounds() ); | |
} | |
CINDER_APP( ContextSharingTest, RendererGl ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment