Oxygen Basic
Programming => Example Code => Topic started by: Peter on January 30, 2011, 04:57:12 AM
-
deleted
[attachment deleted by admin]
.
-
Thanks Peter,
I think I've got an algorithm. ;D
Hint: clockwise 1236874
Charles
PS: GPF on termination - something left on the stack?
.
-
Peter,
I found there was something that prevented your 5x5 Magic square from working when compiled as a standalone (with RTL32).
I traced this to an error in Win_G.inc.
Bind user32
(
LoadIcon LoadIconA
LoadCursor LoadCursorA
RegisterClass RegisterClassA
MessageBox MessageBoxA
SendMessage SendMessageA '<---- was SendMessage
GetMessage GetMessageA
I also removed "ExitProcess" from WinEnd allowing the O2 epilog procedures to perform their normal duties.
Function WinEnd()
FreeGraphics
DestroyWindow sys_hwnd
'ExitProcess 0 '<-----Now removed
End Function
Would it be okay to adopt these changes in your standard Win_G.inc? (zipped below)
Charles
.
-
Thanks Peter,
Here is the amended Func.inc (SendMessage --> SendMessageA)
WinEnd was okay.
Charles
.
-
I also removed "ExitProcess" from WinEnd allowing the O2 epilog procedures to perform their normal duties.
I wonder if this is the reason I see the client area of peter's programs overwriting the upper left corner of my Linux desktop when his program examples end.
-
Yes Wine could well be more sensitive to libraries closing prematurely - X-Windows is likely to behave differently from MS Windows in unexpected circumstances.
Charles
-
Charles,
I updated the win_g.inc with yours and did a recompile of peter's magic squares game. It still leaves a mess. I have stopped trying peter's demos due to this problem.
John
-
Hi John,
I've just installed Wine and am slowly getting familiar with this environment where everything is slightly different from MS. I've run some of the Oxygen standard examples so far. One interesting result is that I was able to run OpenGL Child windows and resize it without getting the problem that you encountered. (We may have a driver/Graphics card issue here, not directly related to Wine.)
Anyway I hope to look at some of Peter's code running under Wine and see if we can find a solution.
One thing I need to know is how to get a DOS console running under Wine?
Charles
-
One thing I need to know is how to get a DOS console running under Wine?
In a Linux console type the following.
wineconsole cmd
Z:\ is your Linux home root.
C:\ is /home/you/.wine/drive_c
FYI: you may need to right click (if in Nautilus) and make the .exe have executable permission if the file wasn't created as part of a Windows install.
may have a driver/Graphics card issue here, not directly related to Wine
Glad to hear it's working there. It's more than likely is my old POS laptop that is the problem. I have to run in no theme goodies mode as I have problems even using minimal effects. >:(
On the other hand, the Gambas OpenGL demos run smooth as glass. (native)
-
The problem appears to be FlipBuffer(). Perhaps this should only be done in response to a WM_Paint message. I will investigate further
Charles
-
I think Wine has expectations as to when an image can be rendered. I will try invalidateRect.. paintstruct etc.
Charles
-
That brings up the question is Windows smart enough to realize what the programmer meant to do and recover or did Windows miss the boat altogether and the problem ending up getting redirected to Winull? (NOP with a few layers)
-
With a few modifications I've got Peter's Magic square and 3D demo working quite well with Wine/Linux.
The two most important things are:
1: Only update the screen buffer when a WM_PAINT message is given - otherwise it may paint in the wrong place and make a mess on the desktop.
2: mask out the upper 16 bits of the value returned from GetAsyncKeyState() otherwise you will get false positives when testing individual keyboard keys.
Other mods are directed towards reducing CPU workload and ensuring that the window can be moved around the screen without disrupting its image refresh.
I have a few more issues to deal with concerning fonts, and will need to investigate another source of memory leaks which is an Oxygen garbage collection problem and quite easy to work around.
Charles
-
I have a few more issues to deal with concerning fonts
Make sure you install the Windows/Wine font pack. Using Winetricks should do the ...
http://wiki.winehq.org/winetricks
You can use Ubuntu Synaptics (default installer) to get Winetricks.
Wine is a compatibility layer for running Windows applications on Linux.
Applications are run at full speed without the need of cpu emulation. Wine
does not require Microsoft Windows, however it can use native system dll
files in place of its own if they are available.
Note: Check the Wine site for the few Wine specific DLLs that can't be replaced with the Windows equivalents.
-
I'll get those fonts John, thanks. I was able to fix the font problem by avoiding "courier" and specifying "roman" instead. It probably did not know what Roman was but came up with a good looking monospaced font instead a scrambled Courier.
Peter,
Your test code above did not work correctly in Linux, partly due to the Courier font, and dumped all its pixels onto the desktop at the end. But here are compatible versions of the magic square and the 3d demo.
I made a number of changes to Func.inc.
1 Replace peekMessage with GetMessage. This eliminates frenetic looping.
2 Call a render() procedure from wndproc on the WM_PAINT message.
3 Respond to the WM_ERASEBKGND message returning 1. This maintains a clean window when moving.
On the App side.
1 provide render() procedure that can be called from WndProc (on WM_PAINT message).
2 bypass rendering when there is no user activity (the act flag)
3 sleep for 10ms instead :)
I am sure the logic controlling the keydown, buttondown and act flags can be improved. They reduce CPU activity to almost nil when the user is not interacting.
Charles
PS: the Magic square needs the media folder (not included)
.
-
Charles,
Your example doesn't work on my box. A small window tries to open (no content) then closes. Nothing left running according to ps/top.
I even tried to recompile both .bas files. (no errors reported)
The 3D example included worked.
.
-
That happens when the media folder (containing maps images and sound) is not alongside the magic square program. Maybe the best way is to copy these new files into the original magic8er folder.
Charles
-
I already have the media folder in the same directory as your example. I had to copy the Oxygen.dll (couldn't find it) and copied the A.dll for good measure. No luck yet.
-
John,
You should be able to run Magic8erWS.exe as a standalone. It only requires the media file which itself contains:
clic.wav
won.wav
number.bmp
I've tested it on both platforms here.
Glad the 3D demo worked anyway. This show the basic techniques work on your system. You have even got the correct "times" font I see :)
Charles
-
Please post a complete set of files for this. I don't have those files in the original Magic Squares media folder.
-
I think you got the media file from earlier 5x5 magic spquare.
Here is the3x3 one with the programs.
Charles
[attachment deleted by admin]
-
(http://files.allbasic.info/O2/ms3x3.png)
When I close the game I no longer have a mess on my desktop.
Thanks!
-
Thanks for testing John.
Don't let the puzzle drive you mad. I am sure this is not Peter's intention :)
I see that WineTricks involves using a script. I am not entirely sure what to do with it in order to get the FontPacks.
In windows we are not exposed to these mysterious incantations.
Charles
-
Use System->Synaptics Installer to install Winetricks. (free candy store)
I may have installed the Windows core fonts package when I had Crossover installed. I know they had a option on their configuration utility to install fonts, COM and other Windows specifics. The only thing I didn't like about Crossover is the bottle scheme to encapsulate a Windows environment. It's hard to say which is better as they are both eating off of the same plate.
-
Hi,
try this for Linux/Wine.
/* Linux Test by Peter Feb o3/2o11 */
Include "Func.inc"
Dim hdc as long
Dim x, y, r, alpha as single
SetWindow "o-o",800,600,ws_dlgframe
hdc = GetDC(sys_hwnd)
r = 2.5
While EscKey() =0
For alpha=0 To 360
x = r*cos(alpha)*100
y = r*sin(alpha)*100
DrawBox hdc,x+400,y+270,2,2,RGB(Rand(64,255),Rand(64,255),Rand(64,255))
DrawBox hdc,x+400,y+270,4,4,&h0000FF
DrawBox hdc,x+400,y+270,6,6,RGB(Rand(64,255),Rand(64,255),Rand(64,255))
Next
DoEvents
r = r - 0.1
iF trunc(r) =-1.0 Then r= 2.5
Wend
-
Hi Peter,
This test works in Linux without dumping pixels. It performs the same as in Windows.
I tested it with Alpha028 and your original func,inc but with the SendMessageA correction.
Charles