Skip to main content
GameDev.net gamedev.net
🔒 Locked

Full Screen Trouble!

Started by Steve5050 Jan 28, 2008 at 5:03 PM 1 replies 1.7k views
Original Post
Steve5050
Steve5050
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.

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

Thanks Steve
V-man
V-man
Probably zero memory did not work.
If it did, next to use is GetLastError()
Steve5050
Steve5050
I got it.
I had to make my own screenres class
and not use the frame work I was using.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.