use Win32::API;
my $gl_vendor = Win32::API->new(
"OpenGL", "char* glGetString(unsigned int a)"
)->Call( 0x1F00 );
I could see looping over that and using mesagl instead of OpenGL too. | [reply] [d/l] [select] |
use strict;
use Win32::API;
my $gl_getstring = Win32::API->new('OpenGL32', 'glGetString', 'I', 'P'
+);
die "Could not load glGetString : $! / $^E"
unless $gl_getstring;
print "Vendor(a): ", unpack "p", $gl_getstring->Call(0x1F00);
I can't test this on my system, as both your variant and my variant seem to crash somewhere, and I don't know how this system here is set up/crippled. You need to change the library to OpenGL32 though, as that's the name of the library on Win32. I just noticed - I had to change your call some more, before Win32::API accepted it at all:
my $gl_vendor = Win32::API->new(
"OpenGL32", "char* glGetString(int a)"
)->Call( 0x1F00 );
print "Vendor (b): ", $gl_vendor;
I've done some work with OpenGL::Simple and have had relatively good success with it, but I haven't delved into the depths of OpenGL programming. If you want/need a test account, I can make you the same offer I already made to Michael Schwern, that you can mail me files that get run on my Win32 machine (when it's on). My personal interest in SDL is limited though, so I won't be working on it. | [reply] [d/l] [select] |
I've now tested this on my machine with an ATI OpenGL driver installed, and there are some more steps necessary to go through before glGetString will work, as the relevant OpenGL ICD(s) must be loaded, which doesn't happen until after OpenGL is initialized. After some short magic with Inline::C and some browsing of the MSDN, the below code is a very convoluted way to print out ATI Technologies Inc. on my machine. I've left in some warnings and didn't golf down the code, but in theory this is what should work everywhere for Win32.
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 Render
+ing Context";
wglMakeCurrent($hDC,$hRC) or die "Couldn't activate the Rendering Cont
+ext";
print glGetString(0x1F00);
I'm not sure what idea the MESA GL libraries subscribe to, but in theory, they should work the same, if they are the only installed ICD. | [reply] [d/l] |