Author Topic: freeglut CubeDemo3  (Read 4089 times)

0 Members and 1 Guest are viewing this topic.

kryton9

  • Guest
freeglut CubeDemo3
« on: June 09, 2012, 12:16:07 PM »
A new cube demo worked out by Charles and me using the new freeglut library for Oxygen.
This has lighting, and movement. The titlebar has the instructions.

move in/out with the a and z key
rotate the cube with the arrow keys
esc to exit

fps is frames per second it is running at.
 
Unzip into your     oxygen\projects\   folder
« Last Edit: June 09, 2012, 03:47:02 PM by kryton9 »

Aurel

  • Guest
Re: freeglut CubeDemo3
« Reply #1 on: June 09, 2012, 12:29:58 PM »
Hmm Kent ..it works but i think that is little bit slow comparing
with DirectX similiar program, i got 60fps

kryton9

  • Guest
Re: freeglut CubeDemo3
« Reply #2 on: June 09, 2012, 12:41:58 PM »
60 fps is not too bad Aurel, more than enough. I will work on something with more objects and textures for the next demo, we will see how it does. Thanks for trying it out. FPS is important so better to know.
On my netbook which is not too powerful I am getting around 300 fps.


Charles Pegge

  • Guest
Re: freeglut CubeDemo3
« Reply #3 on: June 09, 2012, 02:05:22 PM »
Hi Kent,

To preserve aspect ration in freeglut (when the window is stretched):

Include this callback:

sub Reshape(sys w,h)
    establishProjectionMatrix w,h
end sub


then set up the callback as usual

       glutReshapeFunc    @reshape


They certainly make it painless

Charles

« Last Edit: June 09, 2012, 03:17:25 PM by Charles Pegge »

kryton9

  • Guest
Houston, we have a problem
« Reply #4 on: June 09, 2012, 03:45:46 PM »
I went to make the change Charles. My main programming is done on my small netbook. My notebook I save for gaming. The netbook has ATI video and the notebook NVidia.
I don't know what you guys saw when you ran the demo, but you should have seen a cube with different colors on each side that reacted to the lighting as it rotated around.

The same program on my notebook with NVidia just shows a purple cube with lighting.

First post will have the udpated version in a minute.


Charles Pegge

  • Guest
Re: freeglut CubeDemo3
« Reply #5 on: June 09, 2012, 04:12:02 PM »
I'm using desktop NVidia - no glitches here,Kent. What happens to the other GLdemos that come with Oxygen?

I must shift into the dream dimension for a few hours, and trust I will not be abducted for medical experiments. Good Night :)

Charles

kryton9

  • Guest
Houston, problem solved
« Reply #6 on: June 09, 2012, 04:37:15 PM »
Stupid me, I keep forgetting my notebook has Optimus. It is intel video for general use and Nvidia for high end. It didn't switch to nvidia and was using the intel drivers. I manually forced it to use nvidia and problem solved. When you wrote that it worked on your nivida, that clicked in my memory about optimus headaches.

My recommendation, never buy Optimus or any other hybrid energy saving dual graphics solution like it.

kryton9

  • Guest
cube demo 4, a step back
« Reply #7 on: June 09, 2012, 06:29:54 PM »
I modified cube demo 3 to show a simpler way to handle keyboard input. Less code, but you lose multi-key at once input and also response speed.
But many times you don't need those features, so this is a simpler way to do things.

Just unzip into your existing oxygen/projects/cube demo 3     folder. 

kryton9

  • Guest
speed
« Reply #8 on: June 09, 2012, 07:13:32 PM »
I downloaded all the glut examples I could that were available for NeHe tutorials. Some of the advanced did take a while to load and run on my netbook. I don't think freeglut will be fast enough for games on weaker computers like my netbook. Also many of the examples had code relying on the underlying OS. I think that is why you see so many different downloads at the bottom of NeHe pages. I thought freeglut had it all and we would not need to go into the OS api.  I think worrying about cross platform is something I need to get over. Looking at the numbers, Windows is King and will be for some time.

