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

Pages: [1]
1
General / Upgrading SFML and Cmake
« on: April 13, 2017, 07:20:33 pm »
Hi folks.  Since y'all suggested I upgrade SFML, I am trying to do that.

Here's my problem, and I've already found a few posts about it but they aren't solving my issues.
I downloaded SFML 2.4.2, GCC 6.1.0 MinGW (DW2) - 32-bit (I'm using codeblocks)

In my cmake files (I have two projects, one is a library I created and one is my game), I changed:
find_package(SFML REQUIRED COMPONENTS audio network graphics window system)
to
find_package(SFML 2.4 REQUIRED COMPONENTS audio network graphics window system)

Cmake did not complain a bit about either change, said it had successfully found 2.4.2, and everyone was happy.  I made sure too, that the SFML include directory was correct, and that the correct .dll files were listed.

When I compiled my library, everything went fine.
When I compiled my game, I got warnings that sf::Text.setColor() was deprecated, which seemed to me to indicate that the linking had worked.

Then, I got 40 undefined references.

I have tried everything I could find by googling, and haven't had success.  Here are my cmake files:
JollyLava (my library)

project(JollyLava CXX)
cmake_minimum_required( VERSION 2.6 )

# Set version information in a config.h file
set(myproject_VERSION_MAJOR 0)
set(myproject_VERSION_MINOR 1)

# Name of this library.
set(LIBRARY_NAME "JollyLava")

#
# --- Our CMake settings
#
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules" ${CMAKE_MODULE_PATH})

# Place libraries in the root BUILD directory.
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) # static
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) # dynamic

#
# --- Dependencies
#

# SFML
find_package(SFML 2.4 REQUIRED system window graphics network audio)
include_directories("${SFML_INCLUDE_DIR}")

# Box2D
find_package(Box2D REQUIRED)
include_directories("${BOX2D_INCLUDE_DIR}")

# Include headers.
include_directories(${CMAKE_SOURCE_DIR}/include)

# C++ source code.
add_subdirectory(src)

#
# --- Install
#
install(DIRECTORY include DESTINATION lib)
 

and JollyZorbit (my game)
project(JollyZorbit CXX)

cmake_minimum_required(VERSION 2.6)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules" ${CMAKE_MODULE_PATH})

#set(EXECUTABLE_NAME "JollyZorbit")
#add_executable(${EXECUTABLE_NAME} main.cpp)

find_package(JollyLava REQUIRED)
include_directories("${JOLLYLAVA_INCLUDE_DIR}")

find_package(SFML 2.4 REQUIRED audio network graphics window system)
include_directories("${SFML_INCLUDE_DIR}")
# Note - if I enable the following line I get the error "Cannot specify link libraries
# for target "debug" which is not built by this project"
#target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES})


find_package(Box2D REQUIRED)
#set(BOX2D_LIBRARY C:/Box2D_v2.2.1/build/Box2D/libBox2D.a)
#set(BOX2D_INCLUDE_DIR C:/Box2D_v2.2.1/)
include_directories("${BOX2D_INCLUDE_DIR}")

find_package(Steamworks REQUIRED)
include_directories(${STEAMWORKS_INCLUDE_DIR})

# Include headers.
include_directories(${CMAKE_SOURCE_DIR}/include)

# C++ source code.
add_subdirectory(src)

#set_property(TARGET JollyZorbit PROPERTY WIN32_EXECUTABLE true)

Does anyone have any thoughts on what is wrong?  I am obviously quite a CMake newb, so please don't assume I know anything about what I'm doing.

Edit:  Here's a little extra info:
http://imgur.com/a/o5kpe

2
Hi there.  I'd just like to re-raise this issue.

I would love to be able to have an sf::Text with a multiline string have a function to "center" the text.

In other words
it would look like
this.

It is very much a bummer that I have to use a separate sf::Text for every line of my ~100 line credits...

Any update on this idea?

