' -- oxygen basic spheres and reflections
' -- how to make a mirror reflections and/or Raytracing?
'
#compact
$ FileName "t.exe"
'uses RTL32
'uses "RTL64
% title="Spheres and Reflections"
% ExplicitMain ' MainWindow width,height,WS_OVERLAPPEDWINDOW
uses OpenglSceneFrame
uses glo2\shapes
uses glo2\textures
uses glo2\materials
uses glo2\particles
indexbase 1
sys GdiplusToken
float ang1
float ma[16]
float li[16]
sys cube,sphere
Cloud cloud1
sub initialize(sys hWnd)
========================
'
GDIplus 1
'
BuildTextures 16,256
'
cube=CompileList : CubeForm : glEndList
sphere=CompileList : Spheric 1,1,6 : glEndList
'
'standard lighting
------------------
'li<=
'0.0, 8.0, 8.0, 0.0, 'position / w=0 parallel or w=1 for directional
'1.0, 1.0, 1.0, 1.0, 'ambient
'1.0, 1.0, 1.0, 1.0, 'diffuse
'1.0, 1.0, 1.0, 1.0 'specular
Lighting li
material white
'
end sub
sub Release(sys hwnd)
'====================
glDeleteLists cube,1
glDeleteLists sphere,1
glDeleteTextures 4, texn
Gdiplus 0
end sub
sub RenderCube(float x,y,z,sc,sys tex)
======================================
glBindTexture GL_TEXTURE_2D,tex
glPushMatrix
gltranslatef x,y,z
glscalef sc,sc,sc
glCallList cube
'glCallList pent
glPopMatrix
end sub
sub RenderPlane(float x,y,z,sc,tex,u,v)
=======================================
glBindTexture GL_TEXTURE_2D,tex
glPushMatrix
gltranslatef x,y,z
glscalef sc,1,sc
glBegin GL_QUADS
glTexCoord2f 0.0,0.0 : glVertex3f -1.0,0,-1.0
glTexCoord2f u ,0.0 : glVertex3f 1.0,0,-1.0
glTexCoord2f u ,v : glVertex3f 1.0,0, 1.0
glTexCoord2f 0.0,v : glVertex3f -1.0,0, 1.0
glend
glPopMatrix
end sub
sub scene(sys hWnd)
'==================
'
static single ra,ri,angi1=.5
'
SnapShots hWnd 'Ctrl-P take snapshot
NewFrame
glClearColor 0.5, 0.5, 0.7, 0.0
Fog 0.5, 0.5, 0.7, 0.035 'rgb and density
'
glPolygonMode GL_FRONT_AND_BACK, GL_FILL
glEnable GL_LIGHTING
glEnable GL_NORMALIZE
static as single,
model_diffuse(4) => (1.0, 1.0, 1.0, 1.0), '(1.0, 0.8, 0.0, 1.0),
model_specular(4) => (1.0, 1.0, 1.0, 1.0), '(0.0, 0.0, 1.0, 1.0),
model_ambient(4) => (0.9, 0.9, 0.9, 1.0), '(0.0, 0.0, 1.0, 1.0),
'model_ambient(4) => (0.75, 0.75, 0.75, 1.0), '(0.0, 0.0, 1.0, 1.0),
model_shininess=0.1
glColor4fv model_diffuse
'glDisable GL_LIGHTING
'glDepthMask GL_FALSE
'glDisable GL_LIGHTING
sys bb
static as single,
light_position(4) => (0.0, 8.0, 8.0, 0.0), '(0.0, 8.0, 8.0, 1.0),
light_diffuse (4) => (0.29, 0.29, 0.29, 1.0), '(0.5, 0.5, 0.5, 1.0),
light_specular(4) => (0.59, 0.59, 0.59, 1.0), '(0.5, 0.5, 0.5, 1.0),
light_ambient (4) => (0.75, 0.75, 0.75, 1.0) '(0.5, 0.5, 0.5, 1.0)
static as double aspect
'Configure and enable light source 1
' here you can do some changes --------------------- //
glLightfv GL_LIGHT1, GL_POSITION, light_position '(4) '' activate use all is white-black
glLightfv GL_LIGHT1, GL_AMBIENT, light_ambient(4)
glLightfv GL_LIGHT1, GL_DIFFUSE, light_diffuse(4) 'red effect
glLightfv GL_LIGHT1, GL_SPECULAR, light_specular '(4)
' here you can do some changes --------------------- //
glEnable GL_LIGHT1
glEnable GL_LIGHTING
'
sys t1=texn[10]
sys t2=texn[11]
'
'SPHERES
glPushMatrix
indexbase 1
glTranslatef 4.,2.,-20.0 '-20.,10.,-60.0
Material Red
glScalef 4.,4.,4.
glCallList sphere
Material White
glPopMatrix
glPushMatrix
glTranslatef 2.5,-1.0,-6.0
glScalef .5,.5,.5
'glCallList sphere
glPopMatrix
'
'SPHERES
glPushMatrix
indexbase 1
glTranslatef -1.,2.,-10.0
Material Gold
glScalef 3.,3.,3.
glCallList sphere
Material White
glPopMatrix
glPushMatrix
glTranslatef 2.5,-1.0,-6.0
glScalef .75,.75,.75
glCallList sphere
glPopMatrix
glPushMatrix
glTranslatef -2.5,-1.0,-6.0
Material silver
glScalef .75,.75,.75
glCallList sphere
glPopMatrix
glEnable GL_TEXTURE_2D
'
'RenderCube 2.5,-2.0,-6.0, 0.5,t1
'
RenderPlane 0.0,-2.0,-16.0,16.0,t2,8,8
'
glDisable GL_TEXTURE_2D
glDisable GL_LIGHTING
'
'CLOUD
glEnable GL_TEXTURE_2D
glPushMatrix
gltranslatef -10.0, -10.0, -48.0
glscalef 20.0,12.0,1.0
cloud1.render 30 'max 50
glPopMatrix
glDisable GL_TEXTURE_2D
ang1+=angi1
if ang1>360 then ang1-=360
sleep 10
end sub
MainWindow width,height,WS_OVERLAPPEDWINDOW
' -- oxygen basic
' -- example 1)
' global_var is in the global namespace
int global_var = 10
function outer_function() as integer
' outer_var is in the local namespace
int outer_var = 20
function inner_function() as integer
'inner_var is in the nested local namespace
int inner_var = 30
print inner_var
end function
print outer_var
inner_function()
end function
' print the value of the global variable
print global_var
' call the outer function and print local and nested local variables
outer_function()
'------------------- //
' -- example 2)
'
'NESTABLE NAMESPACES
int vic=99
namespace maria
namespace tom
int vic = 200
end namespace
end namespace
'
print maria..tom..vic '200
print vic '99
' oxygen basic c++ translation, 28-04-2024, frank bruebach
'
' a) only "<<" and ">>" doesnt work (double quotation mark)
' b) and "namespace" doesnt know how to use, as function ?
' include <iostream>
' using namespace std;
int main {
const int myAge = 35;
'cout << "I am " << myAge <<
cout "I am "; '\n
cout myAge " years old ";
'cout str(myAge) " years old "; ' this line works too
return 0
}
' output 35 ' ok :-)
' changed oxygen.dll for it, see zip folder
'
' zstring example: reduces text with value -1
'
dim as zstring myzText = "I love Ironman"
dim i as long
for i = 0 to len(myzText) - 1
print "zero based try: " + myzText[i]
next
for i = 1 to len(myzText)
print "one based try: " + myzText[i]
next
print "fine"
' -- arrays -----
'
'-- 1)
'
pim a(20) as pro = {2,4,6,8,10,12,14,16,18,20}
a(20) = a(4) + a(6)
printy a(20) '20
'-- 2)
'
pim abc(100) as pro = {10,20,30,40,50,60,70,80,90,100}
pindex 0
printy abc[4] '50
pindex 1
printy abc[4] '40
pindex 2
printy abc[4] '30
'-- 3)
'
pim tbo(100) as pro
function abc(pro k,x)
k*=2
tbo[k]=x
end function
function abc(pro k) as pro
k*=2
return tbo[k]
end function
abc(5) = 2024
printy abc(5) ' 2024
' convert a freebasic type class constructor to halProment Basic
'
class MyHeroeType
bstring myString
method Constructor(string stParam)
myString = stParam
printy "construct"
end method
method destructor()
===================
'destroy bstrings
del mystring
printy "destruct!"
end method
method actmytype() as string
return mystring " "
end method
end class
new MyHeroeType sample("Superman")
Printy sample.actmytype
'-------------------------------------------- //
' freebasic code with cast
'
'' Type MyType
'' m_String As String
'' Declare Constructor(Byval sParam As String)
'' DECLARE OPERATOR CAST () BYREF AS STRING
'' End Type
'' Constructor MyType(Byval sParam As String)
'' m_String = sParam
'' End Constructor
'' OPERATOR MyType.CAST () BYREF AS STRING
'' OPERATOR = m_String
'' END OPERATOR
'' Dim sample As MyType = "enter man"
'' Print sample
'--------------------------------------- //
Page created in 0.078 seconds with 15 queries.