Author Topic: ColorCube  (Read 2280 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
ColorCube
« on: June 09, 2012, 04:33:18 AM »
Deleted
« Last Edit: April 26, 2015, 06:34:11 AM by Peter »

Charles Pegge

  • Guest
Re: ColorCube
« Reply #1 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

Charles Pegge

  • Guest
Re: ColorCube
« Reply #2 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

Charles Pegge

  • Guest
Re: ColorCube
« Reply #3 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

Charles Pegge

  • Guest
Re: ColorCube
« Reply #4 on: June 09, 2012, 02:13:06 PM »
I get 0 0 0 F8, which is the expected result

Code: OxygenBasic
  1.  
  2. sys col= 0xFFC8C8F8
  3. byte a
  4.  
  5. a = col & 0xFF000000
  6. print hex a
  7. a = col & 0x00FF0000
  8. print hex a
  9. a = col & 0x0000FF00
  10. print hex a
  11. a = col & 0x000000FF
  12.  
  13. print hex a 'result F8 (all others 0)
  14.  

Ah yes, you want to do some bit shifting: a=col>>8  and so forth

Code: OxygenBasic
  1. sys col= 0xFFC8C8F8
  2. byte a
  3. a=col>>8
  4. print hex a 'result c8
  5.  

Charles
« Last Edit: June 09, 2012, 02:19:49 PM by Charles Pegge »

Charles Pegge

  • Guest
Re: ColorCube
« Reply #5 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

« Last Edit: June 09, 2012, 03:48:49 PM by Charles Pegge »