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

Pages: 1 ... 121 122 [123]
1831
Graphics / Re: Slicing/extracting tiles from a grid of tiles
« on: August 11, 2012, 03:04:22 pm »
You'll be having same pixels in memory few times if you do what you did in first post, sprites have subRects you can set to make them use just part of texture.

1832
Graphics / Re: setFramerateLimit(x) vs. setVerticalSyncEnabled(true)
« on: August 10, 2012, 01:20:22 am »
Well not really anymore. :P But there was part of code that I wanted to limit to lower framerate because of amount of sf::VertexArrays stored in vector of vectors with 1 quad each but I changed that part now.

1833
Graphics / Re: setFramerateLimit(x) vs. setVerticalSyncEnabled(true)
« on: August 09, 2012, 09:12:57 pm »
Would class like this be safe?
class SafeRW : public sf::RenderWindow
{
public:
        SafeRW(void);
        SafeRW(sf::WindowHandle handle,const sf::ContextSettings& settings = sf::ContextSettings()):
        sf::RenderWindow(handle,settings){}
        SafeRW(sf::VideoMode mode,const std::string& title,sf::Uint32 style = sf::Style::Default, const sf::ContextSettings& settings = sf::ContextSettings()):
        sf::RenderWindow(mode,title,style,settings){}
        virtual ~SafeRW(void){};
        void setFramerateLimit(unsigned int limit)
        {

                sf::RenderWindow::setVerticalSyncEnabled(false);
                sf::RenderWindow::setFramerateLimit(limit);
        }
        void setVerticalSyncEnabled(bool enabled)
        {
                sf::RenderWindow::setFramerateLimit(0);
                sf::RenderWindow::setVerticalSyncEnabled(enabled);
        }
};

1834
Graphics / setFramerateLimit(x) vs. setVerticalSyncEnabled(true)
« on: August 09, 2012, 03:01:47 am »
How do these two work together in a RenderWindow, mainly:
1. If both were called, is the limit used the the smaller/bigger one of them two, or one that was put on the screen with last call or something else?

2. Is there a way to get max fps that these two permit RenderWindow to have?

3. If setVerticalSyncEnable(true) is called first, then setFramerateLimit(x) with x being smaller than max fps permitted by vertical sync and then setFramerateLimit(0) is called, is limit now again what vertical sync permits or there is no limit at all?

1835
Graphics / Re: SFML 2 views
« on: August 09, 2012, 12:52:51 am »
Center is the point that is currently in the center of view in sfml coordination system.
Size is the size of view's rectangle, in the center of that rectangle is the center of the view.
Center of view's rectangle is the center of the view.
So your view is streched between 4 points:
TopLeft:
x = (center.x-size.x/2)
y = (center.y-size.y/2)
TopRight:
x=(center.x+size.x/2)
y=(center.y-size.y/2)
BottomRight:
x=(center.x+size.x/2)
y=(center.y+size.y/2)
BottomLeft:
x=(center.x-size.x/2)
y=(center.y+size.y/2)

sf::View is created by default with size of 1000x1000 and center at (500,500) maybe try initialize it with your render windows default view first.
Can you show some code examples of your problem?

1836
General / Re: Coordinates system
« on: August 08, 2012, 06:34:47 pm »
I'm asking if there is something that makes system with y pointing up such loved system to the point where people want sfml to change to it: other multimedia library? some rad tool?(im sure borland's vcl has y poiting down)  gamemaker language?
I didn't know box2d defines a coordinates system, where does it do it?

1837
General / Re: Coordinates system
« on: August 08, 2012, 04:34:49 pm »
Can I ask why 'y axis pointing up x axis pointing right' coordinates system has such cult following with anyone who wants to use box2d?

1838
Graphics / Re: How to display texture on things drawn by sf::VertexArray
« on: August 05, 2012, 06:39:08 pm »
Ok, thanks.

