Hi,
I´m still at searching why apps that use fbo crash on mingw.
As the msvc-binaries work I look for differences between mingw and msvc.
One of them is threads. In the mingw-faq it says that you shouldn´t use
CreateThread:
______________________MINGW_FAQ
As MinGW uses the standard Microsoft C runtime library which comes with
Windows, you should be careful and use the correct function to generate
a new thread. In particular, the CreateThread function will not setup
the stack correctly for the C runtime library. You should use
_beginthreadex instead, which is (almost) completely compatible with
CreateThread.
Failure to do this will lead to a small loss of memory if you use a
large number of threads. However, it can also lead to the stack becoming
misaligned, with disasterous consequences if MinGW starts emitting SSE
instructions. In particular, the movaps instruction assumes that memory
is aligned to a 16-byte boundary. MinGW (or, rather, the GCC compiler)
handles this, but it assumes that the stack starts on a 16-byte
boundary. Using _beginthreadex ensures this.
I believe that if you do not wish to use any C library functions, then
CreateThread will work fine. However, _beginthreadex does the same job,
and is safer.
______________________END_MINGW_FAQ
I tried to change the OpenThreads code to use _beginthreadex, but I got
those errors:
../Win32Thread.cpp: In static member function `static void
OpenThreads::ThreadPrivateActions::PrintThreadSchedulingInfo(OpenThreads::Thread*)':
../Win32Thread.cpp:133: warning: unused variable 'pd'
../Win32Thread.cpp: In member function `int OpenThreads::Thread::start()':
../Win32Thread.cpp:328: error: invalid conversion from `long unsigned
int (*)(void*)' to `unsigned int (*)(void*)'
../Win32Thread.cpp:328: error: initializing argument 3 of `long unsigned
int _beginthreadex(void*, unsigned int, unsigned int (*)(void*), void*,
unsigned int, unsigned int*)'
../Win32Thread.cpp:328: error: invalid conversion from `long unsigned
int*' to `unsigned int*'
../Win32Thread.cpp:328: error: initializing argument 6 of `long unsigned
int _beginthreadex(void*, unsigned int, unsigned int (*)(void*), void*,
unsigned int, unsigned int*)'
../Win32Thread.cpp:328: error: invalid conversion from `long unsigned
int' to `void*'
../Win32Thread.cpp:328: error: initializing argument 1 of `void
OpenThreads::HandleHolder::set(void*)'
I don´t know what unsigned int (*)(void*) is (I´m embarrased about it,
but I usually only program C++ and have seldom to do with void*) and how
I could cast that to work.
It´s just a wild guess with the threads, but maybe really _beginthreadex
should be used when on mingw, should´nt it?
Regards,
Andreas
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/