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 ... 9 10 [11] 12 13 14
151
General / Re: Need some help optimizing rendering speed.
« on: October 14, 2015, 11:39:42 pm »
I tried updating every 4 frames and it made the entire shader blink. epilepsy! (yes i only did it for ls.RenderLights(), not the texture.)


Really? can you post images.

As i said, i tested this solutions several (severals ) times with moving lights with the mouse (very fast movements ), having on screen 300 + bigs  dynamic lights. And never blinking at worst only being "slow".

If you don't believe me i can give you examples (executables) of my tests.

Note: i have ltbl 1.5

152
General / Re: Need some help optimizing rendering speed.
« on: October 14, 2015, 11:33:59 pm »
I didn't see the part where you recommended to set it to 4-7 for 60 fps apps. Well that will ofcourse give better performance, but lights will only update at 8-15 fps. I don't think i want to make that sacrifice, atleast not now. Maybe if i really need to sometime i might concider making it run slightly slower.

You are here asking for performance solutions, i give you one.

It's true, its your fps are high you don't need to limit them. But is a good solution.

Can appear that 8-15 fps can be slow but the eyes isn't too fast to distinguish. I said those value because i already tested them.

For exmaple, supose that you finish your game. A user with a super-pc will be glad to run the game in ultra-high graphics (only set the value to 1). But if the user had a poor computer probably with this options he can gain a 25-40% of performance al only loosing 3-10% of smothness.

It's an ajustable solution with a short implementation. i think this is a better solution than remake the LTBL sytem, isn't it?

153
General / Re: Need some help optimizing rendering speed.
« on: October 14, 2015, 10:49:57 pm »
wont that make it so lights are lagging behind moving objects though?, and not moving as smoothly. I can see that it might work for lights that aren't moving, but that's not the case on my lights.


Nope, as i said depend of your fps , if you achieve 700 fps you can set to 30 for example and will run very smooth with a significant performace.

By the way.. setting this to a slow value 4~7 are smooth values for apps that run at 60 fps.

Test with differents values, and say if you performance improve and if your lights are lagging.


AFAIK several games has performance options on shadows,lights,anti-aliasing,smothness etc that the user can ajust ; more graphics power = more work for the computer, if an user can manage this settings will be better for the user.

154
General / Re: Need some help optimizing rendering speed.
« on: October 14, 2015, 10:15:53 pm »
If you are using LTBL1 this could help

You can increase the performance by calling few times lightsystem->RenderLights()

You don't need to call it every frame.

i create this:

       // This class you can define how each frame you will call a function.
        template < typename TYPE >
        class updatePerTicks
        {  
            private :
                        unsigned int ticks ;
            public :
                    unsigned int max_ticks ;

                        updatePerTicks( unsigned int toReachTicks ) : ticks( 0 )  
                        {
                       max_ticks = toReachTicks ;
                        }

                    void operator()( void(*f)( TYPE *something ) , TYPE *param1 )
                        {
                                if( ++ticks == max_ticks )
                                        {  
                                           ticks = 0 ;
                                           f( param1 ) ;
                                        }
                        }

                        void updateTicks( void(*f)( TYPE *something ) , TYPE *param1 ) // Another access for operator() function.
                        {
                                if( ++ticks == max_ticks )
                                        {  
                                           ticks = 0 ;
                                           f( param1 ) ;
                                        }                      
                        }
        };


 


instead of doing this:

    lightsystem->RenderLights() ;
 

i do this:


// put this where you want
auto renderLightsFunc = []( ltbl::LightSystem *ls ){ ls->RenderLights() ; } ;

updatePerTicks< LightSystem > renderLights( 4 ) ; // we set to every 4 frame .. can be  10 / 20 any positive number. Higher fps you can use higher value and will be smooth
// end of "put this"

// we replace  lightsystem->RenderLights() with this:

renderLights( renderLightsFunc , &myLightSystem ) ;

/* if you want you can directly modify the amount of "ticks"
renderLights.max_ticks = myPositiveValue ;
*/


 


Note: You cannot use this method with
lightsystem->RenderLightTexture() ;
this method is needed to be called at least one per frame

155
General / Re: Need some help optimizing rendering speed.
« on: October 14, 2015, 08:56:49 pm »
Are you achieving poor performance , Can we know the fps or render time ?.
What are your pc specifications?

And i think you can profile the code to know where is the bottleneck (if any). (This task is simple on visual studio, this IDE have several tools for this).



156
General / Re: Help me with this doubt.
« on: October 14, 2015, 05:01:48 pm »
Quote
What is this supposed to mean? This has nothing to do with the problem.