3
Graphics / How many is "a lot" of sf::Sprites?
« on: December 09, 2016, 05:14:06 am »
From the FAQ:

"My FPS count drops when drawing a lot of sprites."

How many is "a lot?"  I feel like I might be reaching that point, but I've probably got about... 100-200 sprites in my level?

Related question: does SFML ignore my draw() calls if whatever I'm drawing isn't on screen?

4
Graphics / Dealing with large textures
« on: December 07, 2016, 09:22:32 pm »
Hi folks.

So, I recently began plugging in some textures into my biggest level yet.  I have about 20k by 20k pixels worth of graphics to get in there.

I've split the large image into about 20 4kx4k textures.  I can add about 10 of them and my level editor works no problem.  As I approach 15, my graphics card starts bugging out and I hit the Windows TDR limit (https://msdn.microsoft.com/en-us/library/windows/hardware/ff570087(v=vs.85).aspx).

I've increased my TDR limit, but I'm still hitting it, and I also feel that it doesn't really solve the issue which seems to be: I am asking too much of my GPU.

The files altogether are only 12 MB.  I have about 35 MB worth of graphics in another level and it runs smooth as butter, both in my level editor and in game.  The texture sizes are smaller, and I know(?) SFML only draws what's on screen, so it might be that with these large texture sizes SFML has to draw the whole thing when only a little bit might actually be on screen.  That's my best guess so far.

Does anyone have any recommendations for how to proceed?

EDIT: Further thought: If I should just use smaller textures, does anyone know of a good automated way to split a large picture into several small ones?

5
Window / When I create a fullscreen window, it's bigger than my screen
« on: November 04, 2016, 07:32:07 pm »
Hi folks.  I've been developing a project on my desktop for a long time, but when I compiled on my laptop something strange happened.  When I create the renderWindow, it goes into fullscreen (as expected), and outputs the correct size (1920x1080) if I ask for renderWindow->getSize(), but the content of my project doesn't fit on the screen.

Here is the code, as simple as it gets:
_rw = new sf::RenderWindow();
_rw->create(sf::VideoMode::getFullscreenModes()[0], name(), sf::Style::Fullscreen);

And here are some images illustrating the problem:
http://imgur.com/a/bYkKp

Now, I've even tried simply compiling the SFML example app that comes with SFML 2.0 and I get the same problem.  Which means either my computer is doing something weird, or SFML is doing something weird, but not my code.  If the former, any tips on what I may have done? If the latter, are you aware of this issue? (Yes, I know there are newer versions of SFML and I'll upgrade if I have to but....)

6
Window / Moving joystick counts as a button press...???
« on: September 15, 2016, 04:21:24 pm »
Disclaimer: I'm using SFML 2.0...

I'm very confused.  I'm trying to implement a way for the player of my game to customize their controls.

Basically, they highlight the action they want to change, let's say, "Jump."  They press A, which indicates that the game should now "listen" for a button press and set whatever button to be the "Jump" button.  Just like any game you've ever played that allowed custom controls.

However, if I set my bool _listening to true and then move the joystick, it's recognizing the joystick having been moved as a "button press" and sets the button value to either 0 for the x axis or 1 for the y axis.

How the heck do I fix this?  I really feel like moving the joystick should not be triggering a button pressed event.  The offending code:

else if (_controlsSetup && _listening)
    {
        // leaving this code here just in case it's a matter
       // of {'s or }'s
        if (event.type == sf::Event::KeyPressed)
        {
            if(event.key.code == sf::Keyboard::Return)
            {
                _keyToStore = "";          // Indicates what action (jump, shoot) the key press is for
                _buttonToStore = "";     // ditto for controller buttons.
                _listening = false;
            }
            else if(_keyboardSettings)
            {
                game()->settings()->keyIs(_keyToStore, event.key.code);
                _keyToStore = "";
                _listening = false;
            }
        }
        if (event.type = sf::Event::JoystickButtonPressed)
        {
            // SOMEHOW we are arriving here despite no buttons being pressed, only the joystick being moved.
            if(_controllerSettings)
            {
                _listening = false;
                game()->settings()->buttonIs(_buttonToStore, event.joystickButton.button);
                _buttonToStore = "";
            }
        }
    }

