Original Post
I'm using vb.net 2003 I can't seem to get may app to go fullscreen I don't know whats up here,the nehe code in C# works I don't know why I'm having this problem. (zeromemory and kernal both work if you notice them commented out) Here is the code, it is a little bit messy because I've been farting around with it all day. Thanks Steve
Imports Tao.OpenGl
Imports Tao.Platform.Windows
Module OpenGl
Private Declare Sub ZeroMemory Lib "kernel32.dll" Alias "RtlZeroMemory" (ByVal Destination As Gdi.PIXELFORMATDESCRIPTOR, ByVal Length As Integer)
Private Declare Sub ZeroMemoryfull Lib "kernel32.dll" Alias "RtlZeroMemory" (ByVal Destination As Gdi.DEVMODE, ByVal Length As Integer)
Dim hRC As System.IntPtr
Public Sub EnableOpenGL(ByVal ghDC As System.IntPtr)
Kernel.SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1)
Dim pfd As New Gdi.PIXELFORMATDESCRIPTOR
Dim PixelFormat As Integer
Dim fsc As New Gdi.DEVMODE
Dim fscreen As Screen
If fullscreen Then
'ZeroMemoryfull(fsc, Len(fsc))
fsc.dmSize = Len(fsc)
fsc.dmPelsWidth = 800
fsc.dmPelsHeight = 600
fsc.dmBitsPerPel = 32
fsc.dmFields = Gdi.DM_BITSPERPEL Or Gdi.DM_PELSWIDTH Or Gdi.DM_PELSHEIGHT
'If User.ChangeDisplaySettings(fsc, User.CDS_FULLSCREEN) <> User.DISP_CHANGE_SUCCESSFUL Then
' If The Mode Fails, Offer Two Options. Quit Or Use Windowed Mode.
''If M''essageBox.Show("The Requested Fullscreen Mode Is Not Supported By" & Constants.vbLf & "Your Video Card. Use Windowed Mode Instead?", "NeHe GL", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) = DialogResult.Yes Then
''fullscreen = False ' Windowed Mode Selected. Fullscreen = false
''Else
' Pop up A Message Box Lessing User Know The Program Is Closing.
''MessageBox.Show("Program Will Now Close.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Stop)
''fullscreen = False ' Return false
''End If
End If
''End If
'ZeroMemory(pfd, Len(pfd))
pfd.nSize = Len(pfd)
pfd.nVersion = 1
pfd.dwFlags = Gdi.PFD_DRAW_TO_WINDOW Or Gdi.PFD_SUPPORT_OPENGL Or Gdi.PFD_DOUBLEBUFFER
pfd.iPixelType = Gdi.PFD_TYPE_RGBA
pfd.cColorBits = 32
pfd.cDepthBits = 32
pfd.cStencilBits = 32
pfd.iLayerType = Gdi.PFD_MAIN_PLANE
PixelFormat = Gdi.ChoosePixelFormat(ghDC, pfd)
If PixelFormat = 0 Then
MessageBox.Show("Unable to retrieve pixel format")
End
End If
If Not (Gdi.SetPixelFormat(ghDC, PixelFormat, pfd)) Then
MessageBox.Show("Unable to set pixel format")
End
End If
hRC = Wgl.wglCreateContext(ghDC)
If hRC.ToInt32 = 0 Then
MessageBox.Show("Unable to get rendering context")
End
End If
If Not (Wgl.wglMakeCurrent(ghDC, hRC)) Then
MessageBox.Show("Unable to make rendering context current")
End
End If
End Sub
Sub KillFullScreen()
User.ChangeDisplaySettings(IntPtr.Zero, 0)
End Sub
Sub DisableOpenGL()
Wgl.wglMakeCurrent(IntPtr.Zero, IntPtr.Zero)
Wgl.wglDeleteContext(hRC)
End Sub
End Module