コード例 #1
0
ファイル: gpuPSApp.cpp プロジェクト: flcc/gpuPS
void gpuPSApp::draw()
{
	gl::setMatrices( mCam );
	gl::setViewport( getWindowBounds() );
	gl::clear( ColorA( 0.0f, 0.0f, 0.0f, 1.0f ) );
	
	mFBO[mCurrentFBO].bindTexture(0,0);
	mDisplShader.bind();
	mDisplShader.uniform("displacementMap", 0 );
	gl::pushModelView();
	gl::translate( Vec3f( 0.0f, 0.0f, getWindowHeight() / 2.0f ) );
	gl::rotate( mArcball.getQuat() );
	gl::draw( mVboMesh );
    gl::popModelView();
	
	mDisplShader.unbind();
	mFBO[mCurrentFBO].unbindTexture();
	
	gl::setMatricesWindow(getWindowSize());
	gl::drawString( toString( SIDE*SIDE ) + " vertices", Vec2f(32.0f, 32.0f));
	gl::drawString( toString((int) getAverageFps()) + " fps", Vec2f(32.0f, 52.0f));
}
コード例 #2
0
ファイル: ArcballDemoApp.cpp プロジェクト: AKS2346/Cinder
void ArcballDemoApp::draw()
{
	gl::clear( Color( 0, 0.1f, 0.2f ) );

	if( mDrawVerbose )
		drawVerbose();
	else {
		// the order of operations is important here - we don't want the rotation applied to the scale
		// and likewise, we don't want the translation applied to the scale 
		// So the code below:
		// 1) rotates the cube by the quaternion that arcball has provided
		// 2) scales the cube to be 200 pixels big
		// 3) moves the cube to the center of the window
		gl::pushModelView();
			glCullFace( GL_BACK );
			gl::translate( getWindowSize() / 2.0f );
			gl::scale( Vec3f( 200.0f, 200.0f, 200.0f ) );	
			gl::rotate( mArcball.getQuat() );
			gl::drawColorCube( Vec3f::zero(), Vec3f( 1, 1, 1 ) );
		gl::popModelView();		
	}
}
コード例 #3
0
void wellingtonModelApp::draw()
{
    
    gl::enableDepthRead();
    gl::enableDepthWrite();
    gl::enableAlphaBlending();
    
    // clear out the window with black
	gl::clear( Color( 0, 0, 0 ) );
    
    /*
     if(mWaterModule != NULL){
     gl::pushMatrices();
     mWaterModule->draw();
     gl::popMatrices();
     }
     */
    
    
//    /*
    gl::setMatrices( mMayaCam.getCamera());
    
    gl::pushMatrices();
    myImage.enableAndBind();
    gl::rotate( mArcball.getQuat() );
    gl::scale(Vec3f(0.035,0.035,0.035));
    glLineWidth(0.3f);
    gl::enableWireframe();
    gl::rotate(Vec3f(50.0, -20.0, 0.0));
    gl::draw(mVbo);
    myImage.unbind();
    gl::popMatrices();
     
//     */
    
 
    
}
コード例 #4
0
ファイル: OBJLoaderApp.cpp プロジェクト: alexbw/Cinder
void ObjLoaderApp::draw()
{
	gl::enableDepthWrite();
	gl::enableDepthRead();
	
	gl::clear( Color( 0.0f, 0.1f, 0.2f ) );
	glDisable( GL_CULL_FACE );

	gl::setMatrices( mMayaCam.getCamera() );

/*	Sphere boundingSphere = Sphere::calculateBoundingSphere( mMesh.getVertices() );
	glColor3f( 1.0f, 1.0f, 1.0f );
	gl::disableDepthWrite();
	mTexture->disable();
	mShader.unbind();
	gl::draw( boundingSphere, 30 );
	gl::enableDepthWrite();
*/
	mShader.bind();
	gl::pushMatrices();
		gl::rotate( mArcball.getQuat() );
		gl::draw( mVBO );
	gl::popMatrices();
}
コード例 #5
0
ファイル: testBrown2.cpp プロジェクト: guendas/cncsvision
void drawErnstBanks(double height)
{
	glLoadIdentity();
	glTranslated(0.0,0,Z);
	arcball.applyRotationMatrix();

	// print top sector
	glPushMatrix();
	glTranslated(0, (150+height)/4.0, 0);
	draw_ernst_banks[0].draw();
	glPopMatrix();

	// print bottom sector
	glPushMatrix();
	glTranslated(0, -(150+height)/4.0, 0);
	draw_ernst_banks[1].draw();
	glPopMatrix();

	// print relief
	glPushMatrix();
	glTranslated(0, 0, 0);
	draw_ernst_banks[2].draw();
	glPopMatrix();
}
コード例 #6
0
void BasicShaderIIApp::mouseDown( MouseEvent event )
{
    mArcball.mouseDown( event.getPos() );    
}
コード例 #7
0
void fsExperiments::resize( ResizeEvent event )
{
	mArcball.setWindowSize( getWindowSize() );
	mArcball.setCenter( getWindowCenter() );
	mArcball.setRadius( 150 );
}
コード例 #8
0
void fsExperiments::mouseDrag( MouseEvent event )
{
	mArcball.mouseDrag( event.getPos() );
}
コード例 #9
0
ファイル: basicApp.cpp プロジェクト: ChristophPacher/Cinder
void BasicApp::mouseDrag( MouseEvent event )
{
	mArcball.mouseDrag( event.getPos() );
}
コード例 #10
0
ファイル: ArcballDemoApp.cpp プロジェクト: AKS2346/Cinder
void ArcballDemoApp::mouseDrag( MouseEvent event )
{
	mArcball.mouseDrag( event.getPos() );
	mCurrentMouseDown = event.getPos();
}
コード例 #11
0
void CinderProjectionTestApp::mouseDrag( MouseEvent event )
{
	mArcball.mouseDrag( event.getPos() );
}
コード例 #12
0
ファイル: main.cpp プロジェクト: cirocosta/Arcball
int main(int argc, const char * argv[]) {
    if( !glfwInit() ) {
        cerr << "Unable to initialize glfw" << endl;
        return false;
    }
    
    /* Tell GLFW to use OpenGL 4.1 */
    glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 4 );
    glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 1 );
    glfwWindowHint( GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE );
    glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );
    
    GLFWwindow * window = glfwCreateWindow( WINDOW_WIDTH, WINDOW_HEIGHT, "Arcball", NULL, NULL );
    if ( !window ) {
        cerr << "Unable to create glfw window" << endl;
        glfwTerminate();
        return false;
    }
    
    glfwMakeContextCurrent( window );
    glfwSetInputMode( window, GLFW_STICKY_KEYS, GL_TRUE );
    
    cout << "OpenGL Ver: " << glGetString( GL_VERSION ) << endl;
    
	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    
    glShadeModel( GL_SMOOTH );
    glEnable( GL_DEPTH_TEST );
    glDepthFunc( GL_LESS );
    
    glFrontFace( GL_CCW );
    glEnable( GL_CULL_FACE );
    glCullFace( GL_BACK );
    
    /* Set the callback functions */
    glfwSetErrorCallback( errorCallback );
    glfwSetScrollCallback( window, scrollCallback );
    glfwSetKeyCallback( window, keyCallback );
    glfwSetFramebufferSizeCallback( window, frameBufferSizeCallback );
    glfwSetCursorPosCallback( window, cursorCallback );
    glfwSetMouseButtonCallback( window, mouseButtonCallback );
    
    GLuint vertex_array_id;
    glGenVertexArrays( 1, &vertex_array_id );
    glBindVertexArray( vertex_array_id );
    
    Shader shader( "simpleLighting.vsh", "simpleLighting.fsh" );
    GLuint cube_buffers[2];
    glGenBuffers( 2, cube_buffers );
    glBindBuffer( GL_ARRAY_BUFFER, cube_buffers[0] );
    glBufferData( GL_ARRAY_BUFFER, sizeof(glm::vec3) * cube_buffer_data.size(), &cube_buffer_data[0], GL_STATIC_DRAW );
    glBindBuffer( GL_ARRAY_BUFFER, cube_buffers[1] );
    glBufferData( GL_ARRAY_BUFFER, sizeof(glm::vec3) * cube_normals_data.size(), &cube_normals_data[0], GL_STATIC_DRAW );

    GLuint floor_buffers[2];
    glGenBuffers( 2, floor_buffers );
    glBindBuffer( GL_ARRAY_BUFFER, floor_buffers[0] );
    glBufferData( GL_ARRAY_BUFFER, sizeof(glm::vec3) * floor_buffer_data.size(), &floor_buffer_data[0], GL_STATIC_DRAW );
    glBindBuffer( GL_ARRAY_BUFFER, floor_buffers[1] );
    glBufferData( GL_ARRAY_BUFFER, sizeof(glm::vec3) * floor_normals_data.size(), &floor_normals_data[0], GL_STATIC_DRAW );

    glm::mat4 model      = glm::mat4(1.0);
    glm::mat4 view       = glm::lookAt( glm::vec3(0.0f, 0.0f, 3.0f), glm::vec3(0., 0., 0.), glm::vec3(0., 1., 0.) );
    glm::mat4 projection = glm::perspective(70.0f, 4.0f/3.0f, 0.1f, 100.0f );
    
    glm::vec3 light_position = glm::vec3( 4, 4, 4 );
    
    shader.bind();
    shader.setUniform( "light_position_w", light_position );
    
    while( !glfwWindowShouldClose( window )){
        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
        
        { /* Draw on 1st viewport, show rotation of the camera */
            glViewport( 0, 0, WINDOW_WIDTH / 2, WINDOW_HEIGHT );
            
            glm::mat4 rotated_view = view * arcball.createViewRotationMatrix();
            glm::mat4 mvp = projection * rotated_view * model;
            
            shader.setUniform( "light_color", glm::vec3(1.0, 1.0, 0.0) );
            shader.setUniform( "v", rotated_view );
            shader.setUniform( "m", model );
            shader.setUniform( "mvp", mvp );
            
            /* Draw cube */
            glEnableVertexAttribArray( 0 );
            glBindBuffer( GL_ARRAY_BUFFER, cube_buffers[0] );
            glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, 0, (void*) 0 );
            
            glEnableVertexAttribArray( 1 );
            glBindBuffer( GL_ARRAY_BUFFER, cube_buffers[1] );
            glVertexAttribPointer( 1, 3, GL_FLOAT, GL_FALSE, 0, (void*) 0 );
            
            glEnable( GL_CULL_FACE );
            glDrawArrays( GL_TRIANGLE_STRIP, 0, static_cast<int>(cube_buffer_data.size()) );
            
            
            /* Draw the floor, with different color */
            shader.setUniform( "light_color", glm::vec3(0.0, 1.0, 1.0) );
            glEnableVertexAttribArray( 0 );
            glBindBuffer( GL_ARRAY_BUFFER, floor_buffers[0] );
            glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, 0, (void*) 0 );
            
            glEnableVertexAttribArray( 1 );
            glBindBuffer( GL_ARRAY_BUFFER, floor_buffers[1] );
            glVertexAttribPointer( 1, 3, GL_FLOAT, GL_FALSE, 0, (void*) 0 );
            
            glDisable( GL_CULL_FACE );
            glDrawArrays( GL_TRIANGLE_STRIP, 0, static_cast<int>(floor_buffer_data.size()) );
        }
        
        { /* Draw on 2nd viewport, show rotation of the model */
            glViewport( WINDOW_WIDTH / 2, 0, WINDOW_WIDTH / 2, WINDOW_HEIGHT );
            
            glm::mat4 rotated_model = model * arcball.createModelRotationMatrix( view );
            glm::mat4 mvp = projection * view * rotated_model;
            
            shader.setUniform( "light_color", glm::vec3(1.0, 1.0, 0.0) );
            shader.setUniform( "v", view );
            shader.setUniform( "m", rotated_model );
            shader.setUniform( "mvp", mvp );
            
            /* Draw cube */
            glEnableVertexAttribArray( 0 );
            glBindBuffer( GL_ARRAY_BUFFER, cube_buffers[0] );
            glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, 0, (void*) 0 );
            
            glEnableVertexAttribArray( 1 );
            glBindBuffer( GL_ARRAY_BUFFER, cube_buffers[1] );
            glVertexAttribPointer( 1, 3, GL_FLOAT, GL_FALSE, 0, (void*) 0 );
            
            glEnable( GL_CULL_FACE );
            glDrawArrays( GL_TRIANGLE_STRIP, 0, static_cast<int>(cube_buffer_data.size()) );
            
            /* Draw the floor, with different color */
            shader.setUniform( "light_color", glm::vec3(0.0, 1.0, 1.0) );
            glEnableVertexAttribArray( 0 );
            glBindBuffer( GL_ARRAY_BUFFER, floor_buffers[0] );
            glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, 0, (void*) 0 );
            
            glEnableVertexAttribArray( 1 );
            glBindBuffer( GL_ARRAY_BUFFER, floor_buffers[1] );
            glVertexAttribPointer( 1, 3, GL_FLOAT, GL_FALSE, 0, (void*) 0 );
            
            glDisable( GL_CULL_FACE );
            glDrawArrays( GL_TRIANGLE_STRIP, 0, static_cast<int>(floor_buffer_data.size()) );
        }
        
        
        glfwSwapBuffers( window );
        glfwPollEvents();
    }
    
    shader.unbind();
    
    glDeleteBuffers( 2, cube_buffers );
    glDeleteBuffers( 2, floor_buffers );
    glDeleteVertexArrays( 1, &vertex_array_id );
    
    return 0;
}
コード例 #13
0
ファイル: main.cpp プロジェクト: cirocosta/Arcball
void mouseButtonCallback( GLFWwindow * window, int button, int action, int mods ){
    /* Pass the arguments to our arcball object */
    arcball.mouseButtonCallback( window, button, action, mods );
}
コード例 #14
0
void camerasApp::resize()
{
	mArcball.setWindowSize( getWindowSize() );
	mArcball.setCenter( getWindowCenter() );
	mArcball.setRadius( 150 );
}
コード例 #15
0
ファイル: ArcballDemoApp.cpp プロジェクト: alexbw/Cinder
void ArcballDemoApp::resize( int width, int height )
{
	mArcball.setWindowSize( getWindowSize() );
	mArcball.setCenter( getWindowCenter() );
	mArcball.setRadius( 150 );
}
コード例 #16
0
ファイル: gpuPSApp.cpp プロジェクト: flcc/gpuPS
void gpuPSApp::mouseDrag( MouseEvent event )
{
    mArcball.mouseDrag( event.getPos() );
}
コード例 #17
0
void CinderProjectionTestApp::draw()
{
	
	// clear out the window with black
	gl::clear( Color( 0, 0, 0 ), true );
	
	
	gl::enableDepthRead();
	gl::enableDepthWrite();
	
	//gl::enableAlphaBlending();
	
	
	if ( mActiveCam == CAM_LOOK )
	{
		gl::setMatrices( mLookCam );
		gl::rotate( mArcball.getQuat() );
	}
	else if ( mActiveCam == CAM_SWEET )
		gl::setMatrices( mSweetCam );
	else if ( mActiveCam == CAM_PROJ )
		gl::setMatrices( mProjCam );
	
	// Green = Cam from 'sweet spot'
	gl::color( Color( 0, 1, 0 ) );
	gl::drawFrustum( mSweetCam );
	
	// Cyan = Cam from projector
	gl::color( Color( 0, 1, 1 ) );
	gl::drawFrustum( mProjCam );
	
	// Draw a grid in the yz plane
	gl::color( Color( 0.2f, 0.2f, 0.2f ) );
	gl::pushMatrices();
	gl::scale(Vec3f::one() /5 );
	for (int i=0; i<=20; ++i)
	{
		gl::drawLine(Vec3f(-100.0f+(i*10.0f), 0.0f, -100.0f),Vec3f(-100.0f+(i*10.0f), 0.0f, 100.0f));
		gl::drawLine(Vec3f(-100.0f, 0.0f, -100.0f+(i*10.0f)),Vec3f(100.0f, 0.0f, -100.0f+(i*10.0f)));
	}
	gl::popMatrices();
	
	gl::color( Color::white() );
	
	//glEnable( GL_LIGHTING );
	//glEnable( GL_LIGHT0 );
	//GLfloat light_position[] = { mMousePos.x, mMousePos.y, 75.0f, 1.0f };
	//glLightfv( GL_LIGHT0, GL_POSITION, light_position );
	
	
	// Bind texture, so it will be avaible to the fragment shader.
	mTexture.bind();
    // Bind the texture projection shader, let the magic happen!
    mProjShader.bind();
    
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    mProjShader.uniform("projMap", 0);
    mProjShader.uniform("TexGenMat", mSweetCam.getProjectionMatrix() );
    mProjShader.uniform("InvViewMat", mProjCam.getInverseModelViewMatrix() );
	mProjShader.uniform("texScaling", mTextureScaling );
	//mProjShader.uniform("alpha", 0.6f );
    //mProjShader.uniform("scaling", 10.0f );
	
	gl::pushModelView();
	//gl::rotate( Vec3f( 0.0f, 45.0f, 0.0f ) );
	gl::rotate( mCubeRotation );
	gl::translate( Vec3f(0.0f, 0.5f * mCubeSize, 0.0f) );
	gl::drawColorCube( Vec3f::zero(), Vec3f::one() * mCubeSize );
	gl::popModelView();
	
	
    
    mProjShader.unbind();
	mTexture.unbind();
	
	glDisable( GL_LIGHTING );
	
	gl::color( Color::white() );
	
	
	// Draw the interface
	params::InterfaceGl::draw();
}
コード例 #18
0
ファイル: main.cpp プロジェクト: cirocosta/Arcball
void cursorCallback( GLFWwindow *window, double x, double y ) {
    /* Pass the arguments to our arcball object */
    arcball.cursorCallback( window, x, y );
}
コード例 #19
0
ファイル: ArcballDemoApp.cpp プロジェクト: AKS2346/Cinder
void ArcballDemoApp::resize()
{
	mArcball.setWindowSize( getWindowSize() );
	mArcball.setCenter( getWindowCenter() );
	mArcball.setRadius( 150 );
}
コード例 #20
0
void ImageHFApp::mouseDrag( MouseEvent event )
{
    mArcball.mouseDrag( event.getPos() );
}
コード例 #21
0
ファイル: ArcballDemoApp.cpp プロジェクト: AKS2346/Cinder
void ArcballDemoApp::mouseDown( MouseEvent event )
{
	mArcball.mouseDown( event.getPos() );
	mCurrentMouseDown = mInitialMouseDown = event.getPos();
}
コード例 #22
0
ファイル: testBrown2.cpp プロジェクト: guendas/cncsvision
void mouseDrag(int _x, int _y)
{

    arcball.updateRotation(_x,_y);
    glutPostRedisplay();
}
コード例 #23
0
ファイル: OBJLoaderApp.cpp プロジェクト: AKS2346/Cinder
void ObjLoaderApp::resize()
{
	mArcball.setWindowSize( getWindowSize() );
	mArcball.setCenter( Vec2f( getWindowWidth() / 2.0f, getWindowHeight() / 2.0f ) );
	mArcball.setRadius( 150 );
}