As always, any help is deeply appreciated.  I imagine it's something dumb but...

7
Graphics / My SFML project occasionally BSOD's me
« on: August 05, 2015, 03:52:37 am »
Hi folks.

Unfortunately, this has to be a very general question because I have no idea where in my code this error might be from.  The project is pretty large, too, but if anyone can point me to the kind of code that might produce the error, I can post code, hopefully.

I have a program that I have made that is basically a level-editor for a game that I am making.  Every once in a while when I test the level (in other words, run my Game class and give it the level data, opening a new sf::RenderWindow) I get a blue screen of death with the error "DRIVER_IRQL_NOT_LESS_OR_EQUAL (dxgmms1.sys).  It also happens sometimes when I dereference the Game instance and close the second RenderWindow.

Apparently this kind of error results from:
Quote
This indicates that a kernel-mode driver attempted to access pageable memory at a process IRQL that was too high.  This appears to be a typical software driver bug and is not likely to be caused by a hardware problem.
(Taken from an example dump file, not mine).

Suggested fixes for this problem have been "uninstall and reinstall your graphics driver," which I have done and it does not solve the problem.  I imagine it is that my code is interacting with DirectX or openGL in some way and doing some sort of bad memory access, and I worry that when I release the game, this might happen to a user, which would be very bad.

When this first happened, I checked my code and discovered some memory leaks, which I have now mostly tracked down (still leaking 1mb or so every time I test the game), but my last crash happened with only 43% memory usage.

I have the bad feeling that it is my fault and not my driver... does anyone have any ideas?

EDIT:  Just thought I'd mention I'm running Windows 8.1

8
Hi there.  Y'all have been very helpful in the past, so I turn to you again! I hope this question hasn't been asked many times.  I did a search and didn't see anything on it so...

When the player in my game dies, I want all sf::Sounds and sf::Musics playing to stop for a (hopefully) dramatic effect.  Kind of like when you die in MegaMan.

When I call to my SoundManager class (which is very basic, mostly std::maps to hold sf::Sound and sf::Musics) to stop all playing sounds and musics, it works, but then my game lags like crazy.

Here is the relevant code, as far as I can tell:

    void SoundManager::stopAll()
    {
        stopAllSounds();
        stopAllMusic();
    }

    void SoundManager::stopAllSounds()
    {
        if(_soundVolume == 0)
            return;

        std::map<string, Sound::Ptr>::iterator itr;
        for (itr = _sounds.begin(); itr != _sounds.end(); itr++)
        {
            itr->second->stop();
        }

    }

    void SoundManager::stopAllMusic()
    {
        if(_musicVolume == 0)
            return;

        std::map<string, sf::Music*>::iterator itr;
        for (itr = _musics.begin(); itr != _musics.end(); itr++)
        {
            itr->second->stop();
        }
    }

 

Now, I'm wondering whether iterating over the map is just eating my memory, or if I'm not supposed to be storing and using Sounds this way and should instead be using a soundBuffer... but who knows.  I don't really understand what the point of a SoundBuffer is, even though I've read the documentation.  I am not well versed in sound file technology and terminology.

Any help would be much appreciated!

9
Window / Taking multiple screenshots in succession
« on: October 04, 2014, 09:46:47 pm »
Hi guys.  I haven't turned to you all for help in quite a while, but you're always so helpful when I do.  Anyway, if anyone can help I will very much appreciate it.

I have essentially built a level editor to create large maps for a game.  I'd like to compile a whole map into one image so I can edit it in photoshop (my artist takes the "skeletons" I create in the editor and then fills them in.  Like color-by-numbers).

