i shoot get a blue blank screen
[ the blue is only there to see if opengl is started right ]
Code: Select all
#include once "windows.bi"
#include once "GL/gl.bi"
#include once "GL/glu.bi"
declare function WinMain ( byval hInstance as HINSTANCE, _
byval hPrevInstance as HINSTANCE, _
byval szCmdLine as string, _
byval iCmdShow as integer ) as integer
declare sub opengl_init( w as integer , h as integer )
end WinMain( GetModuleHandle( null ), null, Command( ), SW_NORMAL )
'':::::
function WndProc ( byval hWnd as HWND, _
byval wMsg as UINT, _
byval wParam as WPARAM, _
byval lParam as LPARAM ) as LRESULT
function = 0
dim rct as RECT
dim pnt as PAINTSTRUCT
dim hDC as HDC
select case( wMsg )
case WM_CREATE
GetClientRect( hWnd , @rct )
opengl_init rct.right , rct.bottom
exit function
case WM_PAINT
hDC = BeginPaint( hWnd, @pnt )
GetClientRect( hWnd, @rct )
glClear GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT
EndPaint( hWnd, @pnt )
exit function
case WM_KEYDOWN
if( lobyte( wParam ) = 27 ) then
PostMessage( hWnd, WM_CLOSE, 0, 0 )
end if
case WM_DESTROY
PostQuitMessage( 0 )
exit function
end select
function = DefWindowProc( hWnd, wMsg, wParam, lParam )
end function
'':::::
function WinMain ( byval hInstance as HINSTANCE, _
byval hPrevInstance as HINSTANCE, _
byval szCmdLine as string, _
byval iCmdShow as integer ) as integer
dim wMsg as MSG
dim wcls as WNDCLASS
dim hWnd as HWND
function = 0
with wcls
.style = CS_HREDRAW or CS_VREDRAW
.lpfnWndProc = @WndProc
.cbClsExtra = 0
.cbWndExtra = 0
.hInstance = hInstance
.hIcon = LoadIcon( NULL, IDI_APPLICATION )
.hCursor = LoadCursor( NULL, IDC_ARROW )
.hbrBackground = GetStockObject( BLACK_BRUSH )
.lpszMenuName = NULL
.lpszClassName = @"HelloWin"
end with
if( RegisterClass( @wcls ) = FALSE ) then
MessageBox( null, "Failed to register wcls", "Error", MB_ICONERROR )
exit function
end if
hWnd = CreateWindowEx( 0, _
@"HelloWin", _
"", _
WS_OVERLAPPEDWINDOW or WS_MAXIMIZE , _
0 , _
0 , _
CW_USEDEFAULT, _
CW_USEDEFAULT, _
NULL, _
NULL, _
hInstance, _
NULL )
ShowWindow( hWnd, SW_SHOWMAXIMIZED )''iCmdShow )
UpdateWindow( hWnd )
while( GetMessage( @wMsg, NULL, 0, 0 ) <> FALSE )
TranslateMessage( @wMsg )
DispatchMessage( @wMsg )
wend
function = wMsg.wParam
end function
sub opengl_init( w as integer , h as integer )
'' ReSizeGLScene
glViewport 0, 0, w, h '' Reset The Current Viewport
glMatrixMode GL_PROJECTION '' Select The Projection Matrix
glLoadIdentity '' Reset The Projection Matrix
gluPerspective 45.0, 640.0/480.0, 0.1, 100.0 '' Calculate The Aspect Ratio Of The Window
glMatrixMode GL_MODELVIEW '' Select The Modelview Matrix
glLoadIdentity '' Reset The Modelview Matrix
'' All Setup For OpenGL Goes Here
glShadeModel GL_SMOOTH '' Enable Smooth Shading
glClearColor 0.0, 0.0, 1.0, 1 '' Black Background [ now blue to see if this works ]
glClearDepth 1.0 '' Depth Buffer Setup
glEnable GL_DEPTH_TEST '' Enables Depth Testing
glDepthFunc GL_LEQUAL '' The Type Of Depth Testing To Do
glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST '' Really Nice Perspective Calculations
glEnable( gl_lighting )
dim as single lightpos( 3 ) = { 0 , 100 , 0 , 1 }
dim as single diffuse( 3 ) = { 1 , 1 , 1 , 1 }
glLightfv( gl_light0 , gl_position, @lightpos(0) )
glLightfv( gl_light0 , gl_diffuse , @diffuse(0) )
glEnable( gl_light0 )
end sub