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.


Topics - TheGuerilla

Pages: [1]
1
Graphics / Spritesheets or individual images?
« on: July 12, 2016, 01:07:30 am »
Kind of a random question out of the blue, but would it be faster to load in one "master" spritesheet with all your game images then create the sprites off of rectangles of that texture, or individually load each image as a texture and bind the sprites?

2
Title states it pretty well. Basically, I have a bit of code that automatically applies a given shader to the whole screen (Assuming the shader pointer is not null), and when I re open the windows it crashes. It would be easier to explain this with a gif. (Sorry, can't embed imgur gifs because they technically aren't gifs)

Anyway, here is the exact code where it crashes. (I know it says "Code: C" but this is actually C++)
if (vScreenShader != nullptr && !vSkipFrameShader && vGameWindow->hasFocus()) {
        // Check that the screen texture is the same size as the screen
        if (vScreen.tex.getSize().x != vWindowWidth || vScreen.tex.getSize().y != vWindowHeight) {
                vScreen.tex.create(vWindowWidth, vWindowHeight);
                vScreen.spr.setTexture(vScreen.tex);
        }

        vScreen.tex.update(*vGameWindow);
        vScreen.spr.setTexture(vScreen.tex);

        // Account for current shader and view
        sf::View currentView = vGameWindow->getView();
        sf::Shader* currentShader = (sf::Shader*)vRenderState.shader;

        vRenderState.shader = vScreenShader;
        vGameWindow->setView(vGameWindow->getDefaultView());
        vGameWindow->draw(vScreen.spr, vRenderState);

        vRenderState.shader = currentShader;
        vGameWindow->setView(currentView);
        }
It crashes at line 8 when I try to update the texture with the window. The window used to crash when I minimized it, but when I added the "&& vGameWindow->hasFocus()" to line 1, it fixed that problem. I don't know what I'm doing wrong, I've tried looking for another function to stop this block of code like "if window is opening" or "is minimized," but nothing. I don't know if this is important, but this code works when the window is open. (The gif shows off a sick scanline shader) How do I stop it from updating when the window is regaining focus?

thanks in advance

3
Python / Python bindings?
« on: June 01, 2016, 12:41:31 am »
I'm not sure if this is the right place for this, but it seems fitting. I am curious as to how you take C++ source and bind the functions/classes to Python. How did the person who made PySFML do it?

Thanks


EDIT: After a lot of research I found a few possibilities, and the method that the PySFML creator used.

4
Window / How to toggle fullscreen?
« on: May 09, 2016, 12:41:37 am »
So after reading up on fullscreen in SFML, I came up with this little function:
void SED::RenderHandle::SEF_SetFullscreen(bool fullscreen) {
        if (fullscreen)
                SEV_GameWindow->create(sf::VideoMode(SEV_WindowWidth, SEV_WindowHeight, 32), SEV_WindowTitle, sf::Style::Fullscreen);
        else
                SEV_GameWindow->create(sf::VideoMode(SEV_WindowWidth, SEV_WindowHeight, 32), SEV_WindowTitle);
}
Obviously it doesn't work, it just crashes the program and sets the monitor to 640 * 480 (the previous resolution), but my question is, what did I do wrong? When I read the documentation, it said that sf::Window::create can be used to recreate the window, not just initialize it. So I assumed recreating it with the fullscreen flag would work? I also tried it with using sf::VideoMode::getFullscreenModes()[0] instead of sf::VideoMode(SEV_WindowWidth, SEV_WindowHeight, 32) for fullscreen, and that seemed to keep the monitor size, but still crashed the program.

So I guess what I'm asking is how do you activate/toggle fullscreen?

5
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

6
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;

        view.setRotation(rot);
        view.zoom(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.

7
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++) {
    window.setView(views[i]);
    window.draw(playerSprite);
to draw it to all views, or can I just draw it to the default one? The documentation is fairly confusing with this issue.

Thanks

8
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.

9
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?)

10
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.

Thanks

Pages: [1]
anything