|
I've created a new project based on your code, using C# and OpenTK. You can view that project on GitHub here: VirtualMachineSimulator
Feedback is appreciated!
|
|
|
|
|
This software is getting older. Are you going to update it?
|
|
|
|
|
I really like this screensaver.
The first time I saw it is on my co-worker's computer, impressing! my co-worker had copied this screensaver to me, but one day my system crashed, and I forget to backup this screensaver, and I forget the name of the screensaver, moreover, I had leaved that company, so I don't know how to get this screen, sad.
About one year later, it comes to me, the screensaver is so beautiful, I use google, and search "artificial life screensaver".
Thanks god, and thank you, I find it.
|
|
|
|
|
I don't see the point, considering no one has posted anything in what looks like 4 years. I'm haiving problems using this screensaver. When I try to preview this scr, or let it execute on it's own I get the following: "Runtime Error" Program: C:\Windows\System32\wvm.scr This application has requested the runtime to terminate it in an unusual way. Please contact the application's support team for more information. What am I doing wrong? I'm running windows xp and I've downloaded the latest directx software. How can I fix this?
Insomniac_Xx, The knower of nothing C++
|
|
|
|
|
Great job!
Happy Programming and God Bless!
Internet::WWW::CodeProject::bneacetp
|
|
|
|
|
BOOL CALLBACK MonitorBlankProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
{
UNREFERENCED_PARAMETER(dwData);
UNREFERENCED_PARAMETER(lprcMonitor);
UNREFERENCED_PARAMETER(hdcMonitor);
MONITORINFOEX monitorInfo;
memset(&monitorInfo, 0, sizeof(MONITORINFOEX));
monitorInfo.cbSize = sizeof(MONITORINFOEX);
if (GetMonitorInfo(hMonitor, &monitorInfo))
{
// Don't blank the primary monitor
if (monitorInfo.dwFlags != MONITORINFOF_PRIMARY)
{
HDC hdc = GetDC(NULL);
BitBlt(hdc,
monitorInfo.rcMonitor.left,
monitorInfo.rcMonitor.top,
monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left,
monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top,
NULL,
0,
0,
BLACKNESS);
ReleaseDC(NULL, hdc);
}
}
return TRUE;
}
BOOL CALLBACK MonitorRefreshProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
{
UNREFERENCED_PARAMETER(dwData);
UNREFERENCED_PARAMETER(lprcMonitor);
UNREFERENCED_PARAMETER(hdcMonitor);
MONITORINFOEX monitorInfo;
memset(&monitorInfo, 0, sizeof(MONITORINFOEX));
monitorInfo.cbSize = sizeof(MONITORINFOEX);
if (GetMonitorInfo(hMonitor, &monitorInfo))
{
// Refresh all monitors other than the primary
if (monitorInfo.dwFlags != MONITORINFOF_PRIMARY)
{
// Refresh the monitor
HWND hWndDesktop = GetDesktopWindow();
CreateWindow(WC_STATIC,
"",
WS_VISIBLE | WS_CHILD,
monitorInfo.rcMonitor.left,
monitorInfo.rcMonitor.top,
monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left,
monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top,
hWndDesktop,
NULL,
hMainInstance,
NULL);
}
}
return TRUE;
}
BOOL CALLBACK WindowResizeProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
{
UNREFERENCED_PARAMETER(dwData);
UNREFERENCED_PARAMETER(lprcMonitor);
UNREFERENCED_PARAMETER(hMonitor);
UNREFERENCED_PARAMETER(hdcMonitor);
MONITORINFOEX monitorInfo;
memset(&monitorInfo, 0, sizeof(MONITORINFOEX));
monitorInfo.cbSize = sizeof(MONITORINFOEX);
if (GetMonitorInfo(hMonitor, &monitorInfo))
{
// Resize our screen saver window to cover the primary monitor
if (monitorInfo.dwFlags == MONITORINFOF_PRIMARY) {
HWND hWnd = (HWND)dwData;
RECT rect = monitorInfo.rcMonitor;
MoveWindow(hWnd, 0, 0, (rect.right - rect.left), rect.bottom - rect.top, TRUE);
return FALSE;
}
}
return TRUE;
}
LRESULT WINAPI ScreenSaverProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lParam) {
static HANDLE thread;
static DWORD idThread;
switch (message) {
case WM_CREATE:
idThread = 0;
thread = CreateThread(NULL, 0, ScreenSaverThread, wnd, 0, &idThread);
return 0;
case WM_DESTROY:
ScreenSaver *screenSaver = ScreenSaver::GetSingleton();
if (screenSaver)
screenSaver->Condemn();
WaitForSingleObject(thread, INFINITE);
CloseHandle(thread);
return 0;
}
return DefScreenSaverProc(wnd, message, wParam, lParam);
}
DWORD WINAPI ScreenSaverThread(void* parameter) {
ScreenSaver *screensaver = new ScreenSaver(static_cast<hwnd>(parameter));
screensaver->Heartbeat();
delete screensaver;
return 0;
}
//------------------------------------------------------------------------------
ScreenSaver::ScreenSaver(HWND _wnd)
{
assert(!singleton);
singleton = this;
wnd = _wnd;
int nMonitors = GetSystemMetrics(SM_CMONITORS);
if (nMonitors > 1)
{
OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (GetVersionEx(&versionInfo)) {
// Make sure we are running on some derivative of WinNT
if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
// Need to have at least Win2000 (NT5.0) for EnumDisplayMonitors()
if (versionInfo.dwMajorVersion > 4) {
// Resize screen saver window to size of primary monitor
EnumDisplayMonitors(NULL, NULL, WindowResizeProc, (long)wnd);
}
}
}
}
condemned = false;
InitializeCriticalSection(&threadSafeness);
HRESULT hRes;
if FAILED(hRes = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))
throw hRes;
timeBeginPeriod(1);
srand(static_cast<unsigned>(time(NULL)));
display = new Display;
simulator = new Simulator;
}
ScreenSaver::~ScreenSaver() {
assert(singleton);
delete simulator;
delete display;
timeEndPeriod(1);
CoUninitialize();
DeleteCriticalSection(&threadSafeness);
singleton = NULL;
EnumDisplayMonitors(NULL, NULL, MonitorRefreshProc, 0);
}
//------------------------------------------------------------------------------
void ScreenSaver::Heartbeat()
{
unsigned lastTime = timeGetTime();
unsigned time;
unsigned delta;
while (!IsCondemned()) {
time = timeGetTime();
delta = time - lastTime;
lastTime = time;
simulator->Behave(delta);
Display::GetSingleton()->Paint();
// Blank all monitors other than the primary monitor
EnumDisplayMonitors(NULL, NULL, MonitorBlankProc, NULL);
Sleep(1);
}
}
|
|
|
|
|
This is cool
Kochise
In Code we trust !
|
|
|
|
|
Aside from having to compile with VS7.0 and fixing a few compilation errors, this seems to fix most MultiMon issues. I think the original problem resulted from creating a DirectX surface that spanned multiple DCs, and the additional code your fix adds seems to address this problem by restricting the surface to only the primary monitor. I'm just starting to work with DX, so I may not fully understand this fix yet.
Where this fails, is while the screensaver is running in a preview ("/p xxxxxx") mode, such as when it is executing in desk.cpl. Because this project is compiled against scrnsave.lib, I can't find anyway to get the command-line arguments, or to determine if the screensaver is running full screen or in a preview mode. In this mode, where the secondary monitors do not need to be blanked, they currently are.
If EnumDisplayMonitors(...); in ScreenSaver::Heartbeat() could be called conditionally only if running full screen, then the secondary monitors wouldn't be blanked when running in preview -- but as I said, I don't know how to determine that state.
Any suggestions? I find it hard to believe that scrnsave.lib was written to completely isolate the programmer this information, but I can find little information on it.
:::FIXED:::
if (!fChildPreview)<br />
{<br />
EnumDisplayMonitors(NULL, NULL, MonitorBlankProc, NULL);<br />
}
It turns out there is an extern defined in the scrnsave.h header that indicates if you are running as a preview. If you modify the existing MultiMon fix to include this, it works. There is still an annoying flash if something is being drawn on the secondary monitors (like taskman when you're watching your CPU melt), but this fixes the Desk.cpl issue that I initially saw.
/Ryan
|
|
|
|
|
Hi,
your ScreenSaver is super!
Unfortunately the CPU bumps the ceiling, when the screen saver activates.
I found a simple solution for that:
put Sleep(100); within the loop of the funtion ScreenSaver::Heartbeat().
This cuts down the repaints to 10 paints per second. The display is still good and on my machine the CPU went to 20% max if you set the simulation speed to "Too fast".
Hans
|
|
|
|
|
Sleep(100) slows down the screen saver too much - try Sleep(1) or Sleep(10).
|
|
|
|
|
For me Sleep(100) is ok, because this keeps the CPU below 20%. Keeping CPU low is important for me, I usually have long-running tasks which should not be blocked by a 100% CPU Screensaver.
Is approx. 10 frames/second so slow??
Hans
|
|
|
|
|
10 frames/sec is noticably slower on my machine, but I also speed up the heartbeat by an order of magnitude. 10f/s is probably fine with the stock code if your update rate isn't "fastest".
|
|
|
|
|
I attempted to run the code with both monitors enabled and it failed as the previous poster suggested, but I disabled the secondary monitor with no avail. Any suggestions?
It is not what you know, but if you know where in the book to find it.
|
|
|
|
|
Compile produced the following error:
scrnsave.lib(scrnsave.obj) : error LNK2001: unresolved external symbol __SEH_epilog
I had no problem with the download. I got everything there were.
It didn't matter if I compiled in Release mode, or Debug mode. The same errors occurred.
Running VC++ 6.0 under Win2K.
William
Fortes in fide et opere!
|
|
|
|
|
I can't replicate the problem, but I did do a search on Google for that error line. It gave me a page from CodeGuru which seems to have the same problem: http://www.codeguru.com/mfc/comments/50736.shtml. The only solution given was to add sehprolg.obj to the link line. Maybe that will work? If not maybe someone else has an idea.
|
|
|
|
|
Yes, that fixes the problem.
|
|
|
|
|
Why it´s called "Window Virtual Machine" ??
|
|
|
|
|
Read the newly updated article BeFreak (or the original BeFunge) is a 2D programming language with 1 char/command.
This screen saver put random chars/commands on the screen, and start random 'threads' that will carry on the characters/commands set on the screen.
Sadly, even if the article was enhanced a bit since my first (harsh) re-mark, there stills lack of explanations of the command set and everything that may help to understand what is happening onto the screen :/ Hopefully, it is found in the setting dialog : 'Help' button ! Cooool
As I'm issued from the world of embedded and assembly language, this screen saver just turns me on ! So do BeFreak that recall me some good remembers from my geek past :P
Sad it wasn't enough polished up :/ I myself not submited much articles there, but I always tried to accomplish a complete task I wouldn't have to scrub multiple times before it looks like fully completed.
But thanks again Squirrel Twirler, that's an amazing soft. Some cool and neat graphics, some emulated IA, some tricks and fun... Good to see such sweet goodies around there !
Kochise
PS : A good BeFreak link is http://tunes.org/~iepos/befreak.html
A good setting is :
Speed : 0.040 sec/cycle
Max stack : 10
Max thread : 20
Random noise : 0
New thread : 20
Spawn lifetime : 100
Initialize : TRUE
Reverse : TRUE
Copies : TRUE
Thread death : FALSE
Spawn expiration : TRUE
Terminate random thread : TRUE
Random Noise (if set) : Copy=1, Halt=1, Push=4, Spawn=1
In Code we trust !
|
|
|
|
|
http://koti.mbnet.fi/korsu/tierra.html
Kochise
In Code we trust !
|
|
|
|
|
What's wrong :
-1 DirectX9 SDK (OpenGL would have been more convinient, especially from a code/idea originated from Linux)
-2 VC++7 (not compatible with VC++6, even if the project '*.sln' is converted to VC++6)
-3 The executable '*.scr' file don't works on some graphic cards
-4 The article is poorly designed, no explanation of any kind
What's good :
+1 The source code is kindly neat
+2 The BeFunge/BeFreak programming system is very fascinating
3+ On the computer on which the '*.scr' file works, there is a nice 'rain' of colored characters
4+ Nice try for a first article (yeaaah, I'm trying to find something positive)
5+ The subject leaded me to restart/continue an old project
In conclusion :
-4 +5 = You get my 1 !
Kochise
In Code we trust !
|
|
|
|
|
The beauty of open source is that *you* can do everything that *I* didn't have time for .
Can anyone tell me how to make the project work with version 6? I only have access to the latest version at the moment because I'm at school and the DVD is at home.
I'll revise the article for the next release; I kinda just wanted to get this out and get some feedback. Thanks everyone.
|
|
|
|
|
http://www.codeproject.com/tools/prjconverter.asp (type 'prjconvert VirtualMachine.sln' to convert to VC++6)
I admit, I was very frustrated. The article is SO promising I expected far more :/ Maybe my 5 in the next release
Kochise
In Code we trust !
|
|
|
|
|
Great bit of code, very well done.
Doesn't work on my dual screen setup though, just bombs out straight away, before/while initialising.
Works fine if i disable one of my monitors.
|
|
|
|
|
works fine on my dual monitors.
eVGA Nvidia GeForce 7900GTO
ViewSonic VG2021m and VE150B
But I'm also running UltraMon http://www.realtimesoft.com/ultramon/
So that may be why mine works.
|
|
|
|
|
You did a great job on the screen saver. I'm not too familliar with the Linux world, but I really like the work you've done. Nice job, and good luck in your experimental code language. (Nice screen name too). Dom
|
|
|
|
|