I've compiled a few maps by manually moving the screen, taking a screenshot, then pasting it into paint and fitting all the screenshots together.  Needless to say, this is a huge pain in the ass.  So, I'd like to convince my program to do it for me.  Here's my code:
void SaveLoad::saveLevelImage(std::string fileName)
{
    // Loop through and capture each section of the level.
    for(int viewX = 0; viewX < _editor->_mapWidth; viewX += 1920)
    {
        for(int viewY = 0; viewY < _editor->_mapHeight; viewY += 1080)
        {
            std::stringstream path;
            path << "levels/" << fileName << "/map/" << fileName << viewX << "." << viewY << ".png";

            sf::Image screenToSave;
            screenToSave = _editor->renderWindow()->capture();
            screenToSave.saveToFile(path.str());

            _editor->_contentView.move(0, 1080);
        }
        // After completing a column, return the window back to the top.
        _editor->_contentView.setCenter(_editor->_contentView.getCenter().x, 540);

        // Move over to the next row and start over.
        _editor->_contentView.move(1920, 0);
    }
}
 

When I run the code, the expected files appear in the directory I specified, but they're all blank.  I don't know if SFML simply can't handle my request to capture the screen and save it so many times so quickly or what. 

I was thinking I'd later use a python script to actually combine the images into one, but if I can't get this part to work, then that's not going to be useful.  However, if anyone has any thoughts about combining both steps into one, that would be awesome as well.

Thank you!

10
Window / Second RenderWindow going nuts (OpenGL related)
« on: December 11, 2013, 05:44:21 pm »
Hello, everyone.  Let me preface this by saying I know pretty much zilch about OpenGL.  I shall also say that none of these problems occurred when I compiled with g++ on Windows 7.  These problems are all occurring now that I am trying to run my program on OSX 10.8.5.

The program I am building is a level editor for a game I am making.  In the editor, you can save and test the level you are working on.  In Windows, you press a hotkey and a new RenderWindow appears, loading the level you just created and you can play it and everything is peaches and magic.

When I began trying to build this thing on OSX, I ran into the following problem:

When my second window opens, it looks like someone threw up on the screen.  I can't describe what comes up other than graphics card chaos.  Or, every once in a while, it just comes up black.  The sounds that should play do, and nothing crashes, so it really does appear just to be a problem with graphics.

If, I switch focus to another window, and then switch focus BACK to the test game window, it begins drawing normally.  Which is nice, but it would sure be swell if it worked the first time.

Additional details:
1.) In Windows, I can close the test game window and test again just fine as many times as I like. In OSX, when I test a second time, the screen displays without the throwup on it, but it doesn't update.
2.) My project is giving me linker errors to OpenGL when I try to use any OpenGL methods, which I could fix but I'd rather not have another library dependency if I don't have to.

Related code:
This comes from my Editor.cpp, which basically runs the level editor:
void Editor::loop()
{
    while (true)
    {
        if(_running) // Editor is on
        {
            // Process input for the editor.
            processInput();
           
            // Prepare for drawing.
            _rw->setActive(true);         // _rw is my render window.
            _rw->pushGLStates();        // no idea if this is helping
            _rw->clear();

            // Update all objects.
            _objectMan->update();
           
            // Draw all objects.
            _rw->setView(_contentView);
            _objectMan->draw();

            // Call display on the render window.
            _rw->popGLStates();      // again, no idea if this is doing anything.
            _rw->display();

        }
        else if(_testGame)  // An instance of TestGame class is running.
        {
            _rw->pushGLStates();
            _testGame->run();
           
            // When finished
            _testGame = NULL;
            _rw->popGLStates();
            _running = true;
        }
    }
}
 

I won't bother posting the code, but I will mention that in Editor::ProcessInput(), pressing ctrl + t sets _testGame to a new TestGame() and sets Editor::_running to false.

