Oxygen Basic
Programming => Example Code => Topic started by: Peter on April 01, 2018, 12:03:07 PM
-
Hello, here is a small opengl library for small games and other things.
You can find everything in the gfx.zip file.
The oxygen.dll is from 2015, if a newer dll runs I have not tested yet.
Peter
demo1
include "ogl.inc"
window 800,600,1
SetFrames 60
fon = LoadFont ("gfx/font05.bmp")
boy = LoadTiles("gfx/skulls.bmp",16,4)
cub = LoadImage("gfx/cube.tga")
type digger
sys x
sys y
sys z
sys d
end type
digger dig[3]
sys f
dig[0].x=0 : dig[0].Y=96
dig[1].x=736 : dig[1].y=160
dig[2].x=336 : dig[2].y=536
dig[3].x=400 : dig[3].y=0
while KeyDown(VK_ESCAPE)=0
cls 0,0,0
Text fon,300,16,"TILE DEMO",16,32
if dig[0].d=0
DrawTile boy,dig[0].x,dig[0].y,64,64,dig[0].z,0
dig[0].x +=1
dig[0].z +=1
if dig[0].z=16 then dig[0].z=0
if dig[0].x>=736 then dig[0].d=1
end if
if dig[0].d=1
DrawTile boy,dig[0].x,dig[0].y,64,64,dig[0].z,1
dig[0].x -=1
dig[0].z +=1
if dig[0].z=16 then dig[0].z=0
if dig[0].x<=0 then dig[0].d=0
end if
if dig[1].d=0
DrawTile boy,dig[1].x,dig[1].y,64,64,dig[1].z,1
dig[1].x -=1
dig[1].z +=1
if dig[1].z=16 then dig[1].z=0
if dig[1].x<=0 then dig[1].d=1
end if
if dig[1].d=1
DrawTile boy,dig[1].x,dig[1].y,64,64,dig[1].z,0
dig[1].x +=1
dig[1].z +=1
if dig[1].z=16 then dig[1].z=0
if dig[1].x>=736 then dig[1].d=0
end if
if dig[2].d=0
DrawTile boy,dig[2].x,dig[2].y,64,64,dig[2].z,2
dig[2].y -=1
dig[2].z +=1
if dig[2].z=16 then dig[2].z=0
if dig[2].y=0 then dig[2].d=1
end if
if dig[2].d=1
DrawTile boy,dig[2].x,dig[2].y,64,64,dig[2].z,3
dig[2].y +=1
dig[2].z +=1
if dig[2].z=16 then dig[2].z=0
if dig[2].y>=536 then dig[2].d=0
end if
if dig[3].d=0
DrawTile boy,dig[3].x,dig[3].y,64,64,dig[3].z,3
dig[3].y +=1
dig[3].z +=1
if dig[3].z=16 then dig[3].z=0
if dig[3].y=536 then dig[3].d=1
end if
if dig[3].d=1
DrawTile boy,dig[3].x,dig[3].y,64,64,dig[3].z,2
dig[3].y -=1
dig[3].z +=1
if dig[3].z=16 then dig[3].z=0
if dig[3].y=0 then dig[3].d=0
end if
DrawImage cub,250,268,f
FlipImageH cub,350,268,64,64,f
FlipImageV cub,452,268,64,64,f
f +=1
if f=32 then f=0
Flip
wait 30
wend
WinEnd
demo2
include "ogl.inc"
window 640,480,1
font=LoadFont ("gfx/font32.bmp")
skul=LoadImage("gfx/skull.tga" )
sys w=screenW
sys h=screenH
float a
while KeyDown(VK_ESCAPE)=0
cls 0,0,255
RotateImage skul,296,290,2,2,a,0
Text font,96,32,"Screen Resolution "+w+"x"+h,18,26
Text font,16,64,"Screen Resolution "+w+"x"+h,24,32
Text font,158,120,"I am PeterMaria",16,16
Flip
a +=2.5
if a>=360 then a=-a
wend
WinEnd 'tidy up
Demo3
include "ogl.inc"
Window 480,240,1
SetFrames 60
fon = LoadFont("gfx/font32.bmp")
hnd = OpenFile "gfx/knot.raw"
sys size = FileSize(hnd)
sys a=GetMemory size
ReadByte hnd, *a,size
CloseFile hnd
hnd = OpenFile "gfx/skull.raw"
sys size = FileSize(hnd)
sys c=GetMemory size
ReadByte hnd, *c,size
CloseFile hnd
Sub RawImage(sys x0,y0,mem)
for y=0 to 128
for x=0 to 128
z=(y*128+x)*3
r=Peek mem,z+0
g=Peek mem,z+1
b=Peek mem,z+2
if r>0 or g>0 or b>0
Color r, g, b, 255
SetPixel x+x0,y+y0
end if
next
next
End Sub
while KeyDown(vk_escape)=0
Cls 0,0,0
Text fon,56,8,"ALLIANCE KNOT",16,16
RawImage 64 ,50,a
RawImage 256,50,c
Flip
wend
FreeMemory (a)
FreeMemory (c)
WinEnd
demo4
include "ogl.inc"
window 1024,768,1
Enable GL_POINT_SMOOTH
int width = 1024/2
int height= 768/2
int a=1,d=1, single r,sx,sy
Sub vec(single x,y,z)
if z>0 then Return
if z=0 then z=-0.01
ps = (1/z)*10000
sx = x*ps+width
sy = y*ps+height
color rand(128,255),rand(128,255),rand(128,255),255
FillCircle(sx,sy,2)
End Sub
while Key(27)=0
cls 0,0,0
for i=1 to 1000
vec(cos(i*r+a),sin(i*r-a),-i/a)
next
Flip
if a <=20 and d=1
a +=0.01
else
d=2
end if
if a >=0.05 and d=2
a -=0.1
else
d=1
end iF
r +=0.001
if r >=360 then r=-r
wend
WinEnd
-
Sorry, I forgot the og.dll
-
Thanxx Peter
Only one problem, i tried to compile demo1 and demo2 to exe files but fail.
they can run alright but not able to compile them to demo1.exe and demo2.exe ?
i have atteched the files
-
Hi Peter,
all your demos run fine with my latest OxygenBasicProgress (29/03/18) installation. I did not need your oxygen.dll so I deleted it. I created a folder OpenGl_Library with subfolder gfx. In the OpenGl_Library folder I have ogl.dll, ogl.inc and the four demo examples.
Roland
-
Hello Chrisc,
simple write in the source code at the begin:
$filename "demo1.exe"
include "rtl32.inc"
Peter
-
Thanxx a lot Peter
but when i use rtl64 , it will compile to an exe.
but then when i run this exe it will display ogl.dll message and then exit.
this means that ogl.dll is a 32bit dll, can you please create a 64bit ogl.dll ?
-
Hi Chrisc,
sorry, no 64bit cpu here!
-
Hi Peter,
it is time to upgrade.
Roland
-
I agree. O2 is on a 64 bit mission.
-
I agree. O2 is on a 64 bit mission
really...
why bother when every 64bit windows can execute 32bit app
phh
-
I agree. O2 is on a 64 bit mission
really...
why bother when every 64bit windows can execute 32bit app
phh
The goal of O2 isn't to perform puppet shows.
I can run DOS on 64 bit Windows. What is your point?
-
my company is translating programs from PB to O2 is bcos of the 64bit factor.
as you see PB is operating in 32bits and our customers are asking for 64bits,
that's why we are upgrading to 64bits. And i need to keep my job too, it some kinda job security
It is kinda of demanded by customers, like a new fashion trend or hype? just follow the hype
and bend with the wind that sorta thing?
What customers wanted are what we gonna give to them... we cannot turn down customers requests and
tell them to fly kites. Also 64bits translation is a way to keep my job
Hope that there is a way that a 64bit main.exe program that can call a 32bit dll so that there
will be lesser translation work to do, and faster migration to 64bits in a stage by stage basis.
-
Going 64 bit isn't a rewrite of your 32 bit application. The amount of work depends on how much you depend on the Windows API and not the language you're using.
-
If your code is well constructed, Chris, it will compile to 32 or 64 bit just by switching rtl32/rtl64. The problem is getting all your DLLs to 64bit - being able to test them individually prior to running an entire suite of 64bit code.
-
Thanxx Charles
I have partially translated some of the PB dll to O2 while the main exe program is already in O2.
what i would like to have is to get the main exe (which is 64bit) to be able to call an old 32 bit PB dll
and this will save us some translation work and buy time before we eventually translate all the PB dll
to O2.
It does look like this is not doable.
-
It does look like this is not doable.
Actually it is doable though not easy. It would require a proxy 64-bit DLL that would relay the actual tasks to a dummy 32-bit process having the original 32-bit DLL mapped into its process memory, using inter process communication (a.k.a. IPC) facilities such as sockets, pipes, or COM. That would of course imply perceptible speed penalties and may be even more laborious than re-writing the original DLL for native 64-bit compilation.
-
Thanxx Mike
i'm not in that level to be able to do IPC , i'll just have to convert the remaining PB dlls to O2