use strict; use Win32::API; my $library = 'OpenGL32'; sub loadFunction { my $code = Win32::API->new(@_); die "Couldn't load $_[1] from library $_[0]: $! / $^E" unless $code; no strict 'refs'; *{$_[1]} = sub { $code->Call(@_) }; }; loadFunction('USER32', 'GetDC', 'L','L'); loadFunction('GDI32', 'ChoosePixelFormat', 'LP','L'); loadFunction('GDI32', 'SetPixelFormat', 'LLP','L'); loadFunction($library, 'wglCreateContext', 'L','L'); loadFunction($library, 'wglMakeCurrent', 'LL','L'); loadFunction($library, 'glGetString', 'L','P'); my $hDC = GetDC(0) or die "Couldn't get the Device Context"; warn "Device context $hDC"; my $pfd = pack "ssVccccccccccccccccccccVVV", (40,1,0x25,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,); my $ofs = pack "p", $pfd; my $pfd_num = ChoosePixelFormat($hDC,$pfd); die "Didn't get a (solid) pixel format: $pfd_num" unless $pfd_num; SetPixelFormat($hDC,$pfd_num,$pfd) or die "Couldn't set the proper pixel format"; my $hRC = wglCreateContext($hDC) or die "Couldn't create the GL Rendering Context"; wglMakeCurrent($hDC,$hRC) or die "Couldn't activate the Rendering Context"; print glGetString(0x1F00);