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

Pages: [1] 2 3
1
General discussions / Possible bug in ... something?
« on: August 20, 2011, 02:34:48 pm »
I feel silly. http://www.sfml-dev.org/forum/viewtopic.php?t=5613 is talking about the same thing.

I think as long as the textures are destroyed before sf::RenderWindow::Close() is called, it's all good.

2
General discussions / Possible bug in ... something?
« on: August 19, 2011, 11:01:20 pm »
Upon closing a program, SFML causes an access violation in certain situations with sf::Texture. I'm using 64-bit Windows 7 and Visual Studio 2010. In VS, at program close, I get

Quote

"First-chance exception at 0x773532d0 in Test.exe: 0xC0000005: Access violation reading location 0x000008bcd188e2f8."
The thread 'Win64 Thread' (0x48c) has exited with code 0 (0x0).
The program '[4896] Test.exe: Native' has exited with code 0 (0x0).


The following code is a pretty good demonstration:

Code: [Select]

#define SFML_DYNAMIC
#include <SFML/Graphics.hpp>

#define ACCESS_VIOLATION

int main()
{
#ifdef ACCESS_VIOLATION
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Title");
#endif

    sf::Texture Texture1;
    if (!Texture1.LoadFromFile("sprite1.png"))
        return EXIT_FAILURE;

sf::Texture Texture2;
    if (!Texture2.LoadFromFile("sprite2.png"))
        return EXIT_FAILURE;

#ifdef ACCESS_VIOLATION
App.Close();
#endif
    return EXIT_SUCCESS;
}


The following code has the same behavior, which is confusing:

Code: [Select]

#define SFML_DYNAMIC
#include <SFML/Graphics.hpp>

#define ACCESS_VIOLATION

int main()
{
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Title");

    sf::Texture Texture1;
    if (!Texture1.LoadFromFile("sprite1.png"))
        return EXIT_FAILURE;

sf::Texture Texture2;
#ifdef ACCESS_VIOLATION
    if (!Texture2.LoadFromFile("sprite2.png"))
        return EXIT_FAILURE;
#endif

App.Close();
    return EXIT_SUCCESS;
}


Commenting out the #define ACCESS_VIOLATION results in no error.

3
General / deleting sf::Texture* - I must be doing it really wrong
« on: August 19, 2011, 05:08:11 am »
It's gone from confusing to strange, unfortunately. When debugging in Visual Studio, the debugger doesn't produce any errors at all, and it closes cleanly. When I run the exe outside of VS, windows detects something bad upon closing, and tells me to select a debugger to analyze it.

I took out all the image managing code, until it was just a single texture on the stack, and it still happens. This makes me think it's VS's fault, and I appear to fix it by setting the project from a console subsystem to a windows subsystem, and then changing the "int main()" to "int APIENTRY WinMain(...". The console no longer shows up, and the program appears to close without errors.

Why on earth does that make the program not close with an error? Is this really a fix or am I just hiding a memory leak? Bleh.

4
General / deleting sf::Texture* - I must be doing it really wrong
« on: August 19, 2011, 04:06:57 am »
I suspect I'm doing something very wrong here, but I'm not very experienced with STL.

Essentially, I load all of my images as sf::Texture objects on the heap, and store the pointers in a map.

Code: [Select]

//snippets:
//I use one of these
std::map<std::string, sf::Texture*> images;

//the load image function is like this:
sf::Texture *temp = new sf::Texture;
if( temp->LoadFromFile(fileName) == false )
return false;
images[imageKey] = temp;

//then at the end I iterate through the map and use delete on each pointer in the map


This creates some sort of heap corruption though, which makes me think I'm either making a huge memory leak somewhere or I'm deleting textures twice. What's going on here? Is it the map and using delete on the pointers, or am I screwing up the heap somewhere else and this is just where the heap is used again and the program notices?

5
General / Compiling SFML2 on 64-bit
« on: December 31, 2010, 04:01:42 am »
So I got a new laptop a few days ago (64-bit Windows 7), and I tried to install SFML2. I have Visual Studio 2010 Professional, and I have the 64-bit compiler already installed.

Using CMake, I tried both the Visual Studio 10 compiler and Visual Studio 10 64-bit, and while the standard compiler works fine, some of the examples didn't work. e.g. the shaders example immediately closes after I start it. So then I tried the 64-bit, and SFML doesn't even compile. I get a 130 linker errors for SFML graphics and audio. Example:


