// --------------------------------------------------------------------------
// UnityRenderEvent
// This will be called for GL.IssuePluginEvent script calls; eventID will
// be the integer passed to IssuePluginEvent.
/// @todo does this actually need to be exported? It seems like
/// GetRenderEventFunc returning it would be sufficient...
void UNITY_INTERFACE_API OnRenderEvent(int eventID) {
    // Unknown graphics device type? Do nothing.
    if (!s_deviceType) {
        return;
    }

    switch (eventID) {
    // Call the Render loop
    case kOsvrEventID_Render:
        DoRender();
        break;
    case kOsvrEventID_Shutdown:
        break;
    case kOsvrEventID_Update:
        UpdateRenderInfo();
        break;
    case kOsvrEventID_SetRoomRotationUsingHead:
        SetRoomRotationUsingHead();
        break;
    case kOsvrEventID_ClearRoomToWorldTransform:
        ClearRoomToWorldTransform();
        break;
    default:
        break;
    }
}
Exemple #2
0
FTOutlineGlyphImpl::FTOutlineGlyphImpl(FT_GlyphSlot glyph, float _outset,
                                       bool useDisplayList)
:   FTGlyphImpl(glyph),
    glList(0)
{
    if(ft_glyph_format_outline != glyph->format)
    {
        err = 0x14; // Invalid_Outline
        return;
    }

    vectoriser = new FTVectoriser(glyph);

    if((vectoriser->ContourCount() < 1) || (vectoriser->PointCount() < 3))
    {
        delete vectoriser;
        vectoriser = NULL;
        return;
    }

    outset = _outset;

    if(useDisplayList)
    {
        // glList = glGenLists(1);
        // glNewList(glList, GL_COMPILE);

        DoRender();

        // glEndList();

        delete vectoriser;
        vectoriser = NULL;
    }
}
Exemple #3
0
/** The main loop. **/
void CEngine::Start()
{
	m_lLastTick = SDL_GetTicks();
	m_bQuit = false;

	// Main loop: loop forever.
	while ( !m_bQuit )
	{
		// Handle mouse and keyboard input
		HandleInput();

		if ( m_bMinimized ) {
			// Release some system resources if the app. is minimized.
			//WaitMessage(); // pause the application until focus in regained
		} else {
			// Do some thinking
			DoThink();

			// Render stuff
			DoRender();
		}
	}

	End();
}
const FTPoint& FTPolygonGlyphImpl::RenderImpl(const FTPoint& pen,
                                              int renderMode)
{
    if (vectoriser)
    {
        DoRender(pen);
    }
    return advance;
}
Exemple #5
0
void FTFont::Render( const wchar_t* string )
{
    const wchar_t* c = string;
    pen.x = 0; pen.y = 0;

    while( *c)
    {
        DoRender( *c, *(c + 1));
        ++c;
    }
}
Exemple #6
0
		void DisplayFrame(Frame* pFrame)
		{
			if(pFrame != NULL && pFrame->HasValidDataPtr()) {
				if(GetFrameManager()->Owns(*pFrame)) {
					DoRender(pFrame);
				}
				else {
					FramePtr pTempFrame = GetReservedFrame();
					if(pTempFrame && pFrame->GetDataSize() == pTempFrame->GetDataSize()) {
						utils::image::Copy(pTempFrame->GetDataPtr(), pFrame->GetDataPtr(), pTempFrame->GetDataSize());
						DoRender(pTempFrame.get());
					}
					else
						LOG << TEXT("DECKLINK: Failed to get reserved frame");
				}
			}
			else {
				LOG << TEXT("DECKLINK: Tried to render frame with no data");
			}
		}
Exemple #7
0
  void RenderModule::Render(SceneView* view)
  {
    Setup(view);
    Synchronize(view);

    if (m_flags.test(eRenderRequired))
    {
      DoRender(view);
      m_flags.reset(eRenderRequired);
    }
  }
