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.


In reply to Re^4: SDL_Perl for Win32? by Corion
in thread SDL_Perl for Win32? by jryan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.