If for expample you make this:

window.display()
window.display() // make it twice
 

You'll get a flickering screen.

The code that he provide is not clear at all. A compilable example will give us the opportunity of see the error and correct it , then we can post the correct code and explain better the problem.

Yeah, we are not here to code for others, but we can test and correct a minimal example that show the error.

You give the answer, but he could need to know where is the problem and how avoid it in the future.

157
General / Re: Help me with this doubt.
« on: October 14, 2015, 12:58:47 am »
You should provide code that we can compile, and test.

But like zsbzsb said you need to call clear/draws/display in this order and avoid to call display more than one per cicle if not you will get a flickering screen.

158
Graphics / Re: Question on setColor
« on: October 01, 2015, 05:46:29 am »
Is because you tint the image instead of changing the color.

There is no way, yet, but i believe if you use external libraries for modify the texture, or use shaders you can get a sort of that you want.

160
Graphics / Re: Clickable Sprite
« on: September 30, 2015, 05:24:00 am »
Try this example.


#include <iostream>
#include <SFML\Graphics.hpp>
#include <vector>

using namespace sf ;
using namespace std ;

int main( int argc, char* argv[] )
{
        bool exit = false ;
        std::string Action ;

        RenderWindow window( VideoMode( 800 , 600 ) , "myWindow" ) ;
                     window.setActive( false ) ;
                                 window.setFramerateLimit( 65 ) ;


    RectangleShape s_startGame( Vector2f( 300 , 100 ) ) ;
                                   s_startGame.setFillColor( Color::Red ) ;
                   s_startGame.setPosition( 280 , 225 ) ;


 
    while ( window.isOpen() )
    {  
            Event event ;

        while ( window.pollEvent( event ) )
        {
                                if ( event.type == Event::Closed )
                                                window.close() ;

                                if ( event.type == Event::MouseButtonPressed )
                                {    
                           
                                                if ( event.mouseButton.button == sf::Mouse::Left )
                                                {    
                                                         Vector2i MousePos = Mouse::getPosition( window ) ;
                                                         FloatRect objPos = s_startGame.getGlobalBounds() ;

                                                        if ( objPos.contains( MousePos.x , MousePos.y ) )
                                                        {

                                                                if( exit )
                                                                   { exit = false ; Action = "Exit" ; }
                                                                else
                                                                   { exit = true ; Action = "Enter" ; }

                                                                cout << "Touched by mouse, action: " << Action << endl ;
                                                        }

                                                }
                                }
                }

                window.clear() ;
                window.draw( s_startGame ) ;
                window.display() ;
        }

   return 0 ;
}


 



Please don't do that:
Quote
if (sf::Mouse::getPosition(window).y > s_startGame.getGlobalBounds().top &&
                    sf::Mouse::getPosition(window).y < s_startGame.getGlobalBounds().height + s_startGame.getGlobalBounds().top &&
                    sf::Mouse::getPosition(window).x < s_startGame.getGlobalBounds().width + s_startGame.getGlobalBounds().left &&
                    sf::Mouse::getPosition(window).x > s_startGame.getGlobalBounds().left)

Instead store the result in a variable and use the x,y / top,left,width,height properties

Vector2i mousePos = sf::Mouse::getPosition(window) ;
doWhatEver( mousePos.x , mousePos.y ) ;
 

And use the built-in method to check if a  point intersect or contain.
FloatRect objRect =  s_startGame.getGlobalBounds() ;
// objRect.contains( x , y )
// objRect.intersects( FloatRect( x , y , width , height ) )
 

161
General / Re: SFML 2.0 and Box2d PRoblem
« on: September 24, 2015, 09:51:12 pm »
I made an example that works perfect



#include <iostream>
#include <SFML\Graphics.hpp>
#include <Box2D\Box2D.h>
#include <vector>

using namespace sf ;
using namespace std ;

#define TIMESTEP 1.0f/60.0f    
#define VELITER 10            
#define POSITER 10              