Still for making quick tools and utilities, I think freeglut will be great.

JRS

  • Guest
Re: freeglut CubeDemo3
« Reply #9 on: June 09, 2012, 08:08:19 PM »
Quote
Looking at the numbers, Windows is King and will be for some time.

The numbers ...

  • HP lays off 30,000 employees due to lack of sales of their PCs. (the 'king' is going down with the ship)
  • The corporate post-PC era may be arriving and Dell isn’t happy about it. The wild card is whether Windows 8 saves the day for Dell. (why invest in a platform at the end of it's useful life?)
  • Linux is going to make a nice home for a lot of PCs/laptops that Microsoft now claims is legacy hardware.

kryton9

  • Guest
Re: freeglut CubeDemo3
« Reply #10 on: June 09, 2012, 09:56:27 PM »
John, it is a possibility that can't be ruled out. That's why this upcoming Windows 8 debut is so important. If it turns out anything like Vista's introduction, then the doors are wide open again. But if it is a smooth experience as Windows 7 is, then they shall remain crowned King :)

Hardware manufacturers are announcing soon upcoming devices with Windows 8, so it is pretty close.

My dream device right now would be one device with cell phone capabilities in a 7" tablet form factor with slideout keyboard, that you can actually develop natively on, just as you can with netbooks now.
You would use headphone/mic or bluetooth headset for talking or speaker in quiet environment for the phone. So as long as the tablet is nearby you are set. Right now my tablet is 10", although I like the bigger screen, it does get tiresome holding for some time. I think the 7 to 8" probably is a good size.

Charles Pegge

  • Guest
Re: freeglut CubeDemo3
« Reply #11 on: June 09, 2012, 11:30:22 PM »
Hi Kent,

I would hang onto to multikey, for instance: with arrow keys: press m to move up and down, r to rotate, z to move near and far, s to enlarge and reduce, l to control lighting.

Using materials:

Code: OxygenBasic
  1.  
  2.         glFloat ambient[4],diffuse[4],specular[4],shininess[1]
  3.         ambient <= 0.5, 0.1, 0.1, 1.0
  4.         diffuse <= 1.0, 0.1, 0.1, 1.0
  5.         specular<= 0.0, 0.0, 0.9, 1.0
  6.         shininess<=20.0
  7.         glMaterialfv GL_FRONT, GL_AMBIENT,   ambient
  8.         glMaterialfv GL_FRONT, GL_DIFFUSE,   diffuse
  9.         glMaterialfv GL_FRONT, GL_SPECULAR,  specular
  10.         glMaterialfv GL_FRONT, GL_SHININESS, shininess
  11.         '
  12.        GlutSolidSphere  1,36,16
  13.  

Material interacts with the light model:

Code: OxygenBasic
  1. GLfloat light_ambient[4]  = {0.2, 0.2, 0.2, 1}
  2. GLfloat light_diffuse[4]  = {0.7, 0.7, 0.7, 1}
  3. GLfloat light_specular[4] = {0.7, 0.7, 0.7, 1}
  4. GLfloat light_position[4] = {1.0, 1.0, 1.0, 0.0}
  5.  
Charles
« Last Edit: June 09, 2012, 11:36:37 PM by Charles Pegge »

kryton9

  • Guest
Re: freeglut CubeDemo3
« Reply #12 on: June 09, 2012, 11:37:44 PM »
Did you get some sleep. I can't believe you cranked out a nice demo so soon!  Thanks, looks nice.

Charles Pegge

  • Guest
Re: freeglut CubeDemo3
« Reply #13 on: June 09, 2012, 11:47:07 PM »

Quote
Did you get some sleep

Yes, I think that is where my better ideas come from :)

Aurel

  • Guest
Re: freeglut CubeDemo3
« Reply #14 on: June 10, 2012, 12:59:06 AM »
Of course that windows is king.. ;D
leave a linux where he belong - servers,experimental OS...etc
Linux is not a graphical OS and probably never will be...