I've been trying to get this right for a couple of days now but just can't seem to do it.. I've looked at the powerbasic source and tried to follow that also but still doesn't work. if anyone can help i'd appreciate it.. here's the code.
Code: Select all
IncludeFile "OpenGL.pbi"
Procedure InitGL()
glClearColor_(0.0, 0.0, 0.0, 0.0)
glDepthFunc_(#GL_LESS)
glEnable_(#GL_DEPTH_TEST)
glShadeModel_(#GL_SMOOTH)
glMatrixMode_(#GL_PROJECTION)
glLoadIdentity_()
gluPerspectivef_(45.0, 640/480, 0.1, 100.0)
glMatrixMode_(#GL_MODELVIEW)
EndProcedure
Procedure DrawScene(hDC)
glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
glLoadIdentity_()
glTranslatef_(-1.5, 0.0, -6.0)
glBegin_(#GL_TRIANGLES)
glVertex3f_( 0.0, 1.0, 0.0)
glVertex3f_(-1.0,-1.0, 0.0)
glVertex3f_( 1.0,-1.0, 0.0)
glEnd_()
glTranslatef_(3.0,0.0,0.0)
glBegin_(#GL_QUADS)
glVertex3f_(-1.0, 1.0, 0.0)
glVertex3f_( 1.0, 1.0, 0.0)
glVertex3f_( 1.0,-1.0, 0.0)
glVertex3f_(-1.0,-1.0, 0.0)
glEnd_()
EndProcedure
pfd.PIXELFORMATDESCRIPTOR
hWnd = OpenWindow(0, 10, 10, 640, 480, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "OpenGL Test")
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 = 16
pixformat = ChoosePixelFormat_(hdc, pfd)
SetPixelFormat_(hdc, pixformat, pfd)
hrc = wglCreateContext_(hdc)
wglMakeCurrent_(hdc,hrc)
InitGL()
While Quit = 0
Repeat
EventID = WindowEvent()
Select EventID
Case #PB_EventCloseWindow
Quit = 1
EndSelect
Until EventID = 0
DrawScene(hDC)
SwapBuffers_(hDC)
Wend