Error   83   error LNK2019: unresolved external symbol jpeg_set_defaults referenced in function "private: bool __cdecl sf::priv::ImageLoader::WriteJpg(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::vector<unsigned char,class std::allocator<unsigned char> > const &,unsigned int,unsigned int)" (?WriteJpg@ImageLoader@priv@sf@@AEAA_NAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator
@D@2@@std@@AEBV?$vector@EV?$allocator@E@std@@@5@II@Z)   C:\Users\Zack\sfml2\build\src\SFML\Graphics\ImageLoader.obj   sfml-graphics


I suspect it has to do with the external libraries that sfml-graphics and sfml-audio use, but I'm at a loss at what to do. And why don't the 32-bit compiled SFML samples work right?

6
General / No lib files outputed from visual studio Exp 2010
« on: April 25, 2010, 07:08:41 pm »
Aha! I think I've got it.

Visual C++ Express 2010 doesn't build an import library. When building SFML2, go into the project properties of one of the projects, let's say sfml-graphics.

Properties->Configuration Properties->Linker->Advanced

Where it says "Import Library", put "sfml-graphics-d.lib" if you're building the debug dll, or "sfml-graphics.lib" for the release dll.

Build sfml-graphics, and you'll get a "sfml-graphics-d.lib" in the sfml2\build\vc2008 directory. Copy that into the lib directory, and it'll be accessible like in vc2008.

EDIT: Laurent beat me to the solution! He's right, the imports weren't added.

7
General / No lib files outputed from visual studio Exp 2010
« on: April 25, 2010, 06:54:37 pm »
I also have this problem. I think the reason sfml-main has a .lib is because in the solution properties, it's set to be built as a static library.

I have no idea how to get the linker files, though.

8
Graphics / Changing Image of a Sprite do not work
« on: April 07, 2009, 11:52:26 pm »
I'm working on a strategy game right now, and I simply make a sprite of the spritesheet, and set a subrect to whatever animation frame it is doing. If the unit's image is changed, the subrect would stay the same. It simply makes sense that it does that. Changing the image changes the image.

9
Yes, I think it means that all the IDEs listed work.

10
Graphics / Detect click of a button on a matrix of buttons
« on: March 29, 2009, 03:13:19 pm »
Then what is not working?

11
Graphics / Detect click of a button on a matrix of buttons
« on: March 28, 2009, 11:18:36 pm »
Ah. That wouldn't cause an error then.

You're saying that when you click on a button, another button is being activated?

12
Graphics / Detect click of a button on a matrix of buttons
« on: March 28, 2009, 08:07:54 pm »
Assuming this is your matrix:

_______
|_|_|_|_|
|_|_|_|_|
|_|_|_|_|
|_|_|_|_|

Would cBotones be 16 or 4?

13
Graphics / Detect click of a button on a matrix of buttons
« on: March 28, 2009, 01:08:53 pm »
No, if you go past array bounds, it will compile fine but get a run-time error.

Assuming you got it to work, the reason you register multiple clicks is because you do not click as fast as the program runs. Instead, save the state of the mouse and when you check, just compare the current state to the last state-If it is different and the mouse is currently down, that is a click.

14
Graphics / Detect click of a button on a matrix of buttons
« on: March 28, 2009, 12:47:52 am »
I haven't looked at your code closely, but you check for the mouse being down twice. That won't cause it to not work, but is sort of unnecessary. Just take out:

Code: [Select]
&& ventana->GetInput().IsMouseButtonDown(sf::Mouse::Left)

This will be more efficient.

Also, it isn't that great to put everything onto one line, as it makes the code more difficult to read.

Edit:
What is cBotones? If this is a square matrix, your code might work, but if it is the total amount of buttons, you'll get an error. Can you describe the error you get, or does it not compile?

15
General / Custom cursor has low fps
« on: March 27, 2009, 01:33:08 am »
First of all, you set the maximum frame rate to be 60. It's not going to get faster than that. That won't make it refresh noticeably slowly, though. Under 20 fps is where it gets unacceptably slow.

Secondly, you don't assign an image or anything to the sprite. If you want just a plain colored square, perhaps you should use sf::Shape. I haven't seen this used before like what you are doing with the sprite, but maybe it works.

Also, you might want to use sf::Input for getting input. It's often easier, especially for key presses and mouse location.

Pages: [1] 2 3