|
||||||||||||||||||
Add Forum to Favorites | Send Topic To a Friend | View Forum FAQ | Track this topic |
Last Thread Next Thread ![]() |
| Handy PC/Mac OS X Snippets for Indie Development |
|
![]() Promit Moderator - Graphics Programming and Theory Member since: 7/29/2001 From: Baltimore, MD, United States |
||||
|
|
||||
| Just want to point out that using WMI's VideoController information is probably a much more reliable way of looking up video RAM than using DX5. |
||||
|
||||
![]() SanityAssassin Member since: 3/11/2004 From: Vista, CA, United States |
||||
|
|
||||
| Thanks a ton for these snippets... They are very helpful! |
||||
|
||||
![]() silvermace Member since: 4/6/2002 From: Auckland, New Zealand |
||||
|
|
||||
| I believe that round() function will only work for positive numbers. simple fix: int Round( float x ) { float direction = 0.5f; if( x < 0.0f ) direction = -0.5f; return static_cast<int>( x + direction ); } and a while I'm at it, more C++ oriented replacement for itoa() #include <string> template< typename T > std::string std_itoa( T const& val ) { std::stringstream ss; std::string ret; ss << val; ss >> ret; return ret; } // need to specialize for constant strings, stringstreams dont like spaces. std::string std_itoa(const char* val) { return std::string(val); } "I am a donut! Ask not how many tris/batch, but rather how many batches/frame!" -- Matthias Wloka & Richard Huddy, (GDC, DirectX 9 Performance) http://www.silvermace.com/ -- My personal website |
||||
|
||||
![]() swiftcoder Member since: 7/3/2003 From: Boston, MA, United States |
||||
|
|
||||
| Usefull snippets, but I get the idea the article was written a while ago. I that you will find that Apple will deprecate AGL fairly soon in favor of CGL, since AGL is mainly there for Mac OS 9 compatibility, and OS 9 support is going with the Intel switch. Edit: I see that the deprecation is already happening, albeit maybe not intentionally. Apple has deprecated several non-AGL functions neccessary to create a fullscreen render context in AGL, so although AGL is still in use, it may not be very useable for long. I haven't yet been able to coerse the CoreGraphics functions to be replacements for the deprecated functions, although there should be someway to do this. [Edited by - swiftcoder on January 11, 2006 12:22:24 PM] |
||||
|
||||
![]() evolutional Moderator - Alternative Game Libraries Member since: 1/25/2002 From: Leeds, United Kingdom |
||||
|
|
||||
| Useful tips, but I must criticse the way they're implemented. Specifically, the use of #ifdef throughout the code. If you're working on a large project with potentially many platforms this sort of coding can quickly lead to trouble. Instead I'd prefer to separate out the implementations for these platform/API specific functions into separate files, for example the file win_management.cpp which contains MessageBox and window setup code - it would have counterparts win_management_WIN.cpp, win_management_LIN.cpp and win_management_OSX.cpp. One tip I got off rick_appleton is that in the main .cpp file you could simple do your #ifdef check and include the relevant win_management_*.cpp file that way. Doing this maintains the portability you've suggested as well as made it more manageable overall. |
||||
|
||||
![]() Zaelsius Member since: 6/27/2004 From: Wien, Austria |
||||
|
|
||||
| Thanks for the comments. I guess most of them are right. About the WMI videoController thing, it looks like it is not available for Windows 98. That could be a problem if you plan to sell low-requirement shareware games. This morning I received an e-mail asking for a QueryPerformanceTimer replacement in Mac OS X. I recommended the Carbon function "Microseconds". Is there anything better? |
||||
|
||||
![]() kadaf Member since: 1/9/2000 From: Aalborg, Denmark |
||||
|
|
||||
Quote: Well, using QueryPerformanceTimer()-like functions are actually pretty dangerous, because their frequencies never are assured - they can change at any point during program execution. For instance that is the case with modern SpeedStep-like processor features where the clock frequency changes all the time. I'm not saying QueryPerformanceTimer() is useless, but you'll need a layer on top of it which makes it more reliable. GetTickCount() is safer, but you'll need to live with its much lower precission. Of course, if you only want a method to check how long a small portion of code takes to execute, you don't need to care about all this. |
||||
|
||||
![]() swiftcoder Member since: 7/3/2003 From: Boston, MA, United States |
||||
|
|
||||
Quote: The best function seems to be the Unix gettimeofday() (since OS X is a unix box...) |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| errr... just use libSDL ... it handles it all ;-) |
||||
|
||||
![]() swiftcoder Member since: 7/3/2003 From: Boston, MA, United States |
||||
|
|
||||
Quote: Actually, it covers a great deal of stuff no one ever seems to use, such as CD Audio playing, and it doesn't have a few very useful features, such as fullscreen-windowed context switching (without rebuilding the context), which are available from the OS. |
||||
|
||||
![]() Xeee Member since: 1/28/2001 From: al Jizah, Egypt |
||||
|
|
||||
| any idea about a function like Win32 ShellExecute that works under Mac OS X? to be more specific I want a function that opens the default browser(ShellExecute opens the default browser if it is given a URL as the program). thanks |
||||
|
||||
![]() swiftcoder Member since: 7/3/2003 From: Boston, MA, United States |
||||
|
|
||||
Quote: Not perhaps the safest method, but it works:
int result = system("open http://www.gamedev.net");
if (result == -1)
; // failure
system() is the standard C function, and open is an Apple (or at least NEXT) specific program that opens the specified file or URL with the correct program, as determined by the OS, so for a URL it will open the default browser. There should be a way to do this directly with a Carbon function, but I don't work in Carbon much and I don't know of one off hand. |
||||
|
||||
All times are ET (US)![]() |
Last Thread Next Thread ![]() |
|