Quote from: Frank Brübach on April 30, 2024, 01:51:53 PMHello all
Hi Charles did you ever build an example with raytracing with oxygen?
How I can mirror a sphere Texture or making some reflections?
See Photo four
I have used light Position light Ambient light diffuse light specular for my example below but thats Not enough isnt IT?
Do you have any Idea or example to study? Would be great one example I have found in c++
Oxygen openGl' -- 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 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
Page created in 0.124 seconds with 11 queries.