Crystal Space
Welcome, Guest. Please login or register.
September 20, 2014, 07:29:42 pm

Login with username, password and session length
Search:     Advanced search
9018 Posts in 2051 Topics by 8494 Members
Latest Member: Onapthanh
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  A csApplicationFramework PostProcessFrame problem.
« previous next »
Pages: [1] Print
Author Topic: A csApplicationFramework PostProcessFrame problem.  (Read 2448 times)
muffinpeddler
Full Member
***
Posts: 122


View Profile Email
« on: October 15, 2005, 06:52:52 pm »

I am using the csApplicationFramework with a csBaseEventHandler for my rendering.  A call to PostProcessFrame to draw 2d stuff invokes a subclass of a Scene object's PostProcessScene function.  The problem I am having is that in the event handler I wish to draw the FPS on the screen after I call the scene's PostProcessScene function.  However, it seems like what I am writing is being erased when I draw from the event manager, but this does not happen when I draw from the scene's PostProcessScene function.  Any suggestions?  I am using CEL and CS if that helps.  Thanks.
Logged
sunshine
Administrator
Sr. Member
*****
Posts: 294


View Profile
« Reply #1 on: October 16, 2005, 09:20:58 am »

You probably will need to provide more precise details about what your code is doing. Perhaps include actual code snippets.
Logged
muffinpeddler
Full Member
***
Posts: 122


View Profile Email
« Reply #2 on: October 16, 2005, 06:51:36 pm »

Well, here is the PostProcessFrame function in scene manager which extends csBaseEventHandler:

Code:
    void TerraSceneManager::PostProcessFrame()
    {
        float currentTime = cc->GetVirtualClock()->GetCurrentTicks() * 0.001f;
       
        int iw, ih;
        char fpsstr[50] = { 0 };

        if(!g3d)
        {
            g3d = cc->GetGraphics3D();
            g = g3d->GetDriver2D();
            font = g->GetFontServer()->LoadFont("DejaVuSans", 16);
        }
       
        if(!g3d->BeginDraw(CSDRAW_2DGRAPHICS))
            return;
       
        if(scene)
        {
            scene->PostProcessScene();
        }
   
        frameTime = currentTime;

        fps++;
       
        if(currentTime - lastTime > 1.0f)
        {
            lastTime = currentTime;

            sprintf(fpsstr, "%d", (int)fps);

            fps = 0;
        }

        font->GetDimensions(fpsstr, iw, ih);
        g->Write(font, g->GetWidth()-iw, g->GetHeight()-ih,
                 Color(g, 255, 255, 255, 190),
                 Color(g, 255, 255, 255, 0), fpsstr);
       
        g->FinishDraw();
    }

Which, for example, will call TerraSceneGame's PostProcessScene function:
Code:
    void TerraSceneGame::PostProcessScene()
    {

        RenderCrosshair();
        RenderHUD();
        console->DrawConsole(g);
    }

It's odd, because any drawing I do in the game scene's post processing function it isn't erased right away, but if I do it in the scene manager's post processing, it flickers and is constantly being erased.  Any ideas?  Thanks.
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 6.183 seconds with 16 queries.