yunharla's picture

SGI compatible version?

Hi guys,

I recently started porting some of my GL helpers to VC++ (adding ifdefs for .net compilers...), so i can write code for all the different IDEs without rewriting huge chunks. By doing so i
realised that the OpenTK version im using incompatible with the SGI headers, so i was wondering if and which version could help here? i mean, if there aint one i have to translate the whole
header to opentk code....


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Inertia's picture

Maybe the Compatibility.Tao namespace is what you're looking for?

yunharla's picture

well you see the problem is that neither TAO nor OpenTK seem to work correctly with c++.
For example i use the following code i just get some random junk

	GL::glTexImage2D(int target, level, internalformat, width, height, border, format, type,  IntPtr(pixels)) 
´                    or
	GL::TexImage2D((TextureTarget) target, level, (PixelInternalFormat) internalformat, width , height, border, (PixelFormat) format, (PixelType) type , IntPtr(pixels));

but when i use a c# callback that converts the pixels pointer to a byte[] and then calls Gl.TexImage2D every works....
not to mention that some function that take floats as arguments take doubles....

and since the code is a 1:1 of android and ios i must assume that something is definitly wrong here....

Inertia's picture

some function that take floats as arguments take doubles

If you really should find anything like that, please be make a bug report.

You cannot port C++ code directly to C#, the garbage collector must be considered.
1. One important factor here is that memory allocated in C++ will remain at it's position until deleted, and the code you are porting very likely relies on that. Unless you use the fixed statement or GCHandle & Co. the garbage collector in .Net may compact memory alignment or delete any object that isn't referenced anymore.
2. The OpenGL commands issued by the CPU are queued first and later processed by the GPU at a different pace. This means code like this may work 99 times but fail the 100th with an Access Violation.

byte[] data;
GL.Foo( ref data[0] );
data = null;

...because the garbage collector was faster than GL.Foo.
3. On topic Vertex Arrays, please read