nicolas's picture

TextPrinter problem

 
private readonly TextPrinter printer = new TextPrinter(TextQuality.Default);
private readonly Font font = new Font("Verdana", 10);
 
...
 
printer.Begin();
GL.Translate(300F, 270F, 0F);
printer.Print("TEST", font, Color.White);
printer.End();

this works fine on my development pc running vista (intel duo cpu 3ghz, 2gb ram) but not on my test pc running xp (via nehemiah cpu 666 mhz, 240 mb ram). this test pc is actually a touchscreen terminal. on this terminal I see a bunch of dots and lines, seemingly the top pixel line of "TEST" but I'm not sure. the video adapter on the terminal is "S3 graphics twister".

is this a performance issue? is my test pc too weak to run textprinter?


Comments

Comment viewing options

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

Ok, I've committed a fix in rev. 1746. Can you please update and test the latest SVN version?

nicolas's picture

edit: the TextPrinter works... kinda. When I triangulate an other object in my scene, the app still crashes:

************** Exception Text **************
OpenTK.Graphics.OpenGLErrorException: StackOverflow
at OpenTK.Graphics.GraphicsContext.CheckErrors() in C:\VS2008Projects\Test Projects\opentk\Source\OpenTK\Graphics\GraphicsContext.cs:line 284
at OpenTK.Graphics.ErrorHelper.Dispose() in C:\VS2008Projects\Test Projects\opentk\Source\OpenTK\Graphics\GL\ErrorHelper.cs:line 69
at OpenTK.Graphics.GL.PushMatrix() in C:\VS2008Projects\Test Projects\opentk\Source\OpenTK\Graphics\GL\GL.cs:line 18834

also when I use the parameterless constructor for TextPrinter, it crashes as well. With new TextPrinter(TextQuality.Low) it works for a little bit, then crashes when I try something fancy. "Protected memory" error.

the Fiddler's picture

The portion of the stacktrace you list simply indicates the OpenTK has caught the OpenGL error linked to the PushMatrix call. The important information is just after this part: where did the PushMatrix call originate from? Was it inside OpenTK / OpenTK.Utilities or in your own code?

I don't think there is any call to PushMatrix left in OpenTK (will have to check), so you'll have to check whether you are missing any PopMatrix call. If that's not it, I'm afraid that you'll have to replace all PushMatrix calls with your own stack management, if you wish to get this card to work. Something like this:

// Replace snippets like this
GL.MatrixMode(MatrixMode.Projection);
GL.PushMatrix();
...
GL.PopMatrix();
// with this
Stack<Matrix4> projection_matrix_stack = new Stack<Matrix4>();
...
Matrix4 matrix;
GL.GetFloat(GetPName.ProjectionMatrix, out matrix.Row0.X);
projection_matrix_stack.Push(matrix);
GL.MatrixMode(MatrixMode.Projection);
...
matrix = projection_matrix_stack.Pop();
GL.LoadMatrix(ref matrix);

Regarding the parameterless constructor and the "Protected Memory" errors, can you post stacktraces? Maybe it's something that can be worked around inside the TextPrinter.

As you can imagine, getting anything OpenGL-related to work on this card will be hard. You'll have to identify what driver bugs affect you (we already know about alpha textures and - possibly - PushMatrix) and replace the relevant functionality, if possible.

I imagine there is a reason why you are using this hardware, but ultimately it will be much easier to either use a software OpenGL renderer (Mesa3D) or swap the card for an old nvidia one.

nicolas's picture

It's always the same stacktrace:

OpenTK.Graphics.OpenGLErrorException: StackOverflow
at OpenTK.Graphics.GraphicsContext.CheckErrors() in C:\VS2008Projects\Test Projects\opentk\Source\OpenTK\Graphics\GraphicsContext.cs:line 284
at OpenTK.Graphics.ErrorHelper.Dispose() in C:\VS2008Projects\Test Projects\opentk\Source\OpenTK\Graphics\GL\ErrorHelper.cs:line 69
at OpenTK.Graphics.GL.PushMatrix() in C:\VS2008Projects\Test Projects\opentk\Source\OpenTK\Graphics\GL\GL.cs:line 18834
at OpenTK.Graphics.Text.GL1TextOutputProvider.Begin()
at OpenTK.Graphics.TextPrinter.Begin()

Before that is my code. Seems like a TextPrinter issue to me, no? I checked my Push/PopMatrix calls and they are in order.

the Fiddler's picture

Run a SVN update and try again. As of rev. 1746, TextPrinter.Begin no longer calls Push/PopMatrix.

nicolas's picture

I already did that update, I'm at revision 1747

nicolas's picture

regardless of textprinter, any idea why I can't adapt your texturing test program (test.cs) ?

the Fiddler's picture

Make sure you are not building the project against the older version. Visual Studio is somewhat picky and requires you to remove and readd the reference in the solution explorer (simply readding an existing reference will leave the old reference intact.)

No idea about the jpg, sorry. I just tried legend.jpg with Examples.exe (texturing example) and it works just fine.

nicolas's picture

I copied the OpenTK dll's straight from the opentk source folder to the terminal so it should be the correct versions.

Did you replace logo.jpg with legend.jpg in the the Textures class in the source files? Because that's what I tried and I get an error. Sorry for the Dutch.

AttachmentSize
opentk_error.jpg197.76 KB
the Fiddler's picture

Yes and it seems to work fine. Which probably indicates that your video drivers do not support non-power-of-two textures.

IIRC, NPOT textures were added in OpenGL 2.0. There are earlier extensions that provide this functionality, but the S3 card is unlikely to support those.

Edit: Scratch that, they were added in OpenGL 2.1.

AttachmentSize
legend-ok.jpg29.44 KB