Forums

Problems with Tao-Framework and Cobra

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Re: Problems with Tao-Framework and Cobra

Postby johannes » Sat Mar 15, 2008 6:56 pm

here are the atachments ;) good luck fixing the problems or telling me what I did wrong..
Attachments
muhsdlquit.cobra
branch with Sdl.SDL_QUIT
(1.47 KiB) Downloaded 592 times
muhtype.cobra
type not found in SDL_Event
(1.28 KiB) Downloaded 595 times
johannes
 
Posts: 8

Re: Problems with Tao-Framework and Cobra

Postby Charles » Sat Mar 15, 2008 10:22 pm

Bugs squashed. New code added to the regression test suite.

Note that instead of "1.0 to float", you can use "1.0f". Also, if you say "640.0f / 480.0f" then the expression will be float which eliminates another cast.

Here is the code:
def main is shared
evt as Sdl.SDL_Event
Sdl.sdl_Init(Sdl.sdl_INIT_EVERYTHING)
surfacePtr = Sdl.sdl_SetVideoMode(640,480,32,Sdl.sdl_HWSURFACE|Sdl.sdl_DOUBLEBUF|Sdl.sdl_ANYFORMAT|Sdl.sdl_OPENGL)

h = 640.0f / 480.0f
Gl.glViewport(0, 0, 640, 480)
Gl.glMatrixMode(Gl.gl_PROJECTION)
Gl.glLoadIdentity
Gl.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f)
Gl.glMatrixMode(Gl.gl_MODELVIEW)
Gl.glLoadIdentity
Gl.glTranslatef(0.0 to Single, 0.0 to Single, -40.0 to Single)
while true
Sdl.sdl_PollEvent(out evt)
branch evt.type
on Sdl.sdl_QUIT
break

The SDL API is strange in that the members of classes use the prefixes like "GL" and "SDL_" that I'm sure were needed in C, but aren't needed in C# or Cobra. It might be interesting to write a Cobra program that reads the DLLs, scans the members and spews out a new wrapper class with better names.

Future plans for Cobra that you might be interested in:
  • Allow the "f" suffix even without the fractional part. In other words, recognize "0f" as well as "0.0f"
  • Add float32 and float64 types. "float" becomes an alias to "float64". Literals can have suffixes like "-49.5f32".
  • Provide a "-number:float64" option that changes the default fractional type between float32, float64 and decimal.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Problems with Tao-Framework and Cobra

Postby Charles » Sun Mar 16, 2008 12:17 pm

I've implemented the first two bullets above. So you can refer to types 'float32' and 'float64'. The type 'float' is equivalent to 'float64'.

You can now suffix literals with 'f', 'f32' and 'f64'. You can also use underscores before those suffixes. Examples would be:
1f
5.0_f32
10f32
Charles
 
Posts: 2515
Location: Los Angeles, CA

Previous

Return to Discussion

Who is online

Users browsing this forum: No registered users and 33 guests