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 - DarkRoku12

Pages: 1 ... 12 13 [14]
196
SFML is like SDL.

A library. A very good library (i prefer it over SDL).

I don't understand so much what you say..because it's too philosophical.

If you want more resources (more "media") (instaed of picking this for one library and that for other and then put all together ) you can choose a game engine.

Like cryengine (C++/lua) , unity3D (C#) , unreal engine (C++) , corona sdk ( lua , for android ) ..etc .

The last 3 engines are now free ( unreal requires royalties ).

I really recommend unity3D.

197

3) Its faster ( OpenGL is faster that DirectX ) ( chipmunk-physics are faster than Box2d)
Sorry, but this is complete bullshit, especially with those examples. It's so fundamentally wrong I don't even know where to start. But you'll find these kinds of arguments all over the internet, there's no need to repeat them here... So I'd say we concentrate on the benchmark in this thread, no need for another C vs C++ flamewar.

I will see carefully of RAII , looks ougly but great for the memory leaks.
You should really read my article. Exactly this kind of unfunded myths are refuted.


I know that Lua is slower than C++ . When i made the first test i thought  "C++ sure achieve 20 fps or more"..but not.

Luajit is a good tool too, speed up the lua code. ( I'm traying to make the engine comatible with lua 5.2 ...is a headache cause the incompatibilities but it's possible. )

I can post the lua Code.. but there is a lot of libs ( .hpp / .lua ) involved , i can't post all. When i release my engine all will be on github.

You really want to see all the code ? ( i can upload it now if you want )

198
i use memory management because i like C style.
If you have some time, you could read the RAII article I linked to, there are very good arguments against that :)
[/quote]

For c++ it should be better using the tools provied the official libraries. But i still thinking the syntax is horrible.

I like a lot more C over C++ ( but sometimes i miss C++ features ).

But it i like C over C++ for this.
1) Is a lot more portable.
2) Less API it have..less you need to know.
3) Its faster ( OpenGL is faster that DirectX ) ( chipmunk-physics are faster than Box2d) ( I use box2d because have a better API and documentation ).

I will see carefully of RAII , looks ougly but great for the memory leaks.


199
There are several issues with your C++ code, making the measurement meaningless:
  • You should measure frame time, not FPS.
  • Having a std::cout in the measurement slows down everything, might as well be the bottleneck.
  • If you're really going for CPU performance and not just the GPU communication overhead, use fewer draw calls (sf::VertexArray instead of sf::Sprite).
  • Use iterators or range-based for instead of index access. Make also sure that any debug checks in the STL are disabled.
And what's the point of
Clock *fps = new Clock;
Sprite *obj = new Sprite[ 1000 ] ;
when you can just use
Clock fps;
std::vector<Sprite> obj(1000);
without the need for manual memory management? Use RAII where possible.



I replace all the code with the one that you give me.
Even i take off the fps counter and "cout" ..still the same..sometime ups to 10 fps (FRAPS) but then slow to 8 again.

i use memory management because i like C style.

200
Weird.
Are you running the C++ version from VisualStudio (or CodeBlocks it looks like)?  Even in release, that can be significantly slower.  If so, try running by double-clicking the executable instead.

Still the same for both.

201
I'm making a lua-sfml engine and i decide to test the performace making the same code on pure C++.

All compiler optimizations are on on both projects ( -O3 -fexpensive-optimizations ). (using codeblocks)

Not frame limit in both projects.

Lua-jit gets version  11 fps stable ( with  1000 crates on display , physics engine active ( there are 3 physics object active in the scene, some events dispatcher actives )

In C++ pure version got 8 fps stable ( with ONLY 1000 crates on the display..no physics engine active..no Lua states actives )

I use 2 counters for the test.. a custom counter on the game..and FRAPS.. both counter say the same fps rate. ( 11 for  lua / 8 for  c++ )

C++ code for the test only this no more:
#include <iostream>

using namespace std ;
#include <SFML/Graphics.hpp>
using namespace sf ;

int main()
{
    // create the window
    sf::RenderWindow window(sf::VideoMode(600, 600), "My window") ;
    int fps_rate = 0 ;
    Clock *fps = new Clock ;
    sf::Texture t ;
    // load the texture
    t.loadFromFile( "crate.png" ) ;
    t.setSmooth( true ) ;

    Sprite *obj = new Sprite[ 1000 ] ;
    for( int s = 0 ; s < 1000 ; ++s )
           obj[s].setTexture( t ) ;

    // run the program as long as the window is open
    while (window.isOpen())
    {
       
       // fps counter
        ++fps_rate ;
        if ( fps->getElapsedTime().asSeconds() >= 1 )
        {   fps->restart() ;
            cout << fps_rate << endl ;
            fps_rate = 0 ;
        }

        // check all the window's events that were triggered since the last iteration of the loop
        sf::Event event;
        while (window.pollEvent(event))
        {
            // "close requested" event: we close the window
            if (event.type == sf::Event::Closed)
                window.close();
        }

        // clear the window with black color
        window.clear(sf::Color::Black);

        // draw everything here...

        for( int i = 0 ; i < 1000 ; ++i )
        {
            window.draw( obj[ i ] ) ;
        }

        // end the current frame
        window.display();
    }

    return 0;
}
 


Screenshots:

lua version



The small crate and the long crates are physics objects. (the small crates is falling)
The bigs crates ( there are one thousand , you cant see it because are one behind other )
The console show the fps..and the yellow numbers are shown by FRAPS.

The same in the C++ version :



As you can see.. no physics..no lua States..

Please..if you can optimizate more this c++ code please post it for test it.

I would like yours reviews. :)

PD: link for the full images:

c++ : http://www.subirimagenes.com/imagedata.php?url=http://s2.subirimagenes.com/imagen/9376734c.png

lua : http://www.subirimagenes.com/imagedata.php?url=http://s2.subirimagenes.com/imagen/9376732luaversion.png

Lua game engine topic: http://en.sfml-dev.org/forums/index.php?topic=18074.0

202
SFML projects / Re: Escape From Fog - 3D Maze game
« on: May 20, 2015, 02:25:13 am »
See so cool.

You have a great skills using the OpenGl support. working with the OpenGL API is hard.

I will enjoy play the game when released.  :D

203
Great feature!. ;D

I probably include this in my engine, a lot of game programmers use cinematics on the game.

Thanks for the excellent contribution. All the users of SFML will enjoy this.

My game engine topic:
http://en.sfml-dev.org/forums/index.php?topic=18074.0

Pages: 1 ... 12 13 [14]
anything