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

Pages: [1]
1
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.

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

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

4
Audio / LoadFromSamples Function
« on: March 10, 2009, 11:48:43 pm »
I cannot get LoadFromSamples to work.

I get samples in the form of a  const sf::Int16 *. Since I can't change a const pointer directly, I copy all of the data to a buffer. I modify it, and then I try to load the buffer back to the sf::SoundBuffer.

Code: [Select]
const sf::Int16 * pSample = Buffer.GetSamples();

int max = Buffer.GetSamplesCount()-1;
int channels = Buffer.GetChannelsCount();
int sampleRate = Buffer.GetSampleRate();

sf::Int16 * myBuffer = new sf::Int16[max];

for( int i = 0; i < max; i++ )
{
myBuffer[i] = pSample[i];
}

//Modify myBuffer

Buffer.LoadFromSamples( myBuffer, max, channels, sampleRate );


I get the following error:
error C2662: 'sf::SoundBuffer::LoadFromSamples' : cannot convert 'this' pointer from 'const sf::SoundBuffer' to 'sf::SoundBuffer &'        Conversion loses qualifiers

I declare Buffer as:
Code: [Select]
const sf::SoundBuffer& Buffer = Recorder.GetBuffer();

Maybe I'm doing something wrong with references?

5
General / Access Violation at Program Close
« on: December 27, 2008, 09:34:47 pm »
I've spent the entire morning trying to get this working, but I still haven't gotten it to stop crashing.

Whenever I close the app, it breaks. In fact, it breaks right after the program hits "return 0;" It gives the following error message in VC++ Express:

First-chance exception at 0x0262cbab in demo.exe: 0xC0000005: Access violation reading location 0xfeeefef6.
Unhandled exception at 0x0262cbab in demo.exe: 0xC0000005: Access violation reading location 0xfeeefef6.

and a runtime error when launched through windows explorer:

Pure virtual function call. :(

In fact, the following code, which simply loads two images and shows them for 5 seconds, crashes at the end.

 
Code: [Select]

#define SFML_DYNAMIC

#include <SFML/Graphics.hpp>

int main()
{
sf::Clock timer;
sf::RenderWindow App(sf::VideoMode(200, 200, 32), "Demo App");

App.SetBackgroundColor( sf::Color( 255, 255, 255 ) );

sf::Image Image1, Image2;
if (!Image1.LoadFromFile("pic1.png"))
return 1;
if (!Image2.LoadFromFile("pic2.png"))
return 1;

sf::Sprite Sprite1(Image1);
sf::Sprite Sprite2(Image2);

sf::Sleep( 1.0 );

//Not drawing the sprites fixes the problem, but I don't want a blank game.
while( App.IsOpened() )
{
App.Draw(Sprite1);
App.Draw(Sprite2);
App.Display();

if( timer.GetElapsedTime() > 5.0 )
App.Close();
}

//Crashes right here.
return 0;
}


If I don't call App.Close(), the errors don't happen, but I'm pretty sure that App.Close() does some cleanup work that I shouldn't not do. I must be doing something wrong, in my code. It only happens when I use more than one image and sprite. Help!

6
Graphics / Antialiasing error for shapes
« on: December 26, 2008, 03:53:29 pm »
I'd like to smooth my shape edges, but setting up the window like this:

 
Code: [Select]
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "My App", Style::Close|Style::Resize, WindowSettings(32, 8, 2 ) );

Gives the error:

Failed to find a pixel format supporting antialiasing ; antialiasing will be disabled

Any other way I can do this without using a software renderer to antialias lines manually?

Pages: [1]
anything