Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Tue Nov 21, 2017 8:47 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: OpenGL and SpriteSurface Help
PostPosted: Thu Apr 05, 2012 2:44 pm 
Offline

Joined: Thu Dec 01, 2011 2:13 pm
Posts: 288
Hi

I am a programmer and developed some games with Real Studio. But however - I never used OpenGL or SuperSpriteSurface. So could please someone help me:

1. To build with OpenGL: A small white ball and a blue one which moves in a circla around the white one (in 3D)
2. To build with SuperSpriteSurface: A small character which can run and jump. There are low walls which can be jumped over (in 2D)

Regards
NaNdummy

Btw, you do not have to describe me any method, I am not a newbie.

_________________
Mac OS X 10.3-10.8
Windows 2000 (I know it sucks)
Windows Server 2007

You want a bunch of new classes and web styles? realstudiodevspot.com (search there for Web Styles Plugin)
Folderitem is too hard? File Bin Class
I hate cows.


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL and SpriteSurface Help
PostPosted: Fri Apr 06, 2012 1:33 pm 
Offline

Joined: Mon Feb 05, 2007 11:35 am
Posts: 98
For 1, the simplest way I can think of (off the top of my head, so do test):

Create a declare to gluSphere (should be standard on Mac; need glu32.dll on Win) and use it to create your two spheres.

For drawing in pseudocode:
OpenGL.glLoadIdentity // Reset transformations

// White sphere first
OpenGL.glTranslatef(x,y,z) // position
OpenGL.glColor3f(1, 1, 1) // white color
declare gluSphere(handle, radius, slices, stacks) // draw sphere

// Blue sphere next
OpenGL.glTranslatef(x,y,z) // orbit distance from white sphere, keep this constant or you'll affect rotation
OpenGL.glRotatef(angle,x,y,z) // angle and axis (your axis is probably 0,1,0 if orbiting around Y)
OpenGL.glColor3f(0, 0, 1) // blue color
declare gluSphere(handle, radius, slices, stacks)

The key is that the translate and rotate functions are relative. First, Reset everything with LoadIdentity so that subsequent translates don't build on the last. The first translate sets the white sphere's position, but the second translate for the blue one is an offset from the last translation. The rotate is then considered absolute: you must keep track of the angle yourself. It's easy to mess up here, so hopefully I've written the code correctly myself!

You could put all of this code into OpenGLSurface.Render and have a timer keep calling the Render method.


Regards,

Jeff Quan
jeff@jcquan.com
http://www.jcquan.com/JQportfolio
My RBGL replacement classes: http://www.jcquan.com/REALbasic


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL and SpriteSurface Help
PostPosted: Sat Apr 07, 2012 5:51 am 
Offline

Joined: Thu Dec 01, 2011 2:13 pm
Posts: 288
Thanks! That helped much!!!

Now for #2...

_________________
Mac OS X 10.3-10.8
Windows 2000 (I know it sucks)
Windows Server 2007

You want a bunch of new classes and web styles? realstudiodevspot.com (search there for Web Styles Plugin)
Folderitem is too hard? File Bin Class
I hate cows.


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL and SpriteSurface Help
PostPosted: Sat Apr 07, 2012 8:38 pm 
Offline
User avatar

Joined: Thu Feb 16, 2006 10:04 pm
Posts: 262
The OpenGL Redbook had a demo with spinning planets that you should check out. Scroll down on this page and look for "planet". I duplicated this project a million years ago in Rb. Don't have it anymore, but if you read thru the code, you should be able to get things rolling. You'll probably need to add some GLUT declares on your own. Have fun ... 8)

http://lab.bachem-it.com/opengl/redbook/


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL and SpriteSurface Help
PostPosted: Sun Apr 08, 2012 8:37 am 
Offline

Joined: Thu Dec 01, 2011 2:13 pm
Posts: 288
Thanks mauitom! Looks very interesting.

_________________
Mac OS X 10.3-10.8
Windows 2000 (I know it sucks)
Windows Server 2007

You want a bunch of new classes and web styles? realstudiodevspot.com (search there for Web Styles Plugin)
Folderitem is too hard? File Bin Class
I hate cows.


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL and SpriteSurface Help
PostPosted: Sun Apr 08, 2012 10:04 am 
Offline

Joined: Thu Dec 01, 2011 2:13 pm
Posts: 288
jquan wrote:
For 1, the simplest way I can think of (off the top of my head, so do test):

Create a declare to gluSphere (should be standard on Mac; need glu32.dll on Win) and use it to create your two spheres.

For drawing in pseudocode:
OpenGL.glLoadIdentity // Reset transformations

// White sphere first
OpenGL.glTranslatef(x,y,z) // position
OpenGL.glColor3f(1, 1, 1) // white color
declare gluSphere(handle, radius, slices, stacks) // draw sphere

// Blue sphere next
OpenGL.glTranslatef(x,y,z) // orbit distance from white sphere, keep this constant or you'll affect rotation
OpenGL.glRotatef(angle,x,y,z) // angle and axis (your axis is probably 0,1,0 if orbiting around Y)
OpenGL.glColor3f(0, 0, 1) // blue color
declare gluSphere(handle, radius, slices, stacks)

The key is that the translate and rotate functions are relative. First, Reset everything with LoadIdentity so that subsequent translates don't build on the last. The first translate sets the white sphere's position, but the second translate for the blue one is an offset from the last translation. The rotate is then considered absolute: you must keep track of the angle yourself. It's easy to mess up here, so hopefully I've written the code correctly myself!

You could put all of this code into OpenGLSurface.Render and have a timer keep calling the Render method.


Regards,

Jeff Quan
jeff@jcquan.com
http://www.jcquan.com/JQportfolio
My RBGL replacement classes: http://www.jcquan.com/REALbasic


Hmm... the declares throw a syntax error...

_________________
Mac OS X 10.3-10.8
Windows 2000 (I know it sucks)
Windows Server 2007

You want a bunch of new classes and web styles? realstudiodevspot.com (search there for Web Styles Plugin)
Folderitem is too hard? File Bin Class
I hate cows.


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL and SpriteSurface Help
PostPosted: Sun Apr 08, 2012 9:11 pm 
Offline
User avatar

Joined: Thu Feb 16, 2006 10:04 pm
Posts: 262
Had a few minutes, here you go, a demo! :D

http://bigdaddysurf.com/blog/?p=499

Image

_________________
Thomas C.
Real Studio Blog
http://bigdaddysurf.com/blog/

https://itunes.apple.com/us/app/maui-dragstrip-2013/id604516033?mt=8
https://itunes.apple.com/us/book/how-to-waterstart/id576214730?mt=11


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group