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

Pages: 1 [2]
Graphics / Re: Apply shader to whole screen?
« on: May 08, 2016, 09:40:57 pm »
Thanks! The latter suggestion seems good for my situation.

Graphics / Apply shader to whole screen?
« on: May 08, 2016, 08:51:51 am »
(I know I messed up a couple times and put some topics in this wrongfully, but I'm like 99% sure this is the right thread for this question.)

So I've got GLSL shaders/sf::Shader to work now with some test shaders (Basically just setting the pixel black...), and now I'm wondering if its possible to apply a shader to the whole screen; since you can't apply something like a scanline or blurring shader to each individual drawn thing; it would look atrocious.

Thanks in advance

Graphics / Re: Crash when resetting view
« on: May 07, 2016, 07:35:01 pm »
You were right, the pointer calling this function hadn't been initialized. Thanks a ton!

Graphics / Crash when resetting view
« on: May 07, 2016, 08:39:07 am »
This is probably a stupid question, but humor me anyway. When I call sf::View::reset I get this nice little throw

When I looked this up, I found one of the admins say that SFML doesn't throw exceptions, so I don't know what the deal is there. This is the actual code I use where its called:
void SER::View::setup(float x, float y, float width, float height, float rot, float scale, float portX, float portY, float portW, float portH) {
        view.reset({ x, y, width, height });

        this->x = x;
        this->y = y;
        this->width = width;
        this->height = height;
        viewX = portX;
        viewY = portY;
        viewW = portW;
        viewH = portH;
        this->rot = rot;
        this->scale = scale;


        if (portW == -1) {
                viewW = view.getViewport().width;
                viewH = view.getViewport().height;
As you can see, that is a function, that has a definition in a header file like this:
void setup(float x, float y, float width, float height, float rot = 0, float scale = 1, float portX = 0, float portY = 0, float portW = -1, float portH = -1);
(I'm assuming that part is important because it has default arguments.)

When I call it, I set the x/y/width/height to -32,0,320,240 (The size of the window starting at -32.), and I get that nice little crash right away. The crash happens at the reset call, I know because I used printf to test it and the VS debugger is backing that with the break arrow, so no question there.

So I guess is what did I do wrong? Sorry if this is a stupid question, I just find the sf::View class to be really confusing.

Graphics / Re: How do views work?
« on: May 06, 2016, 10:33:30 pm »
I did not, nor did I realize there was one. I will read it right now, thanks!

Graphics / How do views work?
« on: May 06, 2016, 08:24:17 pm »
I don't quite understand how they work. I assumed originally that I could just define a view width/height/port width/height and have it display that portion of the game world, but it appears otherwise. Say I want to draw the player to the all the 4 views, because for the purpose of this example this is a 4 player split screen game. When I render the player do I have to do something like
for (int i = 0; i < views.size(); i++) {
to draw it to all views, or can I just draw it to the default one? The documentation is fairly confusing with this issue.


General / Re: Problem locking framerate
« on: April 12, 2016, 03:09:17 am »
If SEV_Framelock is 60 seconds (and you converted to microseconds), allocFrameTime will be 0, because 1,000,000/60,000,000 is 0.0166 and allocFrameTime is an integer type.

Then between < allocFrameTime will always be false (except I don't know what between holds).

But why do you want to sleep anyway? Are you using threads?
no the integer value of SEV_FrameLock is 60, so it is just 1,000,000 / 60 which is ~16,666. As for blaming this on the sleep function, I have delta timing so it's not an issue that way, it just that if I say I want to lock it at 60, I would like the framerate around anywhere from 60-65ish, not 100.

But I didn't know that function existed. Imma give it a go right now.

EDIT: After using that magical function, it caps the framerate well. Thanks!

General / Problem locking framerate
« on: April 11, 2016, 01:16:47 am »
When I locked the framerate, I was assuming that to stay at 60 FPS, you take the amount of time 60FPS would be in microseconds minus the time it took to actually process the frame and sleep that long; however, it doesn't work for me.
uint64_t allocFrameTime = 1000000 / SEV_Framelock;
if (between < allocFrameTime)
        sf::sleep(sf::microseconds(allocFrameTime - between));
between is of course the time the frame took to process in microseconds, and SEV_Framelock is 60. However, when I use this code, the game runs at ~100 fps. Uncapped, it reaches ~900 FPS. What am I doing wrong? I don't want it capped at 100, I want it at 60.

General discussions / Re: Keyboard array?
« on: March 25, 2016, 06:36:52 pm »
It's really easy to create such an array yourself - a couple of lines of code.

    std::map<int,bool> keys; // Add this somewhere in a class or where it doesn't get destroyed
    // ---
    sf::Event event;
    while(window.pollEvent(event)) {
        switch(event.type) {
            case sf::Event::KeyPressed:
                keys[event.key.code] = true;
            case sf::Event::KeyReleased:
                keys[event.key.code] = false;

every key's state can be checked with keys[sf::Keyboard:<key>]

Dude I had no idea I could do this. Thanks a ton!

General discussions / Keyboard array?
« on: March 25, 2016, 06:13:38 am »
One of the few things I really liked about SDL was the fact that the keyboard could be gathered from an array; because I could store a record of the last frame by just copying the contents of the array into another and testing for key presses and releases by comparing the two. I don't like testing really anything inside the event poll, so is there any sort of array of the keyboard states in SDL? And if not, is there any other way than checking for key presses/releases than in the event poll? (Perhaps a functions?)

General discussions / Re: SDL2 Speed vs SFML?
« on: March 21, 2016, 11:19:33 pm »
For the most part the performance is more or less the same.

If you want an exact answer for your situation, you'd have to port your engine to SFML and benchmark it. Alternatively, do like Laurent said and make a small benchmark (wont give you exact results, but close enough).
I'm porting it right now. I guess we'll find out. I'm sure hoping its at least the same, because SFML is so much easier to use than SDL2.

EDIT: So I ported the core of the engine and tested it out, and it has about the same performance; so I'm really happy about that. I will definitely be using SFML instead.

General discussions / SDL2 Speed vs SFML?
« on: March 20, 2016, 09:58:27 pm »
I understand that SFML's speed beats SDL 1.2 by a landslide, but I am making a game engine right now that utilizes SDL2's new hardware-acceleration. So has anyone made a test that compares SDL2's hardware acceleration speed to SFML's speed? If SFML is still faster, I will definitely switch the entire engine to it.


Pages: 1 [2]