Here's the code in TestGame::gameLoop():  (Actually is Game::gameLoop() which is TestGame's superclass.)
void TestGame::gameLoop()
{
    while (_running)
    {
        // Get the active state from the StateManager.
        State::Ptr activeState = _stateMan->activeState();

        // If activeState is null, then we're done with the game.
        if (!activeState) break;

        // Process input for the game and for the active state.
        processInput(activeState);

        // Update the state.
        activeState->update();

        // Prepare for drawing.
        _rw->setActive(true);     // Seems like it should be here but I really don't even know.
        _rw->clear();

        // Draw the state.
        _rw->pushGLStates();     // Do I need this?
        activeState->draw();
        _rw->popGLStates();      // Who knows?

        // Call display on the render window.
        _rw->display();
    }

}

Thanks, as always, for your help.  I'm hoping that this problem is all created by me being a dummy rather than a super complicated OpenGL mess that is going to mean learning OpenGL backward and forward.  But if that's what I must do then I suppose I will do it!

11
General / Trouble creating an SFML 2.0 CodeBlocks project file in Cmake
« on: January 29, 2013, 06:06:26 pm »
Hello all.  I have read through a bunch of threads on this forum that talked about similar problems and I made a lot of progress, but there is something weird which is happening that none of those threads quite addressed.  So forgive me if this has been asked a million times.

I'm currently getting the following error when trying to configure:
CMake Error at cmake/Modules/FindSFML.cmake:199 (message):
  SFML found but version too low (requested: 2.0, found: 1.x)
Call Stack (most recent call first):
  CMakeLists.txt:25 (find_package)

I am quite definitely using SFML 2.0.  I even redownloaded the release candidate to make sure.

