Ejemplo n.º 1
0
 void Graphics::SetActiveRenderTarget(RenderTarget* aRenderTarget)
 {
     //Safety check that the render target isn't null and that it isn't already set
     if(aRenderTarget != m_ActiveRenderTarget)
     {
         //Safety check the active render target and unbind it
         if(m_ActiveRenderTarget != nullptr)
         {
             m_ActiveRenderTarget->Unbind();
         }
         
         //Set the active render target
         m_ActiveRenderTarget = aRenderTarget;
         
         //Safety check the newly active render target
         if(m_ActiveRenderTarget != nullptr)
         {
             //And bind it
             m_ActiveRenderTarget->Bind();
             
             //Set the viewport size to match the render target's size
             SetViewportSize(m_ActiveRenderTarget->GetWidth(), m_ActiveRenderTarget->GetHeight());
             Log(VerbosityLevel_Graphics, "Set active render target: (%i, %i)", m_ActiveRenderTarget->GetWidth(), m_ActiveRenderTarget->GetHeight());
         }
         else
         {
             #if !TARGET_OS_IPHONE
             SetViewportSize(m_Width, m_Height);
             SetClearColor(m_ClearColor);
             #endif
         }
     }
 }
Ejemplo n.º 2
0
void rwxGLView::PrepareToDraw(){
    InitSharedContextIfNecessary(this);
    SetCurrent(*sharedContext);
    InitGraphicsDeviceIfNecessary();
    SetViewportSize();

    m_engine->GraphicsDevice()->Clear();
    m_engine->GraphicsDevice()->SetActiveViewport(&m_viewport);
}
Ejemplo n.º 3
0
 void Graphics::Resize(int aWidth, int aHeight)
 {
     #if TARGET_OS_IPHONE
     //We need to create a new frame buffer since is resized
     m_MainRenderTarget->DestroyFrameBuffer();
     m_MainRenderTarget->CreateFrameBuffer();
     
     //If the assert is hit, the render target's frame buffer was NOT the size we expected to resize to
     assert(m_MainRenderTarget->GetWidth() == aWidth && m_MainRenderTarget->GetHeight() == aHeight);
     #else
     m_Width = aWidth;
     m_Height = aHeight;
     #endif
     
     Log(VerbosityLevel_Graphics, "Resize back buffer (%i, %i)", aWidth, aHeight);
     
     //Lastly set the viewport size
     SetViewportSize(aWidth, aHeight);
 }
Ejemplo n.º 4
0
Camera::Camera(float width, float height, glm::vec3 initialPosition, glm::vec3 initialRotation, float fov, float nearClip, float farClip)
:Transform(initialPosition, initialRotation), camFOV(fov), camFarClip(farClip), camNearClip(nearClip)
{
  SetViewportSize(width, height);
  CalculateViewMatrix();
}