* Renamed test to DirectWindowStars.
* Some changes to make it run in the test environment. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15466 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,7 +1,15 @@
|
||||
SubDir HAIKU_TOP src tests kits game direct_window_test ;
|
||||
|
||||
SimpleTest direct_window_test
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
AddSubDirSupportedPlatforms libbe_test ;
|
||||
|
||||
SimpleTest DirectWindowStars
|
||||
: Stars.cpp StarWindow.cpp
|
||||
: game be root
|
||||
: game be
|
||||
;
|
||||
|
||||
if ( $(TARGET_PLATFORM) = libbe_test ) {
|
||||
HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : DirectWindowStars
|
||||
: tests!apps ;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ enum {
|
||||
CRC_KEY = 0x1789feb3
|
||||
};
|
||||
|
||||
|
||||
StarWindow::StarWindow(BRect frame, const char *name)
|
||||
: BDirectWindow(frame, name, B_TITLED_WINDOW, 0)
|
||||
{
|
||||
@@ -76,7 +77,6 @@ StarWindow::StarWindow(BRect frame, const char *name)
|
||||
|
||||
// initialise the default state of the star array
|
||||
for (i = 0; i < star_count_max; i++) {
|
||||
|
||||
// peek a random vector. This is certainly not the nicest way
|
||||
// to do it (the probability and the angle are linked), but that's
|
||||
// simple and doesn't require any trigonometry.
|
||||
@@ -178,17 +178,23 @@ StarWindow::StarWindow(BRect frame, const char *name)
|
||||
SetSizeLimits(40.0, 2000.0, 40.0, 2000.0);
|
||||
|
||||
// If the graphic card/graphic driver we use doesn't support directwindow
|
||||
// in window mode, then we need to switch to fullscreen immediatly, or
|
||||
// in window mode, then we need to switch to fullscreen immediately, or
|
||||
// the user won't see anything, as long as it doesn't used the undocumented
|
||||
// shortcut. That would be bad behavior...
|
||||
if (!BDirectWindow::SupportsWindowMode()) {
|
||||
bool sSwapped;
|
||||
char *buf;
|
||||
BAlert *quit_alert;
|
||||
key_map *map;
|
||||
|
||||
key_map *map;
|
||||
get_key_map(&map, &buf);
|
||||
sSwapped = (map->left_control_key==0x5d) && (map->left_command_key==0x5c);
|
||||
|
||||
if (map != NULL) {
|
||||
sSwapped = (map->left_control_key == 0x5d)
|
||||
&& (map->left_command_key == 0x5c);
|
||||
} else
|
||||
sSwapped = false;
|
||||
|
||||
free(map);
|
||||
free(buf);
|
||||
quit_alert = new BAlert("QuitAlert", sSwapped ?
|
||||
@@ -205,10 +211,9 @@ StarWindow::StarWindow(BRect frame, const char *name)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
StarWindow::~StarWindow()
|
||||
{
|
||||
long result;
|
||||
|
||||
// force the drawing_thread to quit. This is the easiest way to deal
|
||||
// with potential closing problem. When it's not practical, we
|
||||
// recommand to use Hide() and Sync() to force the disconnection of
|
||||
@@ -217,6 +222,8 @@ StarWindow::~StarWindow()
|
||||
// window destructor and kill your drawing thread...
|
||||
kill_my_thread = true;
|
||||
delete_sem(drawing_lock);
|
||||
|
||||
status_t result;
|
||||
wait_for_thread(my_thread, &result);
|
||||
|
||||
// Free window resources. As they're used by the drawing thread, we
|
||||
@@ -224,13 +231,17 @@ StarWindow::~StarWindow()
|
||||
free(star_list);
|
||||
}
|
||||
|
||||
bool StarWindow::QuitRequested()
|
||||
|
||||
bool
|
||||
StarWindow::QuitRequested()
|
||||
{
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
return(TRUE);
|
||||
return true;
|
||||
}
|
||||
|
||||
void StarWindow::MessageReceived(BMessage *message)
|
||||
|
||||
void
|
||||
StarWindow::MessageReceived(BMessage *message)
|
||||
{
|
||||
int8 key_code;
|
||||
|
||||
@@ -253,7 +264,9 @@ void StarWindow::MessageReceived(BMessage *message)
|
||||
}
|
||||
}
|
||||
|
||||
void StarWindow::CrcStep()
|
||||
|
||||
void
|
||||
StarWindow::CrcStep()
|
||||
{
|
||||
// basic crc pseudo-random generator
|
||||
crc_alea <<= 1;
|
||||
@@ -261,7 +274,9 @@ void StarWindow::CrcStep()
|
||||
crc_alea ^= CRC_KEY;
|
||||
}
|
||||
|
||||
void StarWindow::DirectConnected(direct_buffer_info *info)
|
||||
|
||||
void
|
||||
StarWindow::DirectConnected(direct_buffer_info *info)
|
||||
{
|
||||
// you need to use that mask to read the buffer state.
|
||||
switch (info->buffer_state & B_DIRECT_MODE_MASK) {
|
||||
@@ -285,6 +300,7 @@ void StarWindow::DirectConnected(direct_buffer_info *info)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// This function update the internal graphic context of the StarWindow
|
||||
// object to reflect the infos send through the DirectConnected API.
|
||||
// It also update the state of stars (and erase some of them) to
|
||||
@@ -292,7 +308,8 @@ void StarWindow::DirectConnected(direct_buffer_info *info)
|
||||
// in DirectConnected, it's a bad idea to do any heavy drawing (long)
|
||||
// operation. But as we only update the stars (the background will be
|
||||
// updated a little later by the view system), it's not a big deal.
|
||||
void StarWindow::SwitchContext(direct_buffer_info *info)
|
||||
void
|
||||
StarWindow::SwitchContext(direct_buffer_info *info)
|
||||
{
|
||||
star *s;
|
||||
int32 x, y, deltax, deltay;
|
||||
@@ -490,9 +507,11 @@ void StarWindow::SwitchContext(direct_buffer_info *info)
|
||||
cy_old = cy - info->window_bounds.top;
|
||||
}
|
||||
|
||||
|
||||
// This is the thread doing the star animation itself. It would be easy to
|
||||
// adapt to do any other sort of pixel animation.
|
||||
long StarWindow::StarAnimation(void *data)
|
||||
long
|
||||
StarWindow::StarAnimation(void *data)
|
||||
{
|
||||
star *s;
|
||||
int32 x, y;
|
||||
|
||||
Reference in New Issue
Block a user