Oxygen Basic
Programming => Example Code => Topic started by: Peter on June 09, 2012, 04:33:18 AM
Title:
ColorCube
Post by:
Peter
on
June 09, 2012, 04:33:18 AM
Deleted
Title:
Re: ColorCube
Post by:
Charles Pegge
on
June 09, 2012, 10:45:00 AM
Hi Peter,
GlFrustum requires doubles
Declare Sub glFrustum Lib "opengl32.dll" (double ds1,ds2,ds3,ds4,ds5,ds6)
Once you have done this, perspective will perform as expected.
But you will need to move the object about 2 units away from you. (unless you want to be inside the cube :) ).
z=-2
glTranslatef x, y, z
Charles
Title:
Re: ColorCube
Post by:
Charles Pegge
on
June 09, 2012, 12:00:21 PM
You also need one of these (line 608) to update aspect when the window gets stretched.
ElseiF wMsg = WM_SIZE
GetClientRect hWnd, rc
glViewport 0, 0, rc.right, rc.bottom
Aspect=rc.right/rc.bottom
glMatrixMode GL_Projection
glLoadIdentity
Perspective 45.0,Aspect, 0.1,100.0
Title:
Re: ColorCube
Post by:
Charles Pegge
on
June 09, 2012, 12:40:02 PM
It does work, I assure you, Peter. I have all three of your demos working correctly now.
Check out the specification:
http://www.opengl.org/sdk/docs/man/xhtml/glFrustum.xml
Title:
Re: ColorCube
Post by:
Charles Pegge
on
June 09, 2012, 02:13:06 PM
I get 0 0 0 F8, which is the expected result
Code: OxygenBasic
sys
col= 0xFFC8C8F8
byte
a
a = col & 0xFF000000
print
hex
a
a = col & 0x00FF0000
print
hex
a
a = col & 0x0000FF00
print
hex
a
a = col & 0x000000FF
print
hex
a
'result F8 (all others 0)
Ah yes, you want to do some bit shifting:
a=col>>8
and so forth
Code: OxygenBasic
sys
col= 0xFFC8C8F8
byte
a
a=col>>8
print
hex
a
'result c8
Charles
Title:
Re: ColorCube
Post by:
Charles Pegge
on
June 09, 2012, 03:27:25 PM
No need for 0xFF. The compiler does it for you when returning bytes etc.
Function GetColorB(sys kol) as byte
Return kol >> 16
End Function
print hex GetColorB(0xddccbbaa) 'result: cc
If you want really high performance, this produces 100% efficient Assembler. (Functions carry a lot of baggage)
macro GetColorB(c)
(c>>16 and 0xff)
end macro
print hex GetColorB(0xddccbbaa)
--->
mov eax,0xddccbbaa
shr eax,16
and eax,0xff