Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
March 01, 2006 What's wrong with writefln("%s", glGetString(GL_EXTENSIONS)); | ||||
---|---|---|---|---|
| ||||
What's wrong with writefln("%s", glGetString(GL_EXTENSIONS)); printf works but not writefln? How can I get the returned string by GLubyte* glGetString(); into a D char[]? :) I hope I've expressed myself clear enough. Sorry if I've just wrote incomprehensible garbage. |
March 01, 2006 Re: What's wrong with writefln("%s", glGetString(GL_EXTENSIONS)); | ||||
---|---|---|---|---|
| ||||
Posted in reply to Cris | Cris wrote: > What's wrong with writefln("%s", glGetString(GL_EXTENSIONS)); > > printf works but not writefln? > > How can I get the returned string by GLubyte* glGetString(); into a D char[]? std.string.toString: writefln("%s", toString(glGetString(GL_EXTENSIONS))); --anders |
March 04, 2006 Re: What's wrong with writefln("%s", glGetString(GL_EXTENSIONS)); | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders F Björklund | it doesn't work that way: "src\engine\renderer.d(104): cannot implicitly convert expression ((glGetString)(7939u)) of type ubyte* to char*"
Anders F Björklund wrote:
> Cris wrote:
>
>> What's wrong with writefln("%s", glGetString(GL_EXTENSIONS));
>>
>> printf works but not writefln?
>>
>> How can I get the returned string by GLubyte* glGetString(); into a D char[]?
>
> std.string.toString:
>
> writefln("%s", toString(glGetString(GL_EXTENSIONS)));
>
> --anders
|
March 04, 2006 Re: What's wrong with writefln("%s", glGetString(GL_EXTENSIONS)); | ||||
---|---|---|---|---|
| ||||
Posted in reply to Cris | Cris wrote: > it doesn't work that way: "src\engine\renderer.d(104): cannot implicitly convert expression ((glGetString)(7939u)) of type ubyte* to char*" > Given that its natural type is ubyte* you should be able to do this: # private import std.string ; # # char[] toString (ubyte* foo) { # return std.string.toString(cast(char*) foo); # } I would think so, anyhow. If it will not allow a direct cast to char*, you can always add a middle state cast to void* first. -- Chris Nicholson-Sauls |
March 04, 2006 Re: What's wrong with writefln("%s", glGetString(GL_EXTENSIONS)); | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris Sauls | Thank you, Chris,
I think this will work for me.
Chris Sauls wrote:
> Cris wrote:
>> it doesn't work that way: "src\engine\renderer.d(104): cannot implicitly convert expression ((glGetString)(7939u)) of type ubyte* to char*"
>>
>
> Given that its natural type is ubyte* you should be able to do this:
>
> # private import std.string ;
> #
> # char[] toString (ubyte* foo) {
> # return std.string.toString(cast(char*) foo);
> # }
>
> I would think so, anyhow. If it will not allow a direct cast to char*, you can always add a middle state cast to void* first.
>
> -- Chris Nicholson-Sauls
|
Copyright © 1999-2021 by the D Language Foundation