Exemple #8
0
const FTPoint& FTPolygonGlyphImpl::RenderImpl(const FTPoint& pen,
                                              int renderMode)
{
    glTranslatef(pen.Xf(), pen.Yf(), pen.Zf());
    if (vectoriser)
    {
        DoRender();
    }
    glTranslatef(-pen.Xf(), -pen.Yf(), -pen.Zf());
    return advance;
}
Exemple #9
0
void FTFont::Render( const char* string )
{
    const unsigned char* c = (unsigned char*)string;
    pen.x = 0; pen.y = 0;

    while( *c)
    {
        DoRender( *c, *(c + 1));
        ++c;
    }
}
void Entity::Render( float ticks ) throw(std::exception)
{
    DoUpdate(ticks);
    glPushMatrix();
    glMultMatrixf( GetRenderState()->GetMatrix() );

    uint32_t flags = GetRenderState()->GetFlags();

    int gl_blend_src(0), gl_blend_dst(0);
    int alpha_enabled;
    glGetIntegerv(GL_ALPHA_TEST, &alpha_enabled);
    if (!alpha_enabled && (flags & RenderState::ALPHA_F) )
    {
        glGetIntegerv(GL_BLEND_SRC, &gl_blend_src);
        glGetIntegerv(GL_BLEND_DST, &gl_blend_dst);
        glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glEnable(GL_ALPHA_TEST);
    }
    else if (alpha_enabled && (flags & RenderState::ALPHA_F) == 0 )
    {
        glDisable(GL_ALPHA_TEST);
    }
    int blend_enabled;
    glGetIntegerv(GL_BLEND, &blend_enabled);
    if (!blend_enabled && (flags & RenderState::BLEND_F) )
    {
        glEnable(GL_BLEND);
    }
    else if ( blend_enabled && (flags & RenderState::BLEND_F) == 0 )
    {
        glDisable(GL_BLEND);
    }

    for( auto it = m_RenderList.begin(); it != m_RenderList.end(); ) {
        EntityPtr entity = *it;
        if ( entity->AreFlagsSet( Entity::F_ENABLE ) ) {
            entity->Render( ticks );
        }
        if ( entity->AreFlagsSet( Entity::F_DELETE ) ) {
            it = m_RenderList.erase( it );
            continue;
        }
        ++it;
    }
    DoRender();

    if (!alpha_enabled && (flags & RenderState::ALPHA_F) )
    {
        glBlendFunc( gl_blend_src, gl_blend_dst);
    }
    glPopMatrix();
}
Exemple #11
0
// ****************************************************************************
//
//  Function Name:	RCompositeSelection::Render( )
//
//  Description:		Redraws the selection to the screen
//
//  Returns:			Nothing
//
//  Exceptions:		Memory
//
// ****************************************************************************
//
void RCompositeSelection::Render( BOOLEAN fRenderIfLocked ) const
{
    if( !m_fSelectionHidden )
    {
        // Make sure the selection is not visible
        TpsAssert( m_fSelectionVisible == FALSE, "Selection already visible, use Remove( ) instead." );

        // cast away constness because mutable is not supported
        const_cast<RCompositeSelection*>( this )->m_fSelectionVisible = TRUE;

        DoRender( fRenderIfLocked );
    }
}
Exemple #12
0
void Entity::Render( int pass ) throw(std::exception)
{
    glPushMatrix();
    glMultMatrixf( GetRenderState()->GetMatrix() );

    uint32_t flags = GetRenderState()->GetFlags();

    int glBlendSrc(0), glBlendDst(0);
    int alphaEnabled;
    glGetIntegerv(GL_ALPHA_TEST, &alphaEnabled);
    if (!alphaEnabled && (flags & RenderState::ALPHA_F) )
    {
        glGetIntegerv(GL_BLEND_SRC, &glBlendSrc);
        glGetIntegerv(GL_BLEND_DST, &glBlendDst);
        glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glEnable(GL_ALPHA_TEST);
    }
    else if (alphaEnabled && (flags & RenderState::ALPHA_F) == 0 )
    {
        glDisable(GL_ALPHA_TEST);
    }
    int blendEnabled;
    glGetIntegerv(GL_BLEND, &blendEnabled);
    if (!blendEnabled && (flags & RenderState::BLEND_F) )
    {
        glEnable(GL_BLEND);
    }
    else if ( blendEnabled && (flags & RenderState::BLEND_F) == 0 )
    {
        glDisable(GL_BLEND);
    }

    // render all children
    for( auto it = m_RenderList.begin(); it != m_RenderList.end(); ) {
        EntityPtr entity = *it;
        if ( entity->IsFlagSet( Entity::F_ENABLE|Entity::F_VISIBLE ) &&
            !entity->IsFlagSet( Entity::F_DELETE ) )
        {
            // don't bother rendering if we are marked for deletion
            entity->Render( pass );
        }
        ++it;
    }
    DoRender( pass );

    if (!alphaEnabled && (flags & RenderState::ALPHA_F) )
    {
        glBlendFunc( glBlendSrc, glBlendDst);
    }
    glPopMatrix();
}
const FTPoint& OgreFTPolygonGlyphImpl::RenderImpl(const FTPoint& pen,
                                              int renderMode)
{
    glTranslatef(pen.Xf(), pen.Yf(), pen.Zf());
    
    if(glList)
    {
        glCallList(glList);
    }
    else if(vectoriser)
    {
        DoRender(pen);
    }
    glTranslatef(-pen.Xf(), -pen.Yf(), -pen.Zf());

    return advance;
}
void RigidBody::Render() const
{
	glColor3f(GetMaterial()->color.x, GetMaterial()->color.y, GetMaterial()->color.z);
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	
	Vector3 pos = GetPosition();
	glTranslatef(pos.x, pos.y, pos.z);
	float angle;
	Vector3 axis;
	GetOrientation().ToAngleAxis(angle, axis);
	glRotatef(angle*180.0f/M_PI, axis.x, axis.y, axis.z);

	DoRender();
	glPopMatrix();
	int err = glGetError();
	err = err;
}
Exemple #15
0
const FTPoint& FTOutlineGlyphImpl::RenderImpl(const FTPoint& pen,
                                              int renderMode)
{
    (void)renderMode;

    // glTranslatef(pen.Xf(), pen.Yf(), pen.Zf());
    if(glList)
    {
        // glCallList(glList);
    }
    else if(vectoriser)
    {
        DoRender();
    }
    // glTranslatef(-pen.Xf(), -pen.Yf(), -pen.Zf());

    return advance;
}
int Framework::Start(){
	
	Init();


	while(m_isRunning){
		DoUpdate();
		DoRender();
		glfwSwapBuffers();

		m_isRunning = (!glfwGetKey( GLFW_KEY_ESC ) && glfwGetWindowParam( GLFW_OPENED ));


	}

	glfwTerminate();
	TwTerminate();
	return 0;

}
Exemple #17
0
void CEngine::Start()
{
	m_lLastTick = SDL_GetTicks();
	m_bQuit = false;
	
	while(!m_bQuit)
	{
		HandleInput();
		if(m_bMinimized)
		{
		}
		else
		{
			//do some thinking
			DoThink();
			//render stuff
			DoRender();
		}
	}
	End();
}
Exemple #18
0
FTPolygonGlyphImpl::FTPolygonGlyphImpl(FT_GlyphSlot glyph, float _outset,
                                       bool useDisplayList)
