Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - dreimalbla

Pages: [1]
1
Graphics / OpenGL performance issue
« on: July 26, 2008, 08:37:05 pm »
Hi,

we've got a big OpenGL performance problem here.

We are programming a space strategy game using SFML. The framework got bigger and bigger and we are dealing with huge performance problems right now.

Here are the main features which will give you a little review of our situation:

-There are about 9 planets which are drawn and rotating.
-We calculate Point on Map of the Mouse every Frame.
-1 Light Source
-Zoom, Move Map, Rotate around fixed point on Map is possible

At the moment we reach about 200 fps in window mode.
(Graphic Card: 9800 Pro ATI Radeon, CPU amd 2500+)

My friend with an ATI x800xt and amd 3500+ gets about 350 fps. We're both using the newest catalyst drivers (8.7).

To trace the bottleneck we stopped the time for some functions. This didn't really work out because there are two functions which take the most time, drawFunctions and
eventfunction(incl. Point on Map calculation).

Therefore we wrote 2 simple OpenGL testprograms. One in SDL and one in SFML.
There's only some drawing without much calculation at events and without texturing and lighting.

We are drawing 9 gluSpheres with 32 slices and 32 stacks which are rotating in front of a black background.

For testing we also included DisplayLists.

Here are my Results (the x800xt results):

SFML
draw: about 700fps (1000fps)
draw with DL(DisplayLists): about 1500 fps (2800fps)

SDL
draw: about 1000 fps (1800fps)
draw with DL: about 1700 fps (3000fps)

Now the real big difference can be seen in FULLSCREEN mode:

FULLSCREEN
SFML
draw: about 700fps (900fps)
draw with DL(DisplayLists): about 1600 fps (3100fps)

SDL
draw: about 1100 fps (1800fps)
draw with DL: about 3400 fps (6200fps)

Sure, we would like to stick with SFML, because we are big fans of this library and it is really good, but since
we got this performance problem we are wondering if we should switch to SDL.

Maybe someone here can tell us why there is such a big differnce in FULLSCREEN Mode to SDL?

We could post the source of the two testprograms if needed. We tried to have the same things activated at those programs on
each libaray. Is it possible that there are tweaks in SFML that we aren't aware of? If so please help us and tell us how we can improve our program using SFML. Thanks!

2
Graphics / Draw(Text) performance issue
« on: July 16, 2008, 08:20:31 pm »
great :)
keep up the good work

3
Graphics / Draw(Text) performance issue
« on: July 16, 2008, 07:15:34 pm »
thx for the answer, let's hope he'll fix it soon ;)

4
Graphics / Draw(Text) performance issue
« on: July 16, 2008, 05:15:25 pm »
Hi,
I've got huge performance issue when using SFML's draw text.
Let's take the SFML opengl sample as an example.
600fps while drawing the rotating cube and drawing the fps.
300fps while drawing the rotating cube and drawing the fps three times.
250fps while drawing the rotating cube and drawing the fps four times.

I'm using SFML 1.3. Is this a known issue or is it on my side only?

Code: [Select]


////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <iostream>
#include <sstream>
#include <string>


////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{

    // Create main window
    sf::RenderWindow App(sf::VideoMode(800, 600), "SFML OpenGL");
    App.PreserveOpenGLStates(true);

    // Create a sprite for the background
    sf::Image BackgroundImage;
    if (!BackgroundImage.LoadFromFile("datas/opengl/background.jpg"))
        return EXIT_FAILURE;
    sf::Sprite Background(BackgroundImage);

    // Load an OpenGL texture.
    // We could directly use a sf::Image as an OpenGL texture (with its Bind() member function),
    // but here we want more control on it (generate mipmaps, ...) so we create a new one
    GLuint Texture = 0;
    {
        sf::Image Image;
        if (!Image.LoadFromFile("datas/opengl/texture.jpg"))
            return EXIT_FAILURE;
        glGenTextures(1, &Texture);
        glBindTexture(GL_TEXTURE_2D, Texture);
        gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, Image.GetWidth(), Image.GetHeight(), GL_RGBA, GL_UNSIGNED_BYTE, Image.GetPixelsPtr());
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    }

    // Enable Z-buffer read and write
    glEnable(GL_DEPTH_TEST);
    glDepthMask(GL_TRUE);
    glClearDepth(1.f);

    // Setup a perspective projection
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(90.f, 1.f, 1.f, 500.f);

    // Bind our texture
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, Texture);
    glColor4f(1.f, 1.f, 1.f, 1.f);

    // Create a clock for measuring the time elapsed