int main( int argc, char* argv[] )
{

        RenderWindow window( VideoMode( 800 , 600 ) , "myWindow" ) ;
                                 //window.setFramerateLimit( 1000 ) ;

    b2World world(b2Vec2(0.0f, 10.0f));

    //Definir Suelo Box2D
    b2BodyDef sueloBodyDef;
    sueloBodyDef.position.Set( 400 * 0.1 , 500 * 0.1 );
    b2Body* sueloBody = world.CreateBody(&sueloBodyDef);
    b2PolygonShape sueloBox;
    sueloBox.SetAsBox( 200 * 0.1 , 100 * 0.1 );
    sueloBody->CreateFixture(&sueloBox, 0.0f);
    // Crear ventana
    window.setFramerateLimit(60); //Hacer que los tiempos de refresco casen con los tiempos de Box2D

    sf::Vector2f m_Size;
    b2Body *m_pBody;
    b2PolygonShape polyShape;
    b2FixtureDef fixtureDef;
    b2BodyDef bodyDef;

        m_Size = sf::Vector2f(50.0f, 50.0f);
   
    bodyDef.type = b2_dynamicBody;
    bodyDef.position.Set( 400 * 0.1 , 50.0f * 0.1 );
    m_pBody = world.CreateBody(&bodyDef);

    polyShape.SetAsBox( (50.0f/2) * 0.1 , (50.0f/2) * 0.1 ) ;

    fixtureDef.shape = &polyShape;
    fixtureDef.friction = 0.2f;
    fixtureDef.restitution = 0.3f;
    fixtureDef.density = 0.7f;

    m_pBody->CreateFixture(&fixtureDef);

    sf::RectangleShape rectSuelo( sf::Vector2f( 400 , 200 ) );
    rectSuelo.setOrigin( 400/2 , 200/2 );
    rectSuelo.setPosition( 400 , 500 ) ;
    rectSuelo.setFillColor(sf::Color::Red);

    sf::RectangleShape rect( sf::Vector2f( 50 , 50 ) );
    rect.setOrigin( 50/2 , 50/2 );
    rect.setPosition( 50 , 50 ) ;
    rect.setFillColor(sf::Color::Blue);

    while ( window.isOpen() )
    {  
            sf::Event event ;
        while ( window.pollEvent( event ) )
        {
            if ( event.type == sf::Event::Closed )
                window.close() ;

        }

                world.Step(TIMESTEP, VELITER, POSITER) ;

        window.clear() ;
                b2Vec2 pos = m_pBody->GetPosition() ;
                rect.setPosition( pos.x * 10 , pos.y * 10 ) ;
                window.draw(rectSuelo); //Dibujamos el elemento en el buffer
                window.draw(rect);
        window.display() ;
    }

        return 0 ;
}



 

162
General / Re: SFML 2.0 and Box2d PRoblem
« on: September 24, 2015, 08:55:49 pm »
I will follow this conversation with private messages.

Probably the math inside the game logic is wrong, and the objects doesn't appear in the corrects positions.

To know this we can output the positions with std::cout, and test until we get what we want.

For testing is better being minimal, less abstractions as be posible.

Taking in account that we had to considerates the relations, i use for box2d *0.1  when passing position (sfml to box2d) (x,y) and use *10 when getting position (box2d to sfml) .

In rotation i use this #defines

#define TO_RAD 0.0174532925199432957f 
#define TO_DEGREES 57.295779513082320876f

163
Graphics / Re: CircleShape performance
« on: September 24, 2015, 08:19:58 pm »
Post a minimal and testable example so we can know better whats really you want to use, like the answer above you can use vertex array, you will gane a SIGNIFICANT boost but you will lose some of "control" properties.

You can add too what really you want to do, if you need to changes somes propertie likes texture, color , thickness , outline etc...

164
General / Re: SFML 2.0 and Box2d PRoblem
« on: September 24, 2015, 08:10:53 pm »
Como mi idioma nativo es el espaƱol respondere en ambos idiomas, yo tengo buena experiencia con Box2D asi que puedes contactarme por MP si lo deseas.

Cuando llamas world.step() este se suele colocar a una frecuencia (1/60) que seria igual a 60 fps, significa que se actualizara a esa velocidad, para que box2d se actualize debes poner world.step() en el main loop, donde box2D hara los calculos cada frama (cuadro). Supongamos que estableces un limite de 60 fps window.setFrameLimit(60);

trata colocando esto en el main loop para que sea actualizado cada frama en vez de afuera:

        world.Step(TIMESTEP, VELITER, POSITER);
        personaje.run(window);


When we call world.step() this is often set at (1/60) that will be the same as 60 fps,meas that Box2Dwill update at this speed, for box2D get updates you need to put world.step() inside of the main loop, where box2D will do the math every frame. Supose that you set a frame limit of 60 fps
window.setFrameLimit(60) ;

try to put this on the main loop for be updated every frame instead of out:

        world.Step(TIMESTEP, VELITER, POSITER);
        personaje.run(window);

Pages: 1 ... 9 10 [11] 12 13 14
anything