Esempio n. 1
0
int main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
	glutInitWindowSize(1024, 768);
	glutInitWindowPosition(100, 100);
	glutCreateWindow("Week 3");

	InitializeGlutCallback();

	GLenum res = glewInit();
	if (res != GLEW_OK)
	{
		fprintf(stderr, "Error: %s\n", glewGetErrorString(res));
		return 1;
	}

	glClearColor(0.f, 0.f, 0.f, 0.f);

	CreateVertexBuffers();

	CompileShaders();

	glutMainLoop();
	return 0;
}
Esempio n. 2
0
    //
    // Constructor
    //
    CSample03::CSample03( 
                         HINSTANCE Instance, UINT Width, UINT Height, const WCHAR *Caption 
                         ):
        CDemo_GL( Instance, Width, Height, Caption )
    {
        Vec3<float> Eye( 0.0f, 0.0f, 5.0f );
        Vec3<float> At( 0.0f, 0.0f, 0.0f );
        Vec3<float> Up( 0.0f, 1.0f, 0.0f );

        m_View.LookAtRH( Eye, At, Up ); 

        //
        // OpenGL objects
        //

        CreateShaders();
        CreateVertexBuffers();
        CreateIndexBuffers();

        m_OcclusionQuery = new GL::CQuery();

        //
        // App
        //

        m_TrackBall = new UI::CTrackBall( Vec2<float>( m_Width / 2.0f, m_Height / 2.0f ), 250.0f, UI::CTrackBall::RT_TRACKBALL );
    }
Esempio n. 3
0
//------------------------------------------------------------------------------
void
Background2D::Clear()
{
    m_ScrollEntity = NULL;
    m_ScrollPositionStart = Ogre::Vector2::ZERO;
    m_ScrollPositionEnd = Ogre::Vector2::ZERO;
    m_ScrollSeconds = 0;
    m_ScrollCurrentSeconds = 0;
    m_Position = Ogre::Vector2::ZERO;
    m_PositionReal = Ogre::Vector2::ZERO;
    m_range = Ogre::AxisAlignedBox::BOX_INFINITE;
    UnsetScroll();

    for( unsigned int i = 0; i < m_Animations.size(); ++i )
    {
        delete m_Animations[ i ];
    }
    m_Animations.clear();

    for( unsigned int i = 0; i < m_AnimationPlayed.size(); ++i )
    {
        for( unsigned int j = 0; j < m_AnimationPlayed[ i ].sync.size(); ++j )
        {
            ScriptManager::getSingleton().ContinueScriptExecution( m_AnimationPlayed[ i ].sync[ j ] );
        }
    }
    m_AnimationPlayed.clear();

    m_Tiles.clear();
    DestroyVertexBuffers();
    CreateVertexBuffers();
}
Esempio n. 4
0
//------------------------------------------------------------------------------
Background2D::Background2D():
    m_AlphaMaxVertexCount( 0 ),
    m_AddMaxVertexCount( 0 ),

    m_ScrollEntity( NULL ),
    m_ScrollPositionStart( Ogre::Vector2::ZERO ),
    m_ScrollPositionEnd( Ogre::Vector2::ZERO ),
    m_ScrollType( Background2D::NONE ),
    m_ScrollSeconds( 0 ),
    m_ScrollCurrentSeconds( 0 ),
    m_Position( Ogre::Vector2::ZERO ),
    m_PositionReal( Ogre::Vector2::ZERO )

   ,m_range( Ogre::AxisAlignedBox::BOX_INFINITE )
    // for ffvii
   ,m_virtual_screen_size( 320, 240 )
{
    m_SceneManager = Ogre::Root::getSingleton().getSceneManager( "Scene" );
    m_RenderSystem = Ogre::Root::getSingletonPtr()->getRenderSystem();

    CreateVertexBuffers();

    m_AlphaMaterial = Ogre::MaterialManager::getSingleton().create( "Background2DAlpha", "General" );
    Ogre::Pass* pass = m_AlphaMaterial->getTechnique( 0 )->getPass( 0 );
    pass->setVertexColourTracking( Ogre::TVC_AMBIENT );
    pass->setCullingMode( Ogre::CULL_NONE );
    pass->setDepthCheckEnabled( true );
    pass->setDepthWriteEnabled( true );
    pass->setLightingEnabled( false );
    pass->setSceneBlending( Ogre::SBT_TRANSPARENT_ALPHA );
    pass->setAlphaRejectFunction( Ogre::CMPF_GREATER );
    pass->setAlphaRejectValue( 0 );
    Ogre::TextureUnitState* tex = pass->createTextureUnitState();
    tex->setTextureName( "system/blank.png" );
    tex->setNumMipmaps( -1 );
    tex->setTextureFiltering( Ogre::TFO_NONE );

    m_AddMaterial = Ogre::MaterialManager::getSingleton().create( "Background2DAdd", "General" );
    pass = m_AddMaterial->getTechnique( 0 )->getPass( 0 );
    pass->setVertexColourTracking( Ogre::TVC_AMBIENT );
    pass->setCullingMode( Ogre::CULL_NONE );
    pass->setDepthCheckEnabled( true );
    pass->setDepthWriteEnabled( true );
    pass->setLightingEnabled( false );
    pass->setSceneBlending( Ogre::SBT_ADD );
    pass->setAlphaRejectFunction( Ogre::CMPF_GREATER );
    pass->setAlphaRejectValue( 0 );
    tex = pass->createTextureUnitState();
    tex->setTextureName( "system/blank.png" );
    tex->setNumMipmaps( -1 );
    tex->setTextureFiltering( Ogre::TFO_NONE );

    m_SceneManager->addRenderQueueListener( this );
}
Esempio n. 5
0
//--------------------------------------------------------------------------------------
//
// OnCreateDevice
//
// Called when the device is created to create resources for hair rendering
//
//--------------------------------------------------------------------------------------
HRESULT TressFXRenderer::OnCreateDevice(ID3D11Device* pd3dDevice, int winWidth, int winHeight, bool bShortCutOn)
{
    HRESULT hr;

    AMD_V_RETURN(CreateShaderAndLayout(pd3dDevice));
    AMD_V_RETURN(CreateTextureAndViews(pd3dDevice));
    AMD_V_RETURN(CreateConstantBuffer(pd3dDevice));
    AMD_V_RETURN(CreateVertexBuffers(pd3dDevice));
    AMD_V_RETURN(CreateRenderStateObjects(pd3dDevice));

    if (bShortCutOn)
    {
        m_ShortCut.OnCreateDevice(pd3dDevice, winWidth, winHeight);
    }
    else
    {
        AMD_V_RETURN(CreatePPLL(pd3dDevice, winWidth, winHeight, false));
    }

    return S_OK;
}