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