Hi Charles,
I assume the macro above (and MoveThisWithMouse) can be used generally for moving things around and also as a pattern for similar actions? I used the part for increasing / decreasing speed faster.
My purpose for enhancing your little demo was to check what could be done with WndProcExtra and how to add some events.
Although I am far away from understanding all the tools you provided for OpenGl the ConsoleG demo works already very nice in my opinion. It will be interesting to investigate in some more areas. For instance using ImgWin.inc and perhaps adding some user functions it should already be possible to write NeHe lessons 1 - 20 using the provided tools of OxygenBasic.
Roland
$ FileName "ConsoleGDemo.exe"
'include "$/inc/RTL32.inc"
% Title "ConsoleG Demo - F1 for Help"
% Animated
'% ScaleUp
% PlaceCentral
% AnchorCentral
% width 640
% height 480
include "$\inc\ConsoleG.inc"
'Keys: Esc, arrow-keys, n,m, F4, +,-
' F12 toggles fullscreen and windowed mode
'screen dimensions
int swidth = GetSystemMetrics (SM_CXSCREEN)
int sheight = GetSystemMetrics (SM_CYSCREEN)
bool fullscreen=FALSE
BeginScript
sub main
========
static float x,y,z
static float xspeed, yspeed, zspeed
static float m
static int wleft, wtop, wwidth, wheight
RECT wrc
'F1 HELP
'
if key[0x70]
pushstate
move 5,14
color 1,.8,.5
scale 1.5,1.0
printl "Active Keys:"
scale 1/1.5,1.0
printl
printl "ALT-F4, ESC - Exit"
printl "F12 - Toggle Fullscreen"
printl "Arrow Keys, N, M: "
printl "Start moving and"
printl " increase or decrease speed"
printl "+ increase move with faster speed"
printl "- decrease move with faster speed"
printl "F4 - Stop and reset values"
printl "F1 - This help"
printl
popstate
end if
'
lastkey=0
lastchar=0
pushstate
scale 2, 3
color 1,.5,0,1
print "Hello "
scale 2, 1.25
if key(VK_UP) then key(VK_UP)=FALSE : xspeed-=0.01
if key(VK_DOWN) then key(VK_DOWN)=FALSE : xspeed+=0.01
if key(VK_RIGHT) then key(VK_RIGHT)=FALSE : yspeed-=0.01
if key(VK_LEFT) then key(VK_LEFT)=FALSE : yspeed+=0.01
if key(77) then key(77)=FALSE : zspeed-=0.01 'm,M
if key(78) then key(78)=FALSE : zspeed+=0.01 'n,N
if key(VK_F4) then x = y = z = xspeed = yspeed = zspeed = 0.0
if key(VK_ADD) or key(187) then '+
key(VK_ADD) = FALSE : key(187)=FALSE
m=1.0+m*.1
xspeed*=m : yspeed*=m : zspeed*=m
end if
if key(VK_SUBTRACT) or key(189) then '-
key(VK_SUBTRACT)=FALSE: key(189)=FALSE
xspeed/=m : yspeed/=m : zspeed/=m
end if
if key(VK_F12) then
key(VK_F12) = FALSE
fullscreen = not fullscreen
if fullscreen then
GetWindowRect(hwndMain,@wrc)
wleft=wrc.left : wtop=wrc.top : wwidth=wrc.right-wrc.left : wheight=wrc.bottom-wrc.top
SetWindowLong(hWndMain, GWL_STYLE, WS_POPUP)
MoveWindow(hWndMain,0,0,swidth,sheight,1)
ShowWindow(hWndMain, SW_RESTORE)
else
SetWindowLong(hWndMain, GWL_STYLE, WS_OVERLAPPEDWINDOW)
MoveWindow(hWndMain,wleft,wtop,wwidth,wheight,1)
ShowWindow(hWndMain, SW_RESTORE)
end if
end if
rotatex x : x+=xspeed : if x>=360 then x-=360 : if x<=0 then x+=360
rotatey y : y+=yspeed : if y>=360 then y-=360 : if y<=0 then y+=360
rotatez z : z+=zspeed : if z>=360 then z-=360 : if z<=0 then z+=360
print "World!"
popstate
end sub 'main
EndScript
.