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

Pages: [1]
1
So. My old development machine finally kicked the bucket. I'm on a new machine, a (somewhat) new environment, and trying to compile a program that worked just fine on the old machine on this new one.

The old machine was:
- Windows 7 basic (or whatever the very lowest version was)
- 32 bit
- Linking the static sfml2 libraries
- Using VS2010 express
- Worked like a champ!

The new machine is:
- Windows 7 ultimate
- 64 bit
- Linking the dynamic sfml2 libraries, which I re-compiled on this machine
- Still using VS2010 express
- Not working! :(

The program compiles just fine, but the second it starts, it crashes with the very helpful error message in the title.

Any ideas?

2
Audio / Passing sound buffers as references
« on: April 09, 2011, 06:25:05 pm »
So, I have a global resource manager. It has worked well with sprites so far, using the approach:
- Resource manager has sf::Image instances
- Any sprite that needs an image calls a reference to the appropriate sf::Image to use with SetImage

I tried doing the same with audio:
- Resource manager has sf::SoundBuffer instances, which load from files
- Any sf::Sound that needs to play first calls get_sound_buffer with the appropriate filename.

If I do this in main:
Code: [Select]
sf::SoundBuffer buf;
buf.LoadFromFile("Sounds\\Land.wav");
sf::Sound sound;
sound.SetBuffer(buf);
sound.Play();
while(sound.GetStatus() == sf::Sound::Status::Playing) { }


It works just fine.

However, when I try and use the resource manager:

Code: [Select]
file_cabinet.cpp:
(in the constructor) sound_map["ground_collide"].LoadFromFile("Sounds\\Land.wav");

sf::SoundBuffer &file_cabinet::get_sound_buffer(const std::string &Filename) {
    return sound_map[Filename];
}


(this is exactly the same as my get_image function, only replacing sf::Image with sf::SoundBuffers)

later, when I need to use a sound buffer:

Code: [Select]
sf::Sound sound;
sound.SetBuffer(file_cabinet.get_sound_buffer("Sounds\\Land.wav"));
sound.Play();
while(sound.GetStatus() == sf::Sound::Status::Playing) {}


wherever I need to invoke file_cabinet, I pass in a reference to the one file_cabinet object that exists, which is instantiated in main. This doesn't work -- there are no errors, but sounds do not play.

Is there something tricky I need to keep in mind for sound buffers?

3
Graphics / sf::priv::MutexImpl::Lock() Access Violation
« on: April 09, 2011, 01:18:55 am »
I updated my files from SFML 1.6 to 2.0. The program worked okay before; after making some necessary modifications because of the new code, my first run crashes.

Call stack:
Code: [Select]
ntdll.dll!76eb69e0()
  [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
> Mindjob.exe!sf::priv::MutexImpl::Lock()  Line 52 + 0xc bytes C++
  Mindjob.exe!sf::Mutex::Lock()  Line 62 C++
  Mindjob.exe!sf::Lock::Lock(sf::Mutex & mutex)  Line 39 C++
  Mindjob.exe!sf::GlResource::GlResource()  Line 53 + 0xd bytes C++
  Mindjob.exe!sf::Image::Image()  Line 52 + 0x47 bytes C++
  Mindjob.exe!std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,sf::Image,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::Image> > >::operator[](const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & _Keyval)  Line 215 + 0xb bytes C++
  Mindjob.exe!mj_file_cabinet::mj_file_cabinet()  Line 7 + 0x3e bytes C++
  Mindjob.exe!`dynamic initializer for 'cabinet''()  Line 20 + 0x28 bytes C++
  Mindjob.exe!_initterm(void (void)* * pfbegin, void (void)* * pfend)  Line 873 C
  Mindjob.exe!_cinit(int initFloatingPrecision)  Line 288 + 0xf bytes C
  Mindjob.exe!__tmainCRTStartup()  Line 262 + 0x7 bytes C
  Mindjob.exe!wmainCRTStartup()  Line 189 C
  kernel32.dll!75a91194()
  ntdll.dll!76ecb429()
  ntdll.dll!76ecb3fc()


The code in question (if I'm reading the call stack right):

Code: [Select]
mj_file_cabinet::mj_file_cabinet() {
// load our images
// TODO: error handling
image_map["megaman"].LoadFromFile("Sprite Sheets\\x_cut.jpg");
image_map["platform_1"].LoadFromFile("Sprite Sheets\\platform_1.png");
image_map["platform_2"].LoadFromFile("Sprite Sheets\\platform_2.png");

//load our sounds
//TODO: error handling here too
sound_map["ground_collide"].LoadFromFile("Sounds\\Land.wav");
}


"image_map" is declared in the header as std::map<std::string, sf::Image>.

Any ideas?

4
General / Unresolved linker externals
« on: April 07, 2011, 05:33:41 am »
Since I'm sure you guys get tons and tons of linker questions, I'll try and keep this snappy!

Environment:
- SFML 2 (latest Git download as of ~2330 EST on april 6th)
- Used CMake to generate a VS2010 project
- Used make and make-install in said VS2010 project; everything appeared to propagate correctly (odd sidenote: VS2010 didn't load an appropriate "make clean" build?)

Settings:
Preprocessor: SFML_STATIC
Linked files:
Code: [Select]
sfml-window-s-d.lib
sfml-graphics-s-d.lib
sfml-system-s-d.lib
sfml-audio-s-d.lib

Build type: Debug

The build output:
EDIT: Since the output was waaaaay larger than I thought, I put it all in a pastebin here.

5
Audio / libsndfile-1.dll causing a heap corruption?
« on: April 07, 2011, 03:36:48 am »
So I have in my program the line:

Code: [Select]

file_cabinet.h:

sound_map["ground_collide"].LoadFromFile("Sounds\\Land.wav");
sf::SoundBuffer &get_sound_buffer(std::string filename);



sound_map is a map<std::string, sf::SoundBuffer>.

later in another file:

Code: [Select]

sf::Sound sound;
sound.SetBuffer(file_cabinet.get_sound_buffer("Sounds\\Land.wav"));
sound.Play();


If I leave everything in, the application throws a heap corruption.

If I uncomment everything but the LoadFromFile line, it still throws it. If I uncomment only that line, it doesn't throw it, which says to me that something in LoadFromFile is going wrong.

The call trace:
Code: [Select]


  ntdll.dll!76e64513()
  msvcrt.dll!763198cd()
  libsndfile-1.dll!6f145dc1()
> Mindjob.exe!wmainCRTStartup()  Line 371 C
  kernel32.dll!76231194()
  ntdll.dll!76dfb429()
  ntdll.dll!76dfb3fc()



I triple-checked to make sure that there aren't any conflicting versions of libsndfile-1.dll or openal32.dll.

edit: To answer what I'm sure are common questions ...
- I made sure early on in the project that I haven't mixed up debug and release versions of the SFML libraries (I had to recompile them since the FAQ said that there were no current versions available for VC 2010).
- I'm using the libsndfile-1.dll and openal32.dll that are linked in the VC 2008 version of the C++ 1.6 package.

6
Graphics / Blank (white) Sprite -- can I pass a SubRect?
« on: March 30, 2011, 09:19:24 pm »
Hello friends,

My code's process is (in a nutshell) like so:
- a Player class declares and initializes an Animator class
- the Animator class holds said Player's sprite sheet, and is, among other things, responsible for passing back the appropriate sprite to draw at any given time
- the game requests said sprite whenever it needs to draw.

My sprite is showing up as a blank white box. My current theory is that the sprite's image is going out of scope at some point, but I can't figure out where.

Here are (I hope all of) the relevant bits (a bunch of fluff taken out unless requested):

mj_animator.h
Code: [Select]
class mj_animator
{
public:
    mj_animator(const std::string &Filename ... );
    mj_animator();
    sf::Sprite get_sprite();
private:
    sf::Sprite sprite_sheet;
    sf::Image img;
}


mj_animator.cpp
Code: [Select]
mj_animator::mj_animator(const std::string &Filename, ...) {
    if(! img.LoadFromFile(Filename)) {
        // error handling stuff
    }
    sprite_sheet.SetImage(img);
}

sf::Sprite mj_animator::get_sprite() {
    // some calculations to determine x1, y1, x2, y2 of an IntRect
    sprite_sheet.SetSubRect(sf::IntRect(x1, y1, x2, y2));
    return sprite_sheet;
}


mj_player.cpp
Code: [Select]
mj_player::mj_player(sf::Image sheet) {
    //animators is an array of mj_animators objects (in mj_player.h)
    animators[0] = mj_animator("file.jpg", ...);
    animators[1] = mj_animator("file.jpg", ...);
    current_animator = 1; //an int to track which animator currently being used
}

// ... some functions to determine which animator we need to have going at any given time, etc

mj_player::Draw(sf::RenderWindow &App) {
    // some calculations to determine current position
    sf::Sprite draw_sprite = animators[current_animator].get_sprite();
    draw_sprite.SetPosition(position.x, position.y);
    App.Draw(draw_sprite);
}


If there's anything you think you need, I'll put it -- I didn't include a lot of what I think is unrelated because it's already a fairly bloated post. :)

My best guess, as I said, is that either somewhere in the process, the image goes out of scope, or that I can't pass sprite_sheet back as I think I can.

Any guesses? Thanks.

edit:
I should note that through some debugging (read: a bunch of couts), I did determine that the math that I didn't include here is actually all correct -- that the SubRect is being correctly calculated, so it's not trying to draw some weird part of the image that doesn't exist or anything like that.

Pages: [1]
anything