To help give some context, right before receiving this error, I had gotten an error saying CMake could not find SFML (I dunno what's up with the FindSFML.make or what I did to get that message).  I fixed it by added an SFMLDIR path to C:/Program Files(x86)/SFML 2.0 where I have it installed.  That let me continue on until I encountered the error above.  Any ideas?

12
Graphics / How to best handle Textures
« on: December 29, 2012, 09:48:59 pm »
Hello all.  I've gotten some wonderful help here in the past, and my friend and I have a problem that we can't seem to answer ourselves, so we thought we'd turn to you.

We are developing a game with some fairly intricate animations.  Some of our characters have as many as 70 different frames across their running, jumping, etc. animations.

We are currently loading one texture for each character and each frame setting that character's sprite to a different subrectangle of the texture (which seems to be the preferred method around here).  As suggested here: http://en.sfml-dev.org/forums/index.php?topic=9855.0

Here is our problem:
When we had others try our game on their machines, many of them encountered problems as our textures were too large.  Many reported an error that said their maximum texture size was 1024 x 1024.  That seems tiny.  (EDIT: Many of our sprite frames are around 200 x 200 or even 300 x 300 pixels in size to retain image quality.  We could make them smaller and scale them up, but it looks bad) Is this a reasonable maximum texture size?  How new of a system would someone need to increase the maximum to, say, 8192 x 8192? Especially considering if we have animation frames that are 100 x 100 (doesn't seem unreasonable), that means we can only have about 10 animation frames per texture if we go 1024 x 1024.

Should we load multiple textures and cycle through them?  Should we create multiple sprites and cycle through those?  How do we deal with this limited texture size?

Here are the hypothetical approaches we discussed: (Objective is efficient, GPU-independent display of animations)
1. Load a texture for each frame of an animation.  Obviously this comes with a greater load time.
2. Load a single texture from one of two files: a large texture for strong machines and a scaled-down, smaller texture for slower machines. Scale the sprite up for the slow machines. (We tried this and it looks awful)

We checked out Thor's Animation library which has bigTexture and bigSprite.  We are curious how that works exactly.  Does the library need to be in a writable directory?  In other words, is it creating new files somehow?  If so, that could be problematic.  If not, it seems like it might be our answer.

13
Window / <SOLVED> sf::View keeps resetting its zoom factor.
« on: November 29, 2012, 06:38:59 pm »
Hello friends.  I have a bit of a problem that I know must have a very simple answer, but I have been working on it for 2 days now with no avail.

I have created a "Camera" wrapper-class for sf::View.  It allows me to set a "target" and then the view will "glide" to it.  It also has a Zoom() method that will have it zoom in incremental steps toward a desired distance.

However, whenever a "glide" or "zoom" finishes, and the following block of code gets activated, it's resetting the zoom to the original factor, which displeases me greatly.

Any ideas?
(Note: There's some Box2d involved, so if something looks like it came out of nowhere, it probably has to do with that).
bool Camera::Update(sf::RenderWindow * rw)
{
if(!isGliding && !isFixed && !isZooming)      //normal camera function
    {
        //get the position of the current target
        if(!targetIsVec)
        {
            targetPos = zoToolbox::b22sfVec(_target->GetRootBody()->Getb2Body()->GetPosition());
            _targetAngle = -zoToolbox::b22sfAngle(_target->GetRootBody()->Getb2Body()->GetAngle());
        }
        else
            targetPos = _targetVec;

        //Update the view based on the target's current location.
        _view = rw->getView();                                               //i imagine the culprit must be one of these lines
        _view.setCenter(targetPos);
        _view.setRotation(_targetAngle);
        _view.setSize(rw->getSize().x, rw->getSize().y);
    }
 

Here's the code that actually handles zooming, which also appears in the Update() method. _zoomSteps is a number calculated elsewhere that tells the camera how many times it needs to zoom to get from where it started to where it needs to end up (basically makes a zoom happen over time instead of immediately).
if(isZooming)
    {
        if(_zoomSteps > 0)
        {
            std::cout << "zooming " << _zoomSteps << std::endl;
            _view.zoom(_zoomSpeed);
            _zoomSteps--;
        }
        else
        {
            std::cout << "zoom completed" << std::endl;
            _currentZoom = _view.getViewport();
            isZooming = false;
        }
    }
 

Any help would be greatly appreciated.  Thanks so much!

14
Hello all.  I have a program that contains a list of "points" (which are just what they sound like).  These points are represented on screen by a point.png.

If I have a lot of points on the screen (50+?)  the program eventually crashes, even without user input, and displays the follow error message several times, though NOT as many times as there are points.

Quote
Failed to load image "images/point.png". Reason: Corrupt JPEG
Image /images/point.png failed to load.

Now, first of all, it ain't a JPEG file, so how can it be corrupt?  Also, if I change the image path to point.jpg, it STILL gives me this same error message.  I don't use point.png anywhere else in my code.

Can anyone help me make sense of this error message and how I can address it?

15
Graphics / Apparent conflict between View and Mouse
« on: June 12, 2012, 09:07:40 pm »
Hello all.  I'm currently working on a program that's sort of like a drag-and-drop level editor.  I'd like to be able to move the view around using WASD (which I have working), but I also have events that place objects in relation to the mouse's current position.

When I move the view at runtime, Mouse::getPosition() doesn't update to account for the fact that the view has moved.  In other words, if I move the view 3 steps to the left and then drop an object, it drops it 3 steps to the right of where my mouse is.

I'm not sure that posting any particular code will help, as it seems more of a logical problem than a coding conflict, but here is the code for both operations:
if(sf::Mouse::isButtonPressed(sf::Mouse::Left) && keyDown == false)
            {
                mousePosition = sf::Mouse::getPosition(*App);

                if(!pointManager->IsPoint(*App) && pointManager->GetNumLoopPoints()%2 != 0)
                {
                    pointManager->AddPoint(new Point(mousePosition.x, mousePosition.y, "edge"));
                }
                keyDown = true;
            }

and this:
 if (Event.type == sf::Event::KeyPressed)
            {
                switch(Event.key.code)
                {
                    //move the camera with WASD
                    case sf::Keyboard::W:
                        view.move(0, -4);
                        App->setView(view);
                        break;
                    case sf::Keyboard::S:
                        view.move(0, 4);
                        App->setView(view);
                        break;

Any insights would be very much appreciated!

Pages: [1]