View previous topic :: View next topic |
Author |
Message |
scooterman
Joined: 06 Feb 2007 Posts: 10
|
Posted: Tue Sep 18, 2007 7:41 pm Post subject: Problems loading shader... |
|
|
So, I've been trying to load a simple shader onto my GL app. On the specs, the function I should call after creating the shader object is glShaderSource.
It receives a char ** as the third parameter, that is shader source code.
I'm trying to create a char[][] and then cast it to char **, but this is generating a segfault. My strings are null-terminated and I've loaded all extensions.
Any clue?
Thanks,
Victor |
|
Back to top |
|
|
aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Tue Sep 18, 2007 7:51 pm Post subject: |
|
|
Rather than casting, try something like this:
Code: |
// phobos
import std.string;
char *str = toStringz(shader);
// in tango parlance
import tango.stdc.stringz;
char *str = toUtf8z(shader)
char **arg = &str;
// or, if you're absolutely sure your strings are null-terminated:
char **arg = &(shader.ptr);
|
Also, are you checking to make sure the extension loaded successfully? The extension loaders throw no exceptions. _________________ The One With D | The One With Aldacron | D Bits |
|
Back to top |
|
|
scooterman
Joined: 06 Feb 2007 Posts: 10
|
Posted: Wed Sep 19, 2007 8:21 am Post subject: |
|
|
Thanks, that worked, but now I'm having problems compiling the code. I'm receiving these errors:
(1) : error C0000: syntax error, unexpected $undefined at token "<undefined>"
(1) : error C0501: type name expected at token "<undefined>"
(1) : warning C7022: unrecognized profile specifier "L"
Very strange... |
|
Back to top |
|
|
aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Wed Sep 19, 2007 6:09 pm Post subject: |
|
|
Those are shader compilation errors. I hope you are getting those at runtime If you are getting them when you compile the app, that is strange!
At any rate, you'll have to do some Googling for help on those. _________________ The One With D | The One With Aldacron | D Bits |
|
Back to top |
|
|
scooterman
Joined: 06 Feb 2007 Posts: 10
|
Posted: Thu Sep 20, 2007 4:28 pm Post subject: |
|
|
Yeah, it is at runtime =D
And I've googled around and someone said that is because of garbage being read when loading the source, and that I should fill with zeros the array before copy the file, to prevent this error. But no luck here. So, I thought you could have stumbled upon this error before.
=\
Well, maybe a bit more googlin', then.
Thanks! |
|
Back to top |
|
|
aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Thu Sep 20, 2007 8:19 pm Post subject: |
|
|
scooterman wrote: | So, I thought you could have stumbled upon this error before. |
I've yet to do any shader programming other than working my way through the Orange Book. You might try the message board at opengl.org. One of the forums there is specifically for GLSL discussion. _________________ The One With D | The One With Aldacron | D Bits |
|
Back to top |
|
|
vektorboson
Joined: 14 Sep 2006 Posts: 44
|
Posted: Fri Sep 21, 2007 2:54 am Post subject: |
|
|
This is what I am using:
Code: |
char* ptr = source.ptr;
int len = source.length;
glShaderSource(vertexShaderObject,1,&ptr, &len);
glCompileShader(vertexShaderObject);
|
where source is: char[] source |
|
Back to top |
|
|
scooterman
Joined: 06 Feb 2007 Posts: 10
|
Posted: Sat Sep 22, 2007 8:53 am Post subject: |
|
|
thanks vektorbosson, that worked well =) |
|
Back to top |
|
|
|