Seite 1 von 1

initOpenGL Fenster Fullscreen

Verfasst: 18.07.2005 22:12
von IcedCoffee
MOin

Ich will gerade mal wider mit OpenGL anfangen und habe da probs beim fenster erstellen [Fullscreen]
also das fenster ist ja da so wie's soll aber ich sehe nur Rot und nicht mein schönnes* graues Dreieck

Code: Alles auswählen

XIncludeFile "OpenGL.pb"

WindowFlags = #PB_Window_BorderLess
Version = 1
Global hWnd.l
Global WindowWidth.w
Global WindowHeight.w
Global WindowDepth.w
OldWindowWidth.w
OldWindowHeight.w
OldWindowDepth.w

ExamineDesktops()
OldWindowWidth = DesktopWidth(0)
OldWindowHeight = DesktopHeight(0) 
OldWindowDepth = DesktopDepth(0)

If OpenPreferences("options.prefs") = 0
    MessageResult.b = MessageRequester("Error", "Can't open: 'options.prefs' You want To play with standard settings?", #PB_MessageRequester_YesNo)
    If MessageResult = 6
        WindowWidth = 1024
        WindowHeight = 768
        WindowDepth = 32   
    Else
        End
    EndIf
Else
    PreferenceGroup("Window")
    WindowWidth = ReadPreferenceLong("WindowWidth", 1024)
    WindowHeight = ReadPreferenceLong("WindowHeight", 768)
    WindowDepth  = ReadPreferenceLong("WindowBit", 32)
    ClosePreferences()
EndIf

Procedure ChangeDisplaySettings(Width.w, Height.w, Depth.w)
    dmScreenSettings.DEVMODE
    dmScreenSettings\dmSize = SizeOf(DEVMODE)
    dmScreenSettings\dmPelsWidth = Width
    dmScreenSettings\dmPelsHeight = Height
    dmScreenSettings\dmBitsPerPel = Depth
    dmScreenSettings\dmFields = 262144 | 524288 | 1048576
    If ChangeDisplaySettings_(@dmScreenSettings, 1)
        Result = 1
    Else
        Result = 0
    EndIf
    ExamineDesktops()
    ProcedureReturn Result
EndProcedure

Procedure MyWindowCallback(WindowID, Message, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
If Message = #WM_SIZE
glViewport_(0, 0, DesktopWidth(0), DesktopHeight(0))
Result = 1
EndIf
ProcedureReturn Result
EndProcedure

ChangeDisplaySettings(WindowWidth, WindowHeight, WindowDepth)
If OpenWindow(0, 0, 0, DesktopWidth(0), DesktopHeight(0), WindowFlags, "IedCoffee InitOGL version 0.1b") = 0
    MessageResult.b = MessageRequester("Error", "Can't open the Window", #PB_MessageRequester_Ok)
    End
EndIf

SetWindowCallback(@MyWindowCallback())

hWnd = WindowID(0)
pfd.PIXELFORMATDESCRIPTOR
hDC = GetDC_(hWnd)
pfd\nSize = SizeOf(PIXELFORMATDESCRIPTOR)
pfd\nVersion = 1
pfd\dwFlags = #PFD_SUPPORT_OPENGL | #PFD_DOUBLEBUFFER | #PFD_DRAW_TO_WINDOW
pfd\iLayerType = #PFD_MAIN_PLANE
pfd\iPixelType = #PFD_TYPE_RGBA
pfd\cColorBits = 24
pfd\cDepthBits = 32
pixformat = ChoosePixelFormat_(hDC, pfd)
SetPixelFormat_(hDC, pixformat, pfd)
hrc = wglCreateContext_(hDC)
wglMakeCurrent_(hDC, hrc)

Repeat
    glClearColor_(1.0, 0.0, 0.0, 0.0)
    glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
    glLoadIdentity_()
    
    glColor3f_(1.0,1.0,1.0)
    glBegin_(GL_TRIANGLES)
        glVertex3f_( 0.0, 1.0, -5.0)
        glVertex3f_(-1.0,-1.0, -5.0)
        glVertex3f_( 1.0,-1.0, -5.0)
    glEnd_()
    
    SwapBuffers_(hDC)
    Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow

ChangeDisplaySettings(OldWindowWidth, OldWindowHeight, OldWindowDepth)
End

Verfasst: 20.07.2005 17:14
von IcedCoffee
leute kann mir keiner hälfen?

ich teste jetzt hir schon seit 2tagen herum und nix geht :cry: :cry: :cry: :cry:

Verfasst: 20.07.2005 17:29
von DarkDragon
GL_TRIANGLES -> #GL_TRIANGLES
-5.0 -> 0.0
und am Ende bitte:

Code: Alles auswählen

Until Event = #PB_Event_CloseWindow Or GetAsyncKeyState_(#VK_ESCAPE)
ReleaseDC_(hWnd, hDC)
CloseWindow(0)
ChangeDisplaySettings(OldWindowWidth, OldWindowHeight, OldWindowDepth)
End

Verfasst: 20.07.2005 20:00
von IcedCoffee
jeahr :allright: :allright:
und das ganze war jetzt nur wegen dem kleinen # und -5.0
toll und das waren jetzt 2 tage arbeit :? goil