
'OpenTK.Platform.Windows.Wgl' is not accessible in this context because it is 'Friend'.
Posted Monday, 4 October, 2010 - 16:03 by papageorge inHello,
I am writting a project in visual basic using OpenGl. Previously I used to work with TAO but I decided to use openTK. My problem is that I can not use GDI and WGL because it throws this exception "'OpenTK.Platform.Windows.Wgl' is not accessible in this context because it is 'Friend'. ". I use the code as here : http://nio.astronomy.cz/vb/triangle_tao_control.zip. Bellow I show you where I have problem :
Imports OpenTK.Graphics.OpenGL Imports OpenTK.Platform.Windows Imports System Module OpenGL Public Declare Sub ZeroMemory Lib "kernel32.dll" Alias "RtlZeroMemory" (ByVal Destination As Gdi.PIXELFORMATDESCRIPTOR, ByVal Length As Integer) Dim hRC As System.IntPtr Public Sub EnableOpenGL(ByVal ghDC As System.IntPtr) Dim pfd As PixelFormatDescriptor Dim PixelFormat As Integer ZeroMemory(pfd, Len(pfd)) pfd.Size = Len(pfd) pfd.Version = 1 pfd.Flags = PFD_DRAW_TO_WINDOW Or PFD_SUPPORT_OPENGL Or PFD_DOUBLEBUFFER pfd.PixelType = PFD_TYPE_RGBA pfd.ColorBits = 32 pfd.DepthBits = 32 pfd.StencilBits = 32 pfd.LayerType = Gdi.PFD_MAIN_PLANE PixelFormat = Gdi.ChoosePixelFormat(ghDC, pfd) If PixelFormat = 0 Then MsgBox("Unable to retrieve pixel format") End End If If Not (Gdi.SetPixelFormat(ghDC, PixelFormat, pfd)) Then MsgBox("Unable to set pixel format") End End If hRC = Wgl.wglCreateContext(ghDC) If hRC.ToInt32 = 0 Then MsgBox("Unable to get rendering context") End End If If Not (Wgl.wglMakeCurrent(ghDC, hRC)) Then MsgBox("Unable to make rendering context current") End End If End Sub Sub DisableOpenGL() Wgl.wglMakeCurrent(IntPtr.Zero, IntPtr.Zero) Wgl.wglDeleteContext(hRC) End Sub End Module
thanks


Comments
Re: 'OpenTK.Platform.Windows.Wgl' is not accessible in this ...
OpenTK doesn't provide access to Wgl or Gdi.
Besides, the code you list is unnecessary in OpenTK. I assume you are using WinForms? In that case, just drag&drop an OpenTK.GLControl onto your main Form.
Alternatively, use a GameWindow or (more advanced and also unnecessary) create and attach a GraphicsContext to any window you like.
Re: 'OpenTK.Platform.Windows.Wgl' is not accessible in this ...
Ok. I tried to import the OpenTK.dll but it says that this component could not be loaded. Moreover There is not a OpenTK.GLControl class to import
Re: 'OpenTK.Platform.Windows.Wgl' is not accessible in this ...
More information, please!
Which version of OpenTK? What operating system? Have you added OpenTK.GLControl to your project references?
There is a comprehensive tutorial here: http://www.opentk.com/doc/chapter/2/glcontrol
Re: 'OpenTK.Platform.Windows.Wgl' is not accessible in this ...
I use windows vista openTK 1.0 and visual basic.net. Anyway I found the problem. Thanks for your help :)
Re: 'OpenTK.Platform.Windows.Wgl' is not accessible in this ...
I use windows vista openTK 1.0 and visual basic.net. Anyway I found the problem. Thanks for your help :)
Would be nice if you posted the solution so the thread is not completely useless. Other people may benefit from this.
Re: 'OpenTK.Platform.Windows.Wgl' is not accessible in this ...
I do not believe that the post is completely useless :) I did what we discused. So as conclusion if you want I would say that :
OpenTK doesn't provide access to Wgl or Gdi and alternatively I could include the OpenTK.GLControl.dll file in order to use the GLControl component.