Page 1 of 1

[Solved] How to Import glShaderSource()

Posted: Sat Jun 11, 2016 9:04 pm
by StarBootics
Hello everyone,

The question is very simple, how to import this function :

Code: Select all

glShaderSource(GLuint shader,GLsizei count ,const GLchar **string, const GLint *length);
This what I have try without any success :

Code: Select all

glShaderSource(Shader.l, Count.l, *String, *Length)
glShaderSource(Shader.l, Count.l, String.p-ascii, *Length)
I alway get an "Invalid Memory Access"

Best regards
StarBootics

Re: How to Import glShaderSource()

Posted: Sat Jun 11, 2016 11:04 pm
by DontTalkToMe
Should be

Code: Select all

glShaderSource (shader, count, *stringbuffer, *length)
no need to specify .l, better use the default .i

"Invalid Memory Access" where ? anyway the meaning of that number probably can be clear only to you since you can see what's there or where the address it's coming from and that should be an hint

this is GL 2.0, was imported successfully ? is glShaderSource <> 0 (on windows) ?


if all the above is ok, is the buffer you pass an array of pointers ?

If I remember correctly, it's not a buffer of string data, it's an array of pointers (another reason why it's better to not specify .l)

Re: How to Import glShaderSource()

Posted: Sun Jun 12, 2016 12:41 am
by StarBootics
DontTalkToMe wrote:"Invalid Memory Access" where ?
That's the problem, I don't know ! On the line of code where I call that function
DontTalkToMe wrote:this is GL 2.0, was imported successfully ? is glShaderSource <> 0 (on windows) ?
Actually I'm importing this function on GL 3.3 on Ubunbu 16.04 x64

I will search once again some example source code for a function being use to load the Shader source into a buffer to see how to do it.

Thanks
StarBootics

Re: How to Import glShaderSource()

Posted: Sun Jun 12, 2016 1:20 am
by DontTalkToMe

Re: How to Import glShaderSource()

Posted: Sun Jun 12, 2016 2:45 am
by StarBootics
DontTalkToMe wrote:See if this thread helps
http://www.purebasic.fr/english/viewtop ... 36&t=59709
Thanks for the link but since I'm working with PB 5.50 Beta 1 the solution is in fact very simple

Code: Select all

*VSBuffer = Ascii(VertexShaderSource)
VertexShaderID.l = glCreateShader(#GL_VERTEX_SHADER)
glShaderSource(VertexShaderID, 1, @*VSBuffer, #Null)
I do the same thing with the fragment shader an both compile just fine.

Best regards
StarBootics