openGL compatibility between languages

Something which I just rediscovered today is Rosetta code and I hoped to spend some time looking through that code and today I am looking at the "Knapsack" problem in various languages also as it applies here in a strange way as I need to optimize the speed of the execution of openGL code with a certain number of calls that achieves the same result. This is another weighting that can be used for the automatic code generation and becomes a characteristic of my code.

This is a sample of the Java code that is in LWJGL or Java OpenGL, and as you can see the format is the same and this makes it very easy to create a method on my machine, test it and debug it an then port it to a Java application.

GL11.glPushMatrix(); GL11.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); GL11.glRotatef(view_roty, 0.0f, 1.0f, 0.0f); GL11.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);

Below is the C equivalent of the Java code above and as you can see it simply add the prefix "GL11." and so the process is simple if I maintain some modularity and consider how it will port to Python, Blender, or Java.

glPushMatrix(); glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); glRotatef(view_roty, 0.0f, 1.0f, 0.0f); glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);

And this is some similar code in Lesson 11 of NeHe fame which I converted to Python. It is even more similar and really only loses the ";" at the end of the line and if I rememeber correctly, Python doesn't care if you add that. AFAIK. It does have indents and that is important.

glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) glLoadIdentity() glRotatef( lookupdown, 1.0, 0.0 , 0.0 ) glRotatef( sceneroty, 0.0, 1.0 , 0.0 ) glTranslatef( xtrans, ytrans, ztrans )

The first step is to separate the openGL into modular form based on category type with some idea of how it ports between the languages. I suspect that this will give me greater confidence in my code base, as the port can show some flaws in the code that `javac` will tell me or Python will warn. It adds new places where automatic code generation can be certified.

1 comments:

thanks said...
This comment has been removed by a blog administrator.

Automated Intelligence

Automated Intelligence
Auftrag der unendlichen LOL katzen