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..
branch with Sdl.SDL_QUIT
(1.47 KiB) Downloaded 184 times
type not found in SDL_Event
(1.28 KiB) Downloaded 197 times
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
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.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f)
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

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.
Posts: 2514
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:
Posts: 2514
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 11 guests