1839
Graphics / How to display texture on things drawn by sf::VertexArray
« on: August 05, 2012, 05:36:42 pm »
I understand all primitive types and how they treat every point but I don't think I understand how to texture anything.
Am I supposed to 'just' pass sf::RenderStates object with pointer to my texture in draw call like that?
        sf::RenderWindow app(sf::VideoMode(500,500),"test");
        sf::VertexArray ver(sf::Quads,4);
        sf::Texture test;
        test.loadFromFile("Old_Resources/est.tga");
        ver[0]=sf::Vertex(sf::Vector2f(0.f,0.f),sf::Vector2f(0.f,0.f));
        ver[1]=sf::Vertex(sf::Vector2f(128.f,0.f),sf::Vector2f(128.f,0.f));
        ver[2]=sf::Vertex(sf::Vector2f(128.f,128.f),sf::Vector2f(128.f,128.f));
        ver[3]=sf::Vertex(sf::Vector2f(0.f,128.f),sf::Vector2f(0.f,128.f));
        sf::RenderStates states;
        states.texture = &test;
while(1)
{
        app.clear();
        app.draw(ver,states);
        app.display();
}
 

1840
Graphics / Re: Making the draw origin in the bottom left
« on: August 05, 2012, 05:29:07 pm »
You can swap it. Just treat box2d coordinates like the sfml ones. The higher the y the lower the object is. Set your gravity to b2Vec2(0.f,9.8f), that way there is absolutely no +/- work to be done between box2d and sfml, but you still have to remember to convert meters to pixels and radians to degrees.

1841
General / Re: My scrolling appears quite jerky..
« on: August 05, 2012, 03:44:19 pm »
That's true but he's doing a float around 13,(3) movement each frame so that 'tearing' might be from this.
That vector complain reminded me: maybe if you have A LOT of tiles (like - enough to fill screen several times) then instead of iterating through all of them you can get the points of your view rectangle and only display what fits between them by dividing top bottom left and right by tilesize(if it's constant) and then using these to iterate part of the vector.

1842
General / Re: My scrolling appears quite jerky..
« on: August 05, 2012, 03:16:03 pm »
1.Why are you doing sf::Keyboard::isKeyPressed with every single event you process? It should be changed to checking if there was event of key press AND the key pressed was escape or put outside the event loop.

2. 1280x640 doesn't seem like valid full screen resolution(it isn't for me, I checked), you must run isValid() on your VideoMode or use one of resolutions returned by sf::VideoMode::getFullscreenModes() to make sure that you're using valid fullscreen resolution, because fullscreen doesn't work with all resolutions like window does. I think that might be it, but you must check with your rig to see if that resolution is valid for you.

3. In 1.6 windows used to hold references to views and if it went out of scope then interesting things happened and it was (at least for me) unituitive because view doesn't seem like something heavy to copy/store/create.

4. You must do .setSmooth(true) on texture your sprites use or it'll look ugly after any float rotation/movemenet/scaling, in 2.0 it isn't true by default like in 1.6.

1843
General / Re: Anyone know about this code example?
« on: August 03, 2012, 06:39:08 pm »
Could it be this(it's other loop but still list and hard to find tutorial)?
40 MainMenu::MenuResult MainMenu::HandleClick(int x, int y)
41 {
42   std::list<MenuItem>::iterator it;
43
44   for ( it = _menuItems.begin(); it != _menuItems.end(); it++)
45   {
46     sf::Rect<int> menuItemRect = (*it).rect;
47     if( menuItemRect.Bottom > y
48       && menuItemRect.Top < y
49       && menuItemRect.Left < x
50       && menuItemRect.Right > x)
51       {
52         return (*it).action;
53       }
54   }
55
56   return Nothing;
57 }
That's from game from scratch c++ edition part 3 : http://www.gamefromscratch.com/page/Game-From-Scratch-CPP-Edition-Part-3.aspx

Pages: 1 ... 121 122 [123]