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

Pages: [1]
1
Audio / [C++] (1.5) Using loop points in sf::Music
« on: October 08, 2009, 01:36:40 am »
This is what I came up with:

Code: [Select]

#include <SFML/Audio.hpp>
#include <iostream>
#include <string>

void LoopedMusicDelegate( void* ptr );

class LoopedMusic : public sf::Thread {
private:
sf::Music mBeginningMusic;
sf::Music mLoopingMusic;

public:
LoopedMusic( const std::string& beginFilename, const std::string& loopFilename )
: sf::Thread( LoopedMusicDelegate, this )
{
// Ignore errors for now
mBeginningMusic.OpenFromFile( beginFilename );
mLoopingMusic.OpenFromFile( loopFilename );

mLoopingMusic.SetLoop( true );
}


void Play() {
mBeginningMusic.Play();
Launch();  // Run thread
}

// TODO:
// Add Stop() 'n' stuff...

private:
friend void LoopedMusicDelegate( void* );

void Run() {
while ( mBeginningMusic.GetStatus() != sf::Music::Stopped )
;
mLoopingMusic.Play();
}
};

void LoopedMusicDelegate( void* ptr ) {
reinterpret_cast<LoopedMusic*>( ptr )->Run();
}



int main() {
LoopedMusic m( "SampleMusicIntro.wav", "SampleMusicLoop.wav" );

m.Play();

// Wait for user input:
std::cin.get();
}


Basically it waits until the introduction music finishes playing and then plays the looping music.  Sometimes the introductions of some of the sample music can be anywhere from one second to six seconds.  This works for a handful of the musics I have separated, unfortunately for a few, there's a distinct pause between the end of the intro music and the beginning of the looping music.  I have double checked the SampleMusic*.wav files and there are no pauses and they transfer smoothly in a media player.

Any ideas?

2
General / Can't get SFML 1.4 to work properly!
« on: April 02, 2009, 07:55:29 pm »
Quote from: "Laurent"
Yep, you probably have a USB joystick ;)
Unplug it and try again.


 :shock:
Thanks again! It works completely now!   :D

But seriously ... WTF?!

3
General / Can't get SFML 1.4 to work properly!
« on: April 02, 2009, 07:14:55 pm »
Quote from: "Laurent"
You should not use pragmas to setup your linker. Do it in your project's settings.  ... Use your project settings ;)



Thanks!

It works with the static libraries, however, I get the same problem linking to the dynamic libraries -- the program freezes somewhere in ntdll.dll before the program runs.

Any idea why?

4
General / Can't get SFML 1.4 to work properly!
« on: April 02, 2009, 09:32:15 am »
Code: [Select]

#include <sfml/System.hpp>
#include <sfml/Graphics.hpp>
#include <sfml/Window.hpp>
#include <iostream>

// #define STATIC

#ifdef STATIC
# ifdef DEBUG
# pragma comment( lib, "sfml-graphics-s-d.lib")
# pragma comment( lib, "sfml-window-s-d.lib")
# pragma comment( lib, "sfml-system-s-d.lib")
# else
# pragma comment( lib, "sfml-graphics-s.lib")
# pragma comment( lib, "sfml-window-s.lib")
# pragma comment( lib, "sfml-system-s.lib")
# endif
#else
# ifdef DEBUG
# pragma comment( lib, "sfml-graphics-d.lib")
# pragma comment( lib, "sfml-window-d.lib")
# pragma comment( lib, "sfml-system-d.lib")
# else
# pragma comment( lib, "sfml-graphics.lib")
# pragma comment( lib, "sfml-window.lib")
# pragma comment( lib, "sfml-system.lib")
# endif
#endif

int main( int, char*[] )
{
sf::RenderWindow rw(sf::VideoMode(800, 600), "SFML window");

std::cout << "Hello world.\n";

return 0;
}


The code above compiles and links without any errors or warnings with the dynamic libraries.  However, it does not run; when I break the execution, the program seems to be stuck in an infinate loop inside ntdll.dll.

I tried linking with the static libraries, with only this warning:
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library

The program runs and the window displays, unfortunately, on its way out I get this message:
"Run-Time Check Failure #2 - Stack around the variable 'rw' was corrupted."


Adding this code after rw is declared ...:

rw.Clear( sf::Color( 255, 0, 0 ) );

... Resulted in this message on exit:
"A buffer overrun has occurred in sfml-arg-d.exe which has corrupted the program's internal state."

Ignoring the MSVCRT library breaks all the other libraries with Unresolved External Symbols.  I tried the same thing with the tutorial code, with the same results.  I get the same results trying to mix my code linking with the "Multithreaded Deubg DLL" and "Multithreaded Debug" versions of the runtime library.   I've also tried rebuilding the SFML 1.4 libraries, but unfortunately it didn't change anything.  Viewed the static-built exe and the dynamic-linked exe under dependency walker, with nothing appearing out of the ordinary...

So...
I can't use SFML 1.4 dynamic libraries, since it locks up before the program loads, and I can't use SFML 1.4 static libraries, because it's buggy and unpredictable.


What's the heck is going on?!   :evil:

5
Graphics / PostFX question, controlling affected area
« on: October 19, 2008, 10:16:08 pm »
Ah, so it is not currently possible.   :(

Thanks, I will research alternative methods.

6
Graphics / Re: normalize vector
« on: October 19, 2008, 06:53:10 am »
Quote from: "ravenheart"

 in order to keep my pace i have to normalize the vector, am i right?


Correct.

Quote from: "ravenheart"

when i divide my original vector by this above ( i called it temp)
my vector should have lenght 1;


Correct.

Quote from: "ravenheart"

but trying it my Sprite moves VERY slow;



It's because your movement vector is only one unit in length.  :wink:
Try placing:  Sprite_Mouse = Sprite_Mouse * 5; before returning Sprite_Mouse, and it should move 5 times faster

7
Graphics / PostFX question, controlling affected area
« on: October 18, 2008, 11:59:01 pm »
Quick question(s):

Can I apply a shader to a certain area on the screen?  I need to apply a mask over a tile (for every tile) in a breakout-style game.  Is there any significant overhead I should know about when drawing a PostFX?  If I can't apply a shader to certain areas of the screen per tile x60/s, can I use a separate texture, i.e. render target, to render my masks onto?

Thanks for any responses!  
__fastcall

EDIT:
I have tried setting PostFX's scale and position, which rendered the result of the shader (the whole entire screen) onto the area.

8
General / SFML Precision (C++)
« on: September 28, 2008, 12:07:30 am »
Is there any significant reason SFML uses floats instead of doubles?  I know that OpenGL API likes to use floats, but if doubles are as fast as floats, why not use doubles and pick up some extra precision?  :D

EDIT:
After searching the forums and reading this topic, I've concluded that a temporary solution would be to derive my own double-precision sprite class.  But the question remains, why use floats?

Pages: [1]