:   FTGlyphImpl(glyph),
    glList(0)
{
    if(ft_glyph_format_outline != glyph->format)
    {
        m_err = 0x14; // Invalid_Outline
        return;
    }

    vectoriser = new FTVectoriser(glyph);

    if((vectoriser->ContourCount() < 1) || (vectoriser->PointCount() < 3))
    {
        delete vectoriser;
        vectoriser = NULL;
        return;
    }


    hscale = glyph->face->size->metrics.x_ppem * 64;
    vscale = glyph->face->size->metrics.y_ppem * 64;
    outset = _outset;

    if(useDisplayList)
    {
        glList = glGenLists(1);
        glNewList(glList, GL_COMPILE);

        DoRender();

        glEndList();

        delete vectoriser;
        vectoriser = NULL;
    }
}
int __glXDispSwap_Render(__GLXclientState *cl, GLbyte *pc)
{
    return DoRender(cl, pc, True);
}
void CEffect::Render()
{
    if (m_enabled)
        DoRender();
}
Exemple #21
0
void Renderer::Render( Context& context,
                       SceneGraph::TextureCache& textureCache,
                       BufferIndex bufferIndex,
                       const SceneGraph::NodeDataProvider& node,
                       SceneGraph::Shader& defaultShader,
                       const Matrix& modelViewMatrix,
                       const Matrix& viewMatrix,
                       const Matrix& projectionMatrix,
                       bool cull,
                       bool blend )
{
  NewRenderer* renderer = GetNewRenderer(); // avoid a dynamic cast per item per frame

  if( renderer )
  {
    // Get the shader from the material:
    mShader = &renderer->mRenderDataProvider->GetShader();
  }

  // if mShader is NULL it means we're set to default
  if( !mShader )
  {
    mShader = &defaultShader;
  }

  if( !CheckResources() )
  {
    // CheckResources() is overriden in derived classes.
    // Prevents modify the GL state if resources are not ready and nothing is to be rendered.
    return;
  }

  // Get the program to use:
  Program* program = mShader->GetProgram();
  if( !program )
  {
    // if program is NULL it means this is a custom shader with non matching geometry type so we need to use default shaders program
    program = defaultShader.GetProgram();
    DALI_ASSERT_DEBUG( program && "Default shader should always have a program available." );
    if( !program )
    {
      DALI_LOG_ERROR( "Failed to get program for shader at address %p.", (void*) &*mShader );
      return;
    }
  }

  // Take the program into use so we can send uniforms to it
  program->Use();

  DoSetCullFaceMode( context, bufferIndex );

  DoSetBlending( context, bufferIndex, blend );

  // Ignore missing uniforms - custom shaders and flat color shaders don't have SAMPLER
  // set projection and view matrix if program has not yet received them yet this frame
  const Matrix& modelMatrix = node.GetModelMatrix( bufferIndex );
  SetMatrices( *program, modelMatrix, viewMatrix, projectionMatrix, modelViewMatrix );

  // set color uniform
  GLint loc = program->GetUniformLocation( Program::UNIFORM_COLOR );
  if( Program::UNIFORM_UNKNOWN != loc )
  {
    const Vector4& color = node.GetRenderColor( bufferIndex );
    program->SetUniform4f( loc, color.r, color.g, color.b, color.a );
  }

  //@todo MESH_REWORK Remove after removing ImageRenderer
  DoSetUniforms(context, bufferIndex, mShader, program );

  // subclass rendering and actual draw call
  DoRender( context, textureCache, node, bufferIndex, *program, modelViewMatrix, viewMatrix );
}