Inertia's picture

Wishlist

For the mentioned upcoming release, here are minor issues I came around. Nothing serious, and too small issues to create a new topic for them alone.

1) The enum GetTextureParameter doesn't contain GL_TEXTURE_COMPRESSED.

2) Glu.ErrorString expects different type as parameter, than what is returned by GL.GetError(); Unnecessary cast? Don't see any other use for these commands.

3) KeyboardDevice.cs
public bool KeyRepeat
Documentation unclear about "on", true/false might be better.

4) GL.Color could use a Vector overload, colors can be nicely stored in Vector3/4. The function was also behaving a bit weird always expecting (int) for fixed-point types. E.g. (byte)255 for RGB would result in black as it got cast to int32. Anything but byte/float is not really useful?

5) GL.Material could aswell use a Vector4 overload. I understand why this is difficult for all functions where modes can expect different types for their own parameters, but I think this is a special case where this would make sense. How about adding GL.Materialv4, which can be used for convenience with a Vector4 for specifying colors (ambient/diffuse/specular/emissive), where shininess can still be set through default GL.Material().
This is just something to consider, the current implementation is fine.

Ironically 3) was the point where I decided that it'd be quicker to implement that "keystroke manager" in a few minutes than going through documentation. All I wanted was Glut-like handling for a handful of toggles and getting other functions further, no offense/critique against your design - just a subjective decision for that small project.


Comments

Comment viewing options

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

1, 3 - fixed
2 - the enums are different by design. It is an error to pass a GL ErrorCode enum to the Glu function or vice versa.
4, 5 - working on it.

Edit:
4 - done.
5 - probably better to add an explicit (float[]) cast to Vector2/3/4, Matrix4. You can then use it like

GL.Materialv(face, pname, (float[])vector);

What do you think?

Edit 2: Scrap that, the (float[]) cast needs to allocate memory. Just call it like this:

GL.Materialv(face, pname, ref vector.X);

It will work and is safe (even if it doesn't look like it ;) )

Inertia's picture

Like I said the current implementation is fine, it just suited GL.Materialv well. Maybe it'll become more clear in code:

// Current
GL.Materialv( MaterialFace.Front, MaterialParameter.Ambient, ref Surfaces[Skin[currentMesh].MaterialIndex].Ambient.X );
GL.Materialv( MaterialFace.Front, MaterialParameter.Diffuse, ref Surfaces[Skin[currentMesh].MaterialIndex].Diffuse.X );
GL.Materialv( MaterialFace.Front, MaterialParameter.Specular, ref Surfaces[Skin[currentMesh].MaterialIndex].Specular.X );
GL.Materialv( MaterialFace.Front, MaterialParameter.Emission, ref Surfaces[Skin[currentMesh].MaterialIndex].Emission.X );
GL.Material( MaterialFace.Front, MaterialParameter.Shininess, Surfaces[Skin[currentMesh].MaterialIndex].Shininess );
 
// Possible Vector4 overload
GL.Materialv4( MaterialFace.Front, MaterialParameter.Ambient, Surfaces[Skin[currentMesh].MaterialIndex].Ambient );
the Fiddler.'s picture

Aha, thanks for the link. Overloaded with the GL ErrorCode enum, so either will work now.

the Fiddler.'s picture

Well, it's safe (can't cause a crash or anything) and it's just one line of code, so why not? (famous last words :) )

Inertia's picture

Sorry, SF is counter-productive >< Should probably use IRC/IM to discuss such topics rather than using the forum.

Inertia's picture

(float*) Surfaces[Skin[currentMesh].MaterialIndex].Ambient is incorrect, should be
ref Surfaces[Skin[currentMesh].MaterialIndex].Ambient.X
what Fiddler said!

the Fiddler.'s picture

Hmm, that's a good idea.

Inertia's picture

Thank you very very much! At least static models render properly now :-)

http://opentk.sourceforge.net/home/system/files/Coke.jpg

P.S. you should probably delete this topic, I cannot edit the cited source code which is not working.

the Fiddler.'s picture

Err, you mean this source code? And you cannot edit it? That's a problem :/

Edit: well, changed the code. Is there really no 'edit' option under the post?

Edit2: Is it me, or does something look very wrong on this model..? Are you using the (float*) or ref method?

Inertia's picture

Yeah, the link is correct. I can only edit posts without replies, and the initial post if I started the topic. Thanks for changing it.

The image is correct, it shows 2 layers. The solid can and a couple of LineLoops drawn ontop of it (the centers of all triangles connected in order of appearance to visualize what the Vertex Cache optimization changed). It works fine with "ref Vector4.X".

Regarding the Matrix4 struct containing errors, I'm heavily using the Rotate function to convert from Quaternions. This could explain the bad animation keyframes, I'll check this out once it's released. It's a bit weird tho that the Torusknot app doesn't seem to suffer from the Rotate function's bug?