OnlyMicha's picture

Error in Release not in Debug mode

Hi,

Programming:
Windows 7 x64 , VB.NET

Problem:
I get an error in Release mode running that will not come in Debug mode. What is wrong ?

Description:
I have an OpenGL Control in Dialog and inside a different Sub I want to build a screenshot like array.
The Problem is to resize a new GLControl inside function. Resizing will only work if I read out Width and
Aspect Ratio into variables (Bug ? )

In Debug mode this works, in Release mode I get an error :
That happens only if I call the sub, otherwise all is ok

************** Ausnahmetext **************
System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
bei OpenTK.Graphics.GraphicsContext.<.cctor>b__0()
bei OpenTK.Graphics.GraphicsContext.get_CurrentContext()
bei OpenTK.Graphics.GraphicsBindingsBase.GetAddress(String funcname)
bei OpenTK.BindingsBase.LoadDelegate(String name, Type signature)
bei OpenTK.BindingsBase.LoadEntryPoints()
bei OpenTK.GLControl.OnHandleCreated(EventArgs e)
bei System.Windows.Forms.Control.WmCreate(Message& m)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

The Code snipped inside the sub :

Dim RenderImage As New OpenTK.GLControl(OpenTK.Graphics.GraphicsMode.Default, 1, 0, GraphicsContextFlags.Default)

With RenderImage
.Width = LayerWidth
.Height = LayerHeight
End With

'Wegen bug in Open TK muß ausgelesen werden sonst werden die Size Werte nicht übernommen...
Dim aa As Integer = RenderImage.Width
Dim bb As Single = RenderImage.AspectRatio
'Das blöde daran ist, das dann auch das Control was grad im Dialog aktiv ist falsch skaliert wird

...

GL.LoadIdentity() 'Die Matrix zurücksetzen

GL.Viewport(0, 0, LayerWidth, LayerHeight) 'Den Viewport setzen
GL.MatrixMode(MatrixMode.Modelview) 'Auswählen der Modelview Matrix
GL.Ortho(....
....


Comments

Comment viewing options

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

Solved it with a small trick :

Adding a second VISIBLE !!! GLControl inside form, this at runtime I shift to outside the visible client rect.
The second one will be rescaled all time I render inside without touching the original one ... no more errors :-)
In this I do background rendering and come back to main gl output later...

dont forget GLControl.MakeCurrent() to swap between them.

Micha