BlueMonkMN's picture

Vista?

Some Vista users are reporting problems, and I'm not sure if it's related to OpenTK or my own code. So far I know one user has version 6.0.6000.16386 of opengl32.dll, and is reporting the following error:
Error Screenshot

My own version of opengl.dll (5.1.2600.2180) on Windows XP works fine (I assume that's the significant DLL here). Is there possibly a compatibility problem working with different versions of opengl32.dll? Or just an OS problem?

The game in question was the same one linked in my previous post:
http://sgdk2.enigmadream.com/support/TVSGDK2.zip
And the OpenTK code is based off of version 1166 from SubVersion.

(Edit: Also, what in the world is this "@" prefix I see on some of the parameters. I can't find any documentation on that for C#.)


Comments

Comment viewing options

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

Try adding a few GL.Error checks at the code that causes the problem, they might shed some light.

Also, the drivers up to date? Outdated drivers sometimes cause strange problems on Vista, especially with Nvidia video cards.

I spend half of my time on Vista (x64) working on OpenTK, and it looks stable here. After how much time does this error occur?

BlueMonkMN's picture

I'll try adding some error checks in my own code. I'm not sure if that could shed any light on an Access Violation, unless the access violation is the result of some other failed call, but it's hard to guess where that would be -- perhaps in loading the texture.

Also, in case you didn't notice the edit that I made after your previous post (I was updating at the same time you were posting I guess), what is this "@" modifier I see on some parameters?

I'll try to get more information about the drivers too.

Edit: I assume the error happens during startup. They didn't mention anything about seeing anything work at all. They said they couldn't even run the game, so I guess the main window doesn't even appear (?)

BlueMonkMN's picture

I don't see any GL.Error -- I assume you mean GL.GetError. So I created this function:

   private void CheckError()
   {
      ErrorCode ec = GL.GetError();
      if (ec != 0)
      {
         System.Diagnostics.StackFrame sf = new System.Diagnostics.StackFrame(1, true);
         string fileName = sf.GetFileName();
         int lineNum = sf.GetFileLineNumber();
         System.Diagnostics.Debug.WriteLine(String.Format("{0} at {1} line {2}", ec.ToString(), fileName, lineNum));
      }
   }

I do see a whole bunch of errors occurring even on my own system. Strange that everything seemed to be running so well! It looks like my second call to GL.GenTextures is causing InvalidOperation. But the graphics which it loads seem to work fine. It even returns a valid (new) texture number in the output parameter which lets the rest of the function work. Subsequently, every call to BindTexture is failing.

This is my code for loading a texture. It reports success on the first call and outputs 1. It reports failure on the second call, but outputs 2 and works anyway:

   private int GetTexture(string Name)
   {
      int texture;
      GL.GenTextures(1, out texture);
      CheckError(); // Line 186
...

Later on I have this code. The last CheckError here reports hundreds of InvalidOperation errors while the code is running, but I see no evidence of failure:

   public void DrawFrame(TextureRef texture, System.Drawing.Rectangle sourceRect, System.Drawing.PointF[] corners, int offsetX, int offsetY)
   {
      if ((m_currentOp != DisplayOperation.DrawFrames) ||
          (m_currentTexture != texture))
      {
         if (m_currentOp != DisplayOperation.None)
            GL.End();
         else
         {
            GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (float)TextureEnvMode.Modulate);
            CheckError(); // Line 417
            GL.Enable(EnableCap.Blend);
            CheckError();
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            CheckError();
            GL.Enable(texCap);
            CheckError();
            GL.Disable(EnableCap.DepthTest);
            CheckError();
            GL.Disable(EnableCap.Lighting);
            CheckError();
            GL.Disable(EnableCap.Dither);
            CheckError();
         }
         GL.BindTexture(texTarget, texture.Texture);
         CheckError(); // Line 432
         GL.Begin(BeginMode.Quads);
...

The BindTexture in that second block actually triggers the getTexture in the first block (because the Texture property does lazy initialization) if that makes any difference. Despite all these failures being reported, everything appears to work.

This is a sample of the debug output from the first report of an error. The remainder is very repetitive.

InvalidOperation at C:\Documents and Settings\Ben\Desktop\SGDK2\TVSGDK2\Display.cs line 186
InvalidOperation at C:\Documents and Settings\Ben\Desktop\SGDK2\TVSGDK2\Display.cs line 417
InvalidOperation at C:\Documents and Settings\Ben\Desktop\SGDK2\TVSGDK2\Display.cs line 432
InvalidOperation at C:\Documents and Settings\Ben\Desktop\SGDK2\TVSGDK2\Display.cs line 417
InvalidOperation at C:\Documents and Settings\Ben\Desktop\SGDK2\TVSGDK2\Display.cs line 432
InvalidOperation at C:\Documents and Settings\Ben\Desktop\SGDK2\TVSGDK2\Display.cs line 417
InvalidOperation at C:\Documents and Settings\Ben\Desktop\SGDK2\TVSGDK2\Display.cs line 432
InvalidOperation at C:\Documents and Settings\Ben\Desktop\SGDK2\TVSGDK2\Display.cs line 417
InvalidOperation at C:\Documents and Settings\Ben\Desktop\SGDK2\TVSGDK2\Display.cs line 432
InvalidOperation at C:\Documents and Settings\Ben\Desktop\SGDK2\TVSGDK2\Display.cs line 417
InvalidOperation at C:\Documents and Settings\Ben\Desktop\SGDK2\TVSGDK2\Display.cs line 432
InvalidOperation at C:\Documents and Settings\Ben\Desktop\SGDK2\TVSGDK2\Display.cs line 417

Edit: I tried removing the "else" and allowing the block of code after the GL.End to execute regardless of the condition, then all the errors were on the equivalent of line 417 (which ended up being line 415) and none were occurring on line 432 any more. I'm not sure why I had the else there.

Edit 2: I decided to put CheckError all over the place because it appeared that some of the errors being reported were left over from other operations. As it turns out, all my errors are occurring during calls to GL.End(). Any way to narrow down the source of the actual error?

the Fiddler's picture

Ok, I just recovered from a hard disk crash that made Vista unbootable (there's a free software called testdisk that works miracles!)

The '@' allows you to use names that are reserved keywords as variables, e.g. void Foo(int[] @params) (params is a reserved keyword in C#). It's quite useful when generating bindings to C.

Errors in GL.End() usually indicate that the code calls a function that is not allowed between GL.Begin - GL.End. I don't remember off-hand what operations are not allowed, but in general anything that has to do with construction will fail (e.g. VBOs, display lists, textures). Try commenting out code until the error stops happening.

Errors such as these will hopefully be much easier to catch from OpenTK 0.9.2 onwards - I'm planning to add implicit GetErrors in every OpenGL call, so you won't need to litter your code with these (in debug builds only, of course).

Edit: I forgot to mention that once an OpenGL error occurs, behavior is implentation dependent. Usual symptoms include random crashes, horrible performance and/or OpenGL functions failing at random. Different drivers will produce different results.

There's a good chance that the access violations will disappear as soon as you discover the problem.

BlueMonkMN's picture

As it turns out, all my error checking was causing errors, which was a real pain. I didn't realize you weren't allowed to check for errors between a Begin and an End. But I finally narrowed it down to the fact that I was trying to change the scissor rectangle between a begin and an end. I'll try sending a fixed version to the user who was having a problems and get back with the results later.

BlueMonkMN's picture

It looks like the systems now fail due to (I suspect) inadequate hardware support (graphics on the problem systems don't fail immediately, but they do render improperly and eventually fail). I need to figure out how to do better checking and reporting on hardware requirements before allowing the program to continue.

the Fiddler's picture

You could use GL.SupportsExtension/GL.SupportsFunction to detect what opengl functions are supported. In general, a GL.SupportsExtension("VERSION_1_5") is enough to ensure that you can use VBOs.

GLSL is a little more complicated: the opengl wiki contains a good guide here on how to detect different shading models.

BlueMonkMN's picture

I tried GL.SupportsExtension("VERSION_1_5") all the way down through GL.SupportsExtension("VERSION_1_1") and they all returned false on my system. What could I be missing here?

Also, if anybody is willing to look at the code, I have a C# Express 2008 project posted at http://sgdk2.enigmadream.com/support/TVSGDK2Src.zip.

Everything is working fine in my environment -- no errors reported from GL.GetError any more even. But other environments where this project worked in DirectX are completely unable to draw graphics, and still others are mostly working but showing odd behavior (drawing the wrong graphics sometimes). So I would appreciate any help in identifying fundamental flaws that might exist in this code, which is a general example of the kind of code generated for all SGDK2 projects, with the exception of a few customized pieces.

the Fiddler's picture

I've tested on a couple of computers and both show the same results: shows a windows menu, an fps counter and two white rectangles; if I press enter, the screen goes white and nothing happens.

What should the program show?

Computer config: XP on Intel 865 and Vista x64 on Ati X1950Pro.

Ok, you try this: build a debug version of OpenTK and route System.Diagnostics.Debug to the disk. OpenTK is quite chatty in debug mode, and maybe it can help us find out what's going wrong.

objarni's picture

Maybe it would be a good idea to have a debug-version of OpenTK.dll ready-for-download?