Update: My bad. I was including an alpha value in the color array. Being used to perl sub just ignoring extra args whilst I worked out how to use aplha values in OpenGL. But XS subs aren't like perl subs, and the extra value causes the sub to print it's usage message and fail. :(
I finally got OpenGL built and installed and I'm just starting to play with it and I encountered a Perl problem that I haven't experienced before. I'm trying to call glColor3f() within a subroutine into which I'm passing an array ref containing the rgb values.
- My first attempt was: glColor3f( @$ref ); fails!
But that (and all other failures) bellyaches Usage: OpenGL::glColor3f(red, green, blue) at...
- So then I tried hard coding the numbers:glColor3f( 1.0, 0.0, 0.0 ); works!
- So then I tried glColor3f( $ref->[ 0 ], $ref->[ 1 ], $ref->[ 2 ] ); works!
- Hm! Prototype problem? &glColor3f( @$ref ); Fails!
- Then I tried: glColor3f( @{ $ref }[ 0, 1, 2 ] ); works!
- Then I tried: glColor3f( map $_, @$ref ); fails!
Quick peruse of the xs source shows:
void
glColor3f(red, green, blue)
GLfloat red
GLfloat green
GLfloat blue
Which doesn't clarify what's going on. Can you?
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.