Hey all.. new little question about OpenGL and reflection Mode of an object..
I have used the CubicRockRefl.o2bas example and reduced IT to two objects cone and Torus Ring..
what exactly perform the reflection ?
AS I suppose its based on makeTexture and Shadow Forms but I am Not Sure.
I have noticed that the objects were doubled but the Floor seems to be transparent...
$ title "Object Reflection"
$ FileName "t.exe"
'uses RTL64
% ExplicitMain
% MultiSamples 4
uses OpenglSceneFrame
uses MinMidi
uses glo2\shapes
uses glo2\materials
uses glo2\particles
indexbase 1
sys GdiplusToken
float ang1
float ma[16]
float li[16]
int cube,sphere,helix,tors,csface
sys hmo 'midi
Cloud cloud1
Smoke smoke1
plant fern
sub MinTextureA(int n,f,h,b)
============================
static long v[16]
v<=
b,b,b,b,
b,f,h,b,
b,h,h,b,
b,b,b,b
MakeTexture @v, 4, 4, n
End sub
sub InitMidi()
================
int er
er=midiOutOpen(hmo, 0, 0, 0, CALLBACK_NULL) '0=synth a 2=soft synth
midiOutShortMsg(hmo, 0xC0+0x0D00) 'Xylophone Bells assign
end sub
function ding(int v,n)
======================
if v>127 then v=127
if v<10 then v=10
'midiOutShortMsg(hmo, v*0x10000+n*0x100+0x89) 'percussion off
midiOutShortMsg(hmo, v*0x10000+n*0x100+0x99) 'percussion on
end function
sub initialize(sys hWnd)
========================
'
InitMidi
GDIplus 1
'
'PREPARE TEXTURES
'
glGenTextures 16, texn
'
'
seed=0x12345678
MinTexture texn[1],0xffffffff,0x80ffffff,0x00ffffff 'whitecloud
MinTexture texn[2],0xffffffff,0x80ffffff,0x00000000 'smoke
MinTextureA texn[3],0x80000000,0x40000000,0x00000000 'soft light shadow
MinTextureA texn[4],0xc0000000,0x60000000,0x00000000 'soft medium shadow
MinTextureA texn[5],0xff000000,0x80000000,0x00000000 'soft intense shadow
'
static int res=256,texspace
texspace=res*res*4
string imgs[3]
imgs[1]=nuls texspace
imgs[2]=imgs[1]
imgs[3]=imgs[1]
'LoadPixImage "../images/crate.jpg",res,imgs[1]
'
'pixbase,width,height,stride,colorval,offset
--------------------------------------------
AddNoiseC strptr imgs[1],res,res,32,060,060,100,255,0x53535353,1
AddNoiseC strptr imgs[1],res,res,16,060,060,100, 0,0x35353535
AddNoiseC strptr imgs[1],res,res,08,070,070,050, 0,0x53535353
AddNoiseC strptr imgs[1],res,res,02,010,010,005, 0,0x53535353
MakeTexture strptr imgs[1],res,res,texn[10]
'
AddNoiseC strptr imgs[2],res,res,08,100,100,000,255,0x35353535,1
AddNoiseC strptr imgs[2],res,res,02,100,100,000, 0,0x35353535
AddNoiseC strptr imgs[2],res,res,01,050,050,000, 0,0x35353535
MakeTexture strptr imgs[2],res,res,texn[11]
'
'AddNoiseC strptr imgs[3],res,res,32,060,060,100,128,0x53535353,1 'const alpha
AddNoiseC strptr imgs[3],res,res,32,060,060,100,255,0x53535353
AddNoiseC strptr imgs[3],res,res,16,060,060,100, 0,0x35353535
AddNoiseC strptr imgs[3],res,res,08,070,070,050, 0,0x53535353
AddNoiseC strptr imgs[3],res,res,02,010,010,005, 0,0x53535353
MakeTexture strptr imgs[3],res,res,texn[12]
'
sys p
p=fern.new res,32000 'pixel map
MakeTexture p,res,res,texn[13]
fern.free
cube=CompileList : CubeForm : glEndList
sphere=CompileList : Spheric 1,1,6 : glEndList
tors=CompileList : torus 1.,.20 : glEndList
'
'standard lighting
------------------
li<=
0.0, 8.0, 8.0, 1.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
'
SetTimer hWnd,1,10,null
end sub
sub Release(sys hwnd)
'====================
glDeleteLists cube,1
glDeleteLists sphere,1
glDeleteLists helix,1
glDeleteLists tors,1
glDeleteLists csface,1
glDeleteTextures 16, texn
Gdiplus 0
killTimer hwnd, 1
MidiOutClose hmo
end sub
sub RenderPlane(int tex, float u,v)
===================================
glBindTexture GL_TEXTURE_2D,tex
glBegin GL_QUADS
glNormal3f 0.,1.,0.
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
end sub
sub scene(sys hWnd)
===================
'
static single ra,ri,angi1=.4
'
ActiveFrame
glClearColor 0.5, 0.5, 0.7, 0
'
float fcolor[4]={.5, .5, .7, .99}
glfogi GL_FOG_MODE,GL_EXP
glfogf GL_FOG_DENSITY,0.020
glfogfv GL_FOG_COLOR, fcolor
glfogf GL_FOG_INDEX, 0
glfogf GL_FOG_START, -1.0
glfogf GL_FOG_END, -100.0
glEnable GL_FOG
'
glPolygonMode GL_FRONT_AND_BACK, GL_FILL
glEnable GL_NORMALIZE
'
static int t1,t2,t3
t1=texn[10] : t2=texn[11] : t3=texn[12]
'
'MYSTERIOUS RED PLANET
glPushMatrix
glTranslatef -20.,10.,-95.0 '-95.0
Material Red
glScalef 8.0,8.0,8.0 '6.,6.,6.
glEnable GL_LIGHTING
glCallList sphere
'glDisable GL_LIGHTING
glPopMatrix
'
'OBJECTS REFLECTED IN FLOOR
---------------------------
'
li[2]=-li[2] : lighting li 'y position
'
'CONE REFLECTION
glPushMatrix
Material Silver
glTranslatef -3.0,-2.,-8.0
glScalef .5,-.5,.5
glBindTexture GL_TEXTURE_2D,t1
ConeFaces 16,0.,2.,0.
glPopMatrix
'RING REFLECTION
Material Gold
glPushMatrix
glTranslatef 2.0,-2.23,-7.0
glScalef .75,-1.00,.75
glCallList tors
glPopMatrix
li[2]=-li[2] : lighting li 'y position
'
'FLOOR TILES
glPushMatrix
glEnable GL_TEXTURE_2D
glTranslatef -8.0,-1.99,-5.0
glScalef .25,1.,.25
glPushMatrix
int i,j,a
macro rtile1
Material White
RenderPlane t3,1.,1.
glTranslatef 2.,0.,0.
end macro
macro rtile2
Material White
RenderPlane t3,1.,1.
glTranslatef 2.,0.,0.
end macro
for j=1 to 16
for i=1 to 16
if a
rtile1
rtile2
else
rtile2
rtile1
end if
next
glTranslatef -64.0,0.,-2.
a=1-a 'alternate
next
glPopMatrix
glDisable GL_TEXTURE_2D
glPopMatrix
Material White
'
'RING
Material Gold
glPushMatrix
'glTranslatef 3.0,-1.77,-7.0
glTranslatef 2.0,-1.27,-7.0
glScalef .75,1.00,.75
glCallList tors
glPopMatrix
'
'CONE
glPushMatrix
Material Silver
'glTranslatef -3.,-2.,-8.0
glTranslatef -3.,-1.,-8.0
glScalef .5,.5,.5
glBindTexture GL_TEXTURE_2D,t1
ConeFaces 16,0.,2.,0.
glPopMatrix
glDisable GL_TEXTURE_2D
'
ang1+=angi1
if ang1>360 then ang1-=360
end sub
MainWindow width,height,WS_OVERLAPPEDWINDOW
Hi Frank,
There is a transparent textured plane between the object and its reflection.
A more efficient way to do reflections is to use GLSL shaders, but that is a whole new ballgame.
Example in demos\opengl/glsl\sierpinski...
Thank you Charles :)
But a Lot of glsl shader examples dont Work Here glML 16.o2bas is Last example thats running.. your shader and Index buffer example Here: glML22.o2bas causes a Lot of Errors see my Pics below..
I suppose newer oxygen Version dont Like IT an old Version of 2017 this sierpinsky example works fine..
But its Not Urgent at the moment to fix and Run IT .. thats all a Higher Level stuff ;)
Thanks
From a formal PowerBASIC user
https://forum.it-berater.org/index.php/topic,3873.msg12939.html#msg12939
Yes, Patrice is a master of images, and a perfectionist.
Frank, there no problems with the shaders or the VBO example. Last modified around 2020-2022
I ran them direct from folder icons and through Oxide and Peroxide (using Windows 11), so I Don't know what is going wrong on your system.
Thanks Charles but I am using Here latest oxygen build too... Thats Strange thing
Do me a favor please can you send to me your example with shader Torus Like your Pic in the Last Post and the necessary shader Inc Files? Would be great thanks Bye Frank
PS I am using oxygen.dll from 8. October 2023 and Windows 10 all Other OpenGL examples are running fine except glsl folder Up to example glml17.o2bas cause These Errors
Hi Frank,
Its time for another update since there are a few minor changes. This is much easier than attempting to send selected inc files associated with particular examples. I hope this helps.
No change to the Oxygen compiler itself since the last update P7
Sierpinski has moved to another subfolder: demos\opengl\geom\
The flying torus image is from glML33.o2bas.
https://github.com/Charles-Pegge/OxygenBasic/blob/master/OxygenBasic07P8.zip