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

Pages: [1]
1
General / Some questions about optimizations
« on: December 02, 2012, 07:10:56 pm »
I have been using SFML for some time now but have not written anything with a large amount of objects or that is fairly complex, and have been instead trying to learn the engine and how it works by making smaller projects. I am now finally working on my first larger-scale project, and am running into the issues of optimization for the first time. Rather than specific excerpts of code, I would rather simply like some guidance and suggestions about how to optimize things in SFML.

The first thing I am trying to learn how to better optimize would be drawing. I already have a system that only renders objects that are visible in a view, however often times there are a very large amount of objects visible and I believe that drawing all of these objects is definitely having an impact on my program slowing down. Right now I draw objects in a simple for loop that goes through a vector of objects and does a RenderWindow.draw() for all of them that are on screen. I have read a bit about VertexArray but I'm not sure if it would really be much more efficient for me as all of the objects in my program are moving, and none are static. I also tried to create depth buffer of objects to avoid over-drawing, but that turned into something way more complex than I am able to understand at the moment.


I am also trying to optimize my collision detection, and after doing some reading I have found that a QuadTree sounds like my best option for doing this, so I have started working on an implementation for that. The issue I am facing is that every tutorial that I have found about QuadTrees seems to assume that every object being added is the same size, when in the case for my program this is not the case. If I have large objects that might be larger than a single node in my tree and thus require collision checks in other nodes I am not sure how to implement something that would be able to handle varying object sizes.

One last optimization I am wondering about is directional movement. Right now I use trigonometry to calculate how each object should move based on the angle it is moving in, but I've read that trigonometry is a fairly inefficient and slow method to use, although I have not found any alternatives. Are there any good and efficient methods that you know of to calculate directional movement that do not use or are more efficient than trigonometry?

These are the first optimizations that I am trying to work on, but any other suggestions for things to try optimizing would be greatly appreciated as well because this is my first time facing optimization as a real issue. Any help would be great! Thank you!

2
Audio / Re: Crashing When Program Closes with sf::Music
« on: April 30, 2012, 12:27:27 am »
I updated my post to be more clear and direct to the problem. I also did make sure that it is using the correct DLLs and is loading them as well. I tested my program with the exact same DLLs and SFML version on another computer that is running Windows 7, and did not have the error on that computer, so I think the problem is exclusive to Windows XP (Service Pack 3), for me at least.

3
Audio / Crashing When Program Closes with sf::Music
« on: April 29, 2012, 11:36:17 pm »
Hello, I am working on trying to get Music working in my project, and have run into a strange issue where regardless of what I do with an sf:Music object, even if I simply only have one declared at all and regardless of where in my program it is declared, the program crashes or breaks when main() returns. I am using the SFML 2.0 RC on Windows XP Service Pack 3, if that makes any difference.

Other sounds play and work perfectly fine and the music plays fine if I have code in to load and play it, however regardless of whether that code is in or not it still crashes on exit.

Edit: I have tested the program on a computer running Windows 7 with the same Dlls and SFML version, and the error is not reproduced on it, so this seems to be an issue that is exclusive to Windows XP Service Pack 3, or at least for me.

Here is some code to show the issue:

Code: [Select]
#include <SFML/Audio.hpp>
 
int main()
{
sf::Music test;

        //It crashes with or without the following sf::Music related lines
        test.openFromFile("test.ogg");
        test.play();
        test.stop();

        //It also crashes with the same error with or without a main game loop
        //and window, so I removed the main game loop and render window code
        //from this snippet.
       
        return 0;
}

This is what comes up in the output box in VC++ when it crashes on exit:

Quote
First-chance exception at 0x004653cc in SFML Basic Build.exe: 0xC0000005: Access violation reading location 0x00a3c820.
Unhandled exception at 0x004653cc in SFML Basic Build.exe: 0xC0000005: Access violation reading location 0x00a3c820.

Any help on this would be greatly appreciated,

Thanks!

Here is a screenshot of the program crashing on exit when built as a release build and run from the exe:




~~Tofugames

Pages: [1]
anything