sf::Clock Clock;
double currTime = Clock.GetElapsedTime();
double lastTime = Clock.GetElapsedTime();
double deltaTime;

    // Start game loop
    while (App.IsOpened())
    {
currTime = Clock.GetElapsedTime();
deltaTime = currTime - lastTime;
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();

            // Escape key : exit
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
                App.Close();

            // Adjust the viewport when the window is resized
            if (Event.Type == sf::Event::Resized)
                glViewport(0, 0, Event.Size.Width, Event.Size.Height);
        }

        // Draw background
        App.Draw(Background);

        // Clear depth buffer
        glClear(GL_DEPTH_BUFFER_BIT);

        // Apply some transformations
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

        glTranslatef(0.f, 0.f, -200.f);
        glRotatef(Clock.GetElapsedTime() * 50, 1.f, 0.f, 0.f);
        glRotatef(Clock.GetElapsedTime() * 30, 0.f, 1.f, 0.f);
        glRotatef(Clock.GetElapsedTime() * 90, 0.f, 0.f, 1.f);

        //Draw a cube
        glBegin(GL_QUADS);

            glTexCoord2f(0, 0); glVertex3f(-50.f, -50.f, -50.f);
            glTexCoord2f(0, 1); glVertex3f(-50.f,  50.f, -50.f);
            glTexCoord2f(1, 1); glVertex3f( 50.f,  50.f, -50.f);
            glTexCoord2f(1, 0); glVertex3f( 50.f, -50.f, -50.f);

            glTexCoord2f(0, 0); glVertex3f(-50.f, -50.f, 50.f);
            glTexCoord2f(0, 1); glVertex3f(-50.f,  50.f, 50.f);
            glTexCoord2f(1, 1); glVertex3f( 50.f,  50.f, 50.f);
            glTexCoord2f(1, 0); glVertex3f( 50.f, -50.f, 50.f);

            glTexCoord2f(0, 0); glVertex3f(-50.f, -50.f, -50.f);
            glTexCoord2f(0, 1); glVertex3f(-50.f,  50.f, -50.f);
            glTexCoord2f(1, 1); glVertex3f(-50.f,  50.f,  50.f);
            glTexCoord2f(1, 0); glVertex3f(-50.f, -50.f,  50.f);

            glTexCoord2f(0, 0); glVertex3f(50.f, -50.f, -50.f);
            glTexCoord2f(0, 1); glVertex3f(50.f,  50.f, -50.f);
            glTexCoord2f(1, 1); glVertex3f(50.f,  50.f,  50.f);
            glTexCoord2f(1, 0); glVertex3f(50.f, -50.f,  50.f);

            glTexCoord2f(0, 1); glVertex3f(-50.f, -50.f,  50.f);
            glTexCoord2f(0, 0); glVertex3f(-50.f, -50.f, -50.f);
            glTexCoord2f(1, 0); glVertex3f( 50.f, -50.f, -50.f);
            glTexCoord2f(1, 1); glVertex3f( 50.f, -50.f,  50.f);

            glTexCoord2f(0, 1); glVertex3f(-50.f, 50.f,  50.f);
            glTexCoord2f(0, 0); glVertex3f(-50.f, 50.f, -50.f);
            glTexCoord2f(1, 0); glVertex3f( 50.f, 50.f, -50.f);
            glTexCoord2f(1, 1); glVertex3f( 50.f, 50.f,  50.f);

        glEnd();

lastTime = currTime;

std::ostringstream ss;
ss << 1/deltaTime;
std::string s = ss.str();

        // Draw some text on top of our OpenGL object
        sf::String Text(s);
        Text.SetPosition(250.f, 300.f);
        Text.SetColor(sf::Color(128, 0, 128));
        App.Draw(Text);

Text.SetText(s);
        Text.SetPosition(250.f, 330.f);
        Text.SetColor(sf::Color(128, 0, 128));
        App.Draw(Text);

Text.SetText(s);
        Text.SetPosition(250.f, 360.f);
        Text.SetColor(sf::Color(128, 0, 128));
        App.Draw(Text);

Text.SetText(s);
        Text.SetPosition(250.f, 360.f);
        Text.SetColor(sf::Color(128, 0, 128));
        App.Draw(Text);

        // Finally, display the rendered frame on screen
        App.Display();
    }

    // Don't forget to destroy our texture
    glDeleteTextures(1, &Texture);

    return EXIT_SUCCESS;
}


5
Graphics / GL_INVALID_ENUM in renderwindow.cpp
« on: April 25, 2008, 08:09:15 pm »
That's the problem. We can not specify where the error occurs. We've disabled our light class and now the error occurs after closing the window, but only when closing it with a mouse-click on the X at the right top corner. It doesn't occur when pressing "Esc".


Code: [Select]
while (appWindow::Instance().getEvent(Event))
    {
        // Close window : exit
        if (Event.Type == sf::Event::Closed)
            running = false;

        // Escape key : exit
        if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
       running = false;
    }


In Debug Mode it seems to happen before he gets to the first IF.??

6
Graphics / GL_INVALID_ENUM in renderwindow.cpp
« on: April 25, 2008, 03:26:43 am »
hi,
we're using version 1.2

void RenderWindow::OnDisplay()
{
// Find which buffers we must clearGLbitfield ClearBits = GL_COLOR_BUFFER_BIT;
if (GetDepthBits() > 0) ClearBits |= GL_DEPTH_BUFFER_BIT;
if (GetStencilBits() > 0) ClearBits |= GL_STENCIL_BUFFER_BIT;
// Clear the color/depth/stencil buffers for next frame
line 234 --> GLCheck(glClearColor(myBackgroundColor.r / 255.f,
myBackgroundColor.g / 255.f,
myBackgroundColor.b / 255.f,
myBackgroundColor.a / 255.f));
GLCheck(glClear(ClearBits));
}

thanks for your help

Pages: [1]