FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problems loading shader...

 
Post new topic   Reply to topic     Forum Index -> Derelict
View previous topic :: View next topic  
Author Message
scooterman



Joined: 06 Feb 2007
Posts: 10

PostPosted: Tue Sep 18, 2007 7:41 pm    Post subject: Problems loading shader... Reply with quote

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
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Tue Sep 18, 2007 7:51 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
scooterman



Joined: 06 Feb 2007
Posts: 10

PostPosted: Wed Sep 19, 2007 8:21 am    Post subject: Reply with quote

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
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Wed Sep 19, 2007 6:09 pm    Post subject: Reply with quote

Those are shader compilation errors. I hope you are getting those at runtime Smile 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
View user's profile Send private message Send e-mail
scooterman



Joined: 06 Feb 2007
Posts: 10

PostPosted: Thu Sep 20, 2007 4:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Thu Sep 20, 2007 8:19 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
vektorboson



Joined: 14 Sep 2006
Posts: 44

PostPosted: Fri Sep 21, 2007 2:54 am    Post subject: Reply with quote

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
View user's profile Send private message
scooterman



Joined: 06 Feb 2007
Posts: 10

PostPosted: Sat Sep 22, 2007 8:53 am    Post subject: Reply with quote

thanks vektorbosson, that worked well =)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Derelict All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group