Shocker's picture

2byte character code may causes a bug with GL.ShaderSource .

Thanks for a lot of working of OpenTK .

I have been learning the OpenGL for few months .
And recently, I could reach the step using some shaders .

I met a small? bug .
I'm developing a project which uses shader .
So, I need to use "GL.ShaderSource" .
I wrote shaders and debug a project .
Then program crashes on GL.ShaderSource line .

Error message is "COM Exception" .

I think about root of the crash .
Tried removing Japanese comment line from shader code , the crash disappered .
Maybe, 2byte character code is root of this bug .

I'm sorry this poor English . Thank you .


Comment viewing options

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

I don't think that OpenGL can deal with unicode characters at all. OpenTK passes your shader directly to .Net, which converts it to ANSI (UnmanagedType.LPStr, which is the default for C#) before passing it to OpenGL. Unfortunately, this process is lossy and the resulting shader may not work correctly.

May I suggest a small experiment? Download a shader GUI like RenderMonkey and try modifying one of its existing shaders to contain 2byte characters. Does it work?

If it does work, then this issue may be fixable from within OpenTK (please file a bug report and I will see what I can do!)

Shocker's picture

Thanks .
I tried "Render Monkey" and "Shader Maker", and there is no problem to use 2byte character .
I also tried adding some 2byte char comment into the shader in OpenTK.Examples - OpenGL - 3.0 - HelloGL3.cs .
Same crash appeared .

System.Runtime.InteropServices.COMException (0x8007007A)

I'm going to submit a similar report to bug report .