Author Topic: OpenGl Library  (Read 1433 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
OpenGl Library
« on: April 03, 2018, 08:02:20 AM »
Hello together,

more opengl2D demo's by me. 
demo's are  only 32bit. 

   
demo5:
Code: [Select]
include "ogl.inc"
window 640,480,1
SetFrames 60
Enable GL_SMOOTH
int a

while KeyDown(27)=0
cls 0,0,0
for y=0 to 480 step 40
for x=0 to 640 step 40
    color 0,100,255,255
    Circle x+sin(rad(a))*40,y+cos(rad(a))*40,10,2
    color 255,0,0,255
    Circle x+cos(rad(a))*40,y+sin(rad(a))*40,12,2
    color 0,255,0,255
    Circle x+cos(rad(a))*40,y+cos(rad(a))*40,14,2
next
next
a +=4
if a >=360 then a=-a
Flip
wend
WinEnd

demo6:
Code: [Select]
include "ogl.inc"
window 640,480,1

f1=LoadFont ("gfx/font32.bmp")
f2=LoadFont ("gfx/font05.bmp")
mo=LoadImage("gfx/mouse.tga")

while KeyDown(27)=0
Cls 0,0,0
DrawImage mo,260,64,0
Text f1,184,16,"MouseButton Test",16,16
Text f1,176,240,"Press a MouseButton",16,24
if MouseButton()=1 then Text f2,190,280,"LEFT BUTTON ",24,24
if MouseButton()=2 then Text f2,190,280,"RIGHT BUTTON ",24,24
if MouseButton()=4 then Text f2,190,280,"MIDDLE BUTTON ",24,24
Text f2,30,390,"ESCAPE ENDS THE TEST",28,28
Flip
wait 10
wend
WinEnd
demo7:
Code: [Select]
include "ogl.inc"
window 640,480,1
SetFrames 100

f1 = LoadFont ("gfx/font24.bmp")

hnd = OpenFile("gfx/greentoy.raw")
big = FileSize(hnd)
mem = GetMemory(big)
ReadByte(hnd,*mem,big)
CloseFile(hnd)

single wAmp=2,wFreq=.8,x,m1
sys height = 128
sys width  = 128

while Key(vk_escape)=0
cls 10,10,10
x -=.2
m1=x
for ix=0 to <height
    m1 += wfreq
for jx=0 to <width   
    z = (ix*width+jx)*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 240+jx*1+sin(m1)*wAmp+1,250+ix*1
    end if
next
next
text f1,150,410,"PETERMARIA",32,32
text f1,32,32,"FRAMES: " & GetFrames,16,26
Flip
wend
winEnd
demo8:
Code: [Select]
include "ogl.inc"
Window 800,600,1
SetFrames 60

s1 = LoadImage "gfx/star2.tga"
s2 = LoadImage "gfx/ufostrip.tga"

Type Star
   sys xStar
   sys yStar
   sys speed
End Type

dim Stars(200) as Star
sys xRes = 800
sys yRes = 600
sys frms, single a

for i=1 to 100
Stars(i).xStar = Rand(1, xRes-2)
Stars(i).yStar = Rand(1, yRes-2)
Stars(i).speed = Rand(4, 8)
next

Sub MoveStars()
for i=1 to 100
color Rand(64,255),255,255,255
BlendImage s1,stars(i).xStar,Stars(i).yStar,64,64,100,0
Stars(i).xStar = Stars(i).xStar + Stars(i).speed
if Stars(i).xStar > xRes+64
   Stars(i).xStar = -64
   Stars(i).yStar = Rand(1, yRes-2)
   Stars(i).speed = Rand(4, 8)
end if
next
End Sub

while Key(27)=0
cls 0,0,0
ScaleImage s2,384,284+cos(rad(a))*100,128,128,frms
MoveStars
frms +=1
if frms=16 then frms=0
a +=.5
if a >=360 then a=-a
redraw
wait 40
wend
WinEnd
demo9:
Code: [Select]
include "ogl.inc"
window 640,480,1
SetFrames 60

f1 = LoadFont("gfx/font25.bmp")

sys tl,i,x
string z="WELCOME TO MY OPENGL2D LIBRARY", letter
tl=len(z)
dim y(44) as single
dim angle(44) as single

for i=1 to tl
angle(i) = 360-i*(360/tl)
y(i) = 240
next

while Key(27)=0
cls 0,0,0
for x=1, tl
angle(x)=angle(x)+1
if angle(x)=360 then angle(x)=0
letter=Mid(z,x,1)
y(x) += cos(rad(angle(x)))*2
Text f1,40+x*16,y(x),letter,32,32
next
Flip
wend
winEnd
demo10:
Code: [Select]
include "ogl.inc"
window 640,480,1
SetFrames 60

fon = LoadFont("gfx/font22.bmp")
wa1 = LoadWav ("gfx/025.wav")
wa2 = LoadWav ("gfx/028.wav")
wa3 = LoadWav ("gfx/029.wav")
wa4 = LoadWav ("gfx/020.wav")
wa5 = LoadWav ("gfx/022.wav")
wa6 = LoadWav ("gfx/025.wav")
wa7 = LoadWav ("gfx/027.wav")

while Key(27)=0
cls 0,0,0
Text fon,168,16,"PRESS KEY [1 - 7]",16,24
if Key(vk_1)
   a=PlayWav wa1
end if
if Key(vk_2)
   a=PlayWav wa2
end if
if Key(vk_3)
   a=PlayWav wa3
end if   
if Key(vk_4)
   a=PlayWav wa4
end if   
if Key(vk_5)
   a=PlayWav wa5
end if   
if Key(vk_6)
   a=PlayWav wa6
end if
if Key(vk_7)
   a=PlayWav wa7
end if   
Text fon,80,200,"IDENTIFICATION VALUE " + a,20,32
if a=1 then Text fon,180,64,"PLAYED WAV 1",20,24
if a=2 then Text fon,180,64,"PLAYED WAV 2",20,24
if a=3 then Text fon,180,64,"PLAYED WAV 3",20,24
if a=4 then Text fon,180,64,"PLAYED WAV 4",20,24
if a=5 then Text fon,180,64,"PLAYED WAV 5",20,24
if a=6 then Text fon,180,64,"PLAYED WAV 6",20,24
if a=7 then Text fon,180,64,"PLAYED WAV 7",20,24
Flip
wend
winEnd




 
« Last Edit: April 08, 2018, 09:21:49 AM by Peter »