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
1
General discussions / Re: Mixing graphics libraries on C++
« on: July 17, 2016, 02:16:43 am »
Bro...it's funny because it's like...what SFML dont have that SDL have I can use...I have heard that SFML on android dont support shaders but SDL support...but I also say that we can use one library called GLSL to better shaders effects...so In SFML on Android I can use GLSL to use shaders?
As DarkRoku said, SFML uses OpenGL ES 1, which does not support shaders. That said, if you do plan on using SDL just for cross platform shaders, it is worth noting that implementing shaders in SDL is astronomical levels more difficult than it is in SFML unless you know how to use the OpenGL api.

2
Vulkan
To my understanding, Vulkan was supposed to be the next OpenGL version, but it was so wildly different and non backwards compatible they just released it under a new name.

Here is a quick rundown on low level graphics apis
  • DirectX is a Microsoft only api that is used on everything Microsoft (Windows, Xbox, phones)
  • OpenGL is a cross platform api that works on most devices
  • Vulkan is supposed to be the next greatest thing to make games even better
  • Metal is Apple's attempt at DirectX, very few use it. (Apple products only)

3
General / Re: Compile SFML in android
« on: July 14, 2016, 04:00:26 am »
The Android C++ environment C4Droid could probably do it, since it is capable of building native C++ programs that use Qt and SDL.

4
Graphics / Re: Clicking on a Sprite to highlight it
« on: July 14, 2016, 03:47:47 am »
First off, I would make a function to check if a given coordinate is within a given bounding box; pointInRectangle is what I usually call it. That function would look like
inline int clamp(int val, int min, int max) {
    val = val < min ? min : val;
    val = val > max ? max : val;
    return val
}

inline bool pointInRectangle(int x, int y, int x1, int y1, int x2, int y2) {
    return (clamp(x, x1, x2) == x && clamp(y, y1, y2) == y);
(You need clamp to make pointInRectangle even easier to read)
With that function, you could just say
int x sf::Mouse::getPosition().x;
int y sf::Mouse::getPosition().y;
int x1 = sprite.getPosition().x;
int y1 = sprite.getPosition().y;
int x2 = sprite.getPosition().x + (sprite.getScale().x * 275);
int y2 = sprite.getPosition().y + (sprite.getScale().y * 275);
if (pointInRectangle(x, y, x1, y1, x2, y2) && sf::Mouse::isButtonPressed(sf::Mouse::Left)) {
    // Do stuff...
}
Of course you could remove all the variables I set there, I just hate looking at that much within parameters.

5
Graphics / Re: Spritesheets or individual images?
« on: July 12, 2016, 07:29:47 am »
I managed to clock in at 8192, considering my graphics is very low end. So realistically if I keep my spritesheets 4096 or below, very few people would be unable to run it.

Thank you to both of you!

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

7
Okay, so I gave your method a try, and while digging through the documentation noticed a few other inefficient things I was doing; but long story short, it works. I will eventually test the speed difference, but it's certainly a lot easier to work with than the last method.

thanks!

8
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

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

10
Window / Re: How to toggle fullscreen?
« on: May 10, 2016, 05:36:20 am »
(I'm assuming since this is a day later, this isn't a bump. Sorry if it is...)

Okay so I couldn't tell you what went wrong even if I wanted to, but what I did was after switching to fullscreen, I added a variable that waits a frame until re-adding the whole screen shader (the problem line), and that seemed to fix everything. I got the idea from this Github issue, which would lead me to believe that the issue is not limited to Linux.

Anyway, thanks for the help you guys!

11
Window / Re: How to toggle fullscreen?
« on: May 09, 2016, 01:43:19 am »
Sadly, its a valid pointer. I tested if it was either NULL or nullptr before calling that, and it is not a null pointer.

12
Game looks pretty damn good. Any vague idea when a release will be availible?

13
Window / Re: How to toggle fullscreen?
« on: May 09, 2016, 01:22:21 am »
Well, you're right, I wasn't resizing the texture, so I fixed that part by setting the window width/height variables after calling that function; then before the screen is rendered and shaders are applied, it runs this code to make sure that the texture is up to spec with the screen size
if (SEV_Screen.tex.getSize().x != SEV_WindowWidth || SEV_Screen.tex.getSize().y != SEV_WindowHeight) {
                SEV_Screen.tex.create(SEV_WindowWidth, SEV_WindowHeight);
                SEV_Screen.spr.setTexture(SEV_Screen.tex);
        }
A few more printf's revealed that SEV_WindowWidth/Height are the right size (1366 and 768 respectively), yet now I just get this error.

That error occurs when
SEV_Screen.tex.update(*SEV_GameWindow);
is called; but I know that the texture is the right size. (I also tested the texture size)

(Btw thanks for the help thus far)

14
Window / Re: How to toggle fullscreen?
« on: May 09, 2016, 01:03:27 am »
Yes, I forgot to include the crash info.

Sorry for the big image size, I had to capture the whole screen through ShareX because I couldn't get snipping tool to work there.

I also get this in the console window

(I was also unable to just straight copy the contents of the console for some reason...) I have no idea what either of those errors mean, so I'm quite clueless on this issue.

15
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?

Pages: [1] 2
anything