miujin's picture

Black Screen at start and end when using lower version of .Net Framework

Hi,

if i compile my program with .NET Framework 4.5 everything is ok, but if i compile with a lower version, than the screen becomes for a short time black when creating the GraphicsContext und deleting it. The GUI of Win7 switch from Aero to the standard Design. Any idea what the problem is and how to fix it?


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. Which version of OpenTK are you using?
  2. Are you requesting a specific GraphicsMode?
  3. Are you using GameWindow or GLControl?
miujin's picture

1. OpenTK Version 1.1.0.0
2. No special GraphicsMode
3. I am using GLControl

The BlackScreen comes after the MainWindow function. In the Mainwindowfunction I create a GLControl which i declare as Child of a WindowsFormsHost.
I create the GLControl with this function call:

_panel = new GLControl(GraphicsMode.Default, 4, 3, GraphicsContextFlags.Default);

the Fiddler's picture

Please try building a new version from here https://github.com/thefiddler/opentk and rebuild your application against that. (You may have to remove and re-add the reference to OpenTK.dll before Visual Studio understands that it has changed.)

This commit should fix the issue you are seeing, but I cannot tell whether the version you are using includes that.

Let me know how that works.

miujin's picture

The new dll doesn't fix the problem.
When i try to compile the code, visual studio says that it cannot find the GlobalAssemblyInfo.cs. I've delete this file from the projects an compile the dll. I don't think that there will be a difference with this file.

the Fiddler's picture

Right-click and build the "Build.UpdateVersion" project manually in order to re-generate the missing GlobalAssemblyInfo.cs. It is true that this does not affect the issue you are seeing.

Is it possible to test the application with a debug version of OpenTK.dll? If so, please do so and post the generated debug messages. Refer to this article on how to capture debug messages.

miujin's picture

If linked the programm with the OpenTK source project and debugged it.
The screen switch and aurora stops running when Line 79 in WinGLContext.cs is called.

ContextHandle temp_context = new ContextHandle(Wgl.Imports.CreateContext(window.DeviceContext));

When i run the programm this line is called two times. When it is called first, everythin is ok, but when it is called a second time, the screen switches.

I've splitted this line and debugged a second time. The call of
Wgl.Imports.CreateContext(window.DeviceContect));
causes the error.

EDIT:
I've found a way, without the error. When I call the constructor of GLControl with a custom GraphicsMode, instead of the default. The screen doesn't switch when i set the number of bits for the stencil buffer from 0 to 1.
GraphicsMode gm = new GraphicsMode(new ColorFormat(8, 8, 8, 8), 32, 1, 0, 0, 2, false);

the Fiddler's picture

Thank you, this is very helpful. What is happening is that WinGraphicsMode selects a "default" mode that does not support DWM composition. When you define your own GraphicsMode with a stencil buffer, you end up with a different mode that supports composition.

This is definitely a bug. I have opened a new issue here: https://github.com/thefiddler/opentk/issues/4

It would be helpful if you could post what GPU and driver version you are using.

Note that CreateContext is called twice by design (just the regular dose of insanity in low-level Microsoft APIs.)

miujin's picture

I'm using a Geforce Quadro 600 with the driver version 320.90

But the problems still exist on another computer with a Geforce Quadro FX 4600 with the driver version 320.96.