예제 #1
0
void Fluid2DTextureApp::draw()
{
	// clear out the window with black
	gl::clear( Color( 0, 0, 0 ) ); 
	gl::setMatricesWindow( getWindowWidth(), getWindowHeight() );

	// Update the positions and tex coords
	Rectf drawRect = getWindowBounds();
	int limX = mFluid2D.resX() - 1;
	int limY = mFluid2D.resY() - 1;
	float dx = drawRect.getWidth()/(float)limX;
	float dy = drawRect.getHeight()/(float)limY;
	
	for( int j = 0; j < mFluid2D.resY(); ++j ) {
		for( int i = 0; i < mFluid2D.resX(); ++i ) {
			vec2 P = vec2( i*dx, j*dy );
			vec2 uv = mFluid2D.texCoordAt( i, j );

			int idx = j*mFluid2D.resX() + i;
			mTriMesh->getPositions<2>()[idx] = P;
			mTriMesh->getTexCoords0<2>()[idx] = uv;
			
		}
	}

	mTex->bind();
	gl::bindStockShader( gl::ShaderDef().color().texture() );
	gl::draw( gl::VboMesh::create(*mTriMesh) );
	mTex->unbind();
	
	mParams.draw();	
}
예제 #2
0
void srvlib::renderer::DrawTexture(ci::gl::Texture2dRef image, const glm::ivec2 &size){

  ci::gl::disableDepthRead();
  ci::gl::disableDepthWrite();

  ci::gl::pushMatrices();

  auto vp = ci::gl::getViewport();

  ci::CameraOrtho o;
  o.setOrtho(0.0f, (float)size[0], 0.0f, (float)size[1], (float)0, (float)1);

  ci::gl::setProjectionMatrix(o.getProjectionMatrix());

  ci::gl::setModelMatrix(glm::mat4());
  ci::gl::setViewMatrix(glm::mat4());

  ci::Rectf bounds(0, 0, size[0], size[1]);
  ci::gl::viewport(size);
  image->setTopDown();
  ci::gl::draw(image);
  ci::gl::viewport(vp);

  ci::gl::popMatrices();

  ci::gl::enableDepthRead();
  ci::gl::enableDepthWrite();


}
예제 #3
0
//! initalizes the font texture
void Renderer::initFontTexture()
{
	unsigned char* pixels;
	int width, height;
	ImGui::GetIO().Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
	mFontTexture = gl::Texture::create( pixels, GL_RGBA, width, height, gl::Texture::Format().magFilter(GL_LINEAR).minFilter(GL_LINEAR) );
	ImGui::GetIO().Fonts->ClearTexData();
	ImGui::GetIO().Fonts->TexID = (void *)(intptr_t) mFontTexture->getId();
}
예제 #4
0
void Fluid2DParticlesApp::draw()
{
    // clear out the window with black
    gl::clear( Color( 0, 0, 0 ) );

    gl::color( ColorAf( 1.0f, 1.0f, 1.0f, 0.999f ) );
    float* data = const_cast<float*>( (float*)mFluid2D.rgb().data() );
    Surface32f surf( data, mFluid2D.resX(), mFluid2D.resY(), mFluid2D.resX()*sizeof(Colorf), SurfaceChannelOrder::RGB );


    if ( ! mTex ) {
        mTex = gl::Texture::create( surf );
    } else {
        mTex->update( surf );
    }
    gl::draw( mTex, getWindowBounds() );
    mTex->unbind();
    mParticles.draw();
    mParams.draw();
}
예제 #5
0
void srvlib::renderer::DrawTexture(ci::gl::Texture2dRef image, const glm::ivec2 &eye_size, const glm::ivec2 &draw_size, ci::gl::GlslProgRef shader){

  ci::gl::disableDepthRead();
  ci::gl::disableDepthWrite();

  ci::gl::pushMatrices();

  auto vp = ci::gl::getViewport();

  ci::CameraOrtho o;
  o.setOrtho(0.0f, (float)eye_size[0], 0.0f, (float)eye_size[1], (float)0, (float)1);

  ci::gl::setProjectionMatrix(o.getProjectionMatrix());

  ci::gl::setModelMatrix(glm::mat4());
  ci::gl::setViewMatrix(glm::mat4());

  image->bind();

  if (shader){
    shader->bind();
    shader->uniform("tex0", 0);
  }
  else{
    auto default_shader = ci::gl::getStockShader(ci::gl::ShaderDef().color().lambert());
    default_shader->bind();
  }

  ci::Rectf bounds(0, 0, draw_size[0], draw_size[1]);
  ci::gl::viewport(draw_size);
  ci::gl::drawSolidRect(bounds);// , glm::vec2(0, 0), glm::vec2(1, 1));
  ci::gl::viewport(vp);
  
  image->unbind();

  ci::gl::popMatrices();

  ci::gl::enableDepthRead();
  ci::gl::enableDepthWrite();
}
예제 #6
0
bool ImageButton( const ci::gl::Texture2dRef &texture, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, int frame_padding, const ImVec4& bg_col, const ImVec4& tint_col)
{
	return ImageButton( (void*)(intptr_t) texture->getId(), size, uv0, uv1, frame_padding, bg_col, tint_col );
}
예제 #7
0
// Cinder Helpers
void Image( const ci::gl::Texture2dRef &texture, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col )
{
	Image( (void*)(intptr_t) texture->getId(), size, uv0, uv1, tint_col, border_col );
}