[Solved] How to Import glShaderSource()

Everything related to 3D programming
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

[Solved] How to Import glShaderSource()

Post 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
Last edited by StarBootics on Sun Jun 12, 2016 3:14 am, edited 1 time in total.
The Stone Age did not end due to a shortage of stones !
DontTalkToMe
Enthusiast
Enthusiast
Posts: 334
Joined: Mon Feb 04, 2013 5:28 pm

Re: How to Import glShaderSource()

Post 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)
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: How to Import glShaderSource()

Post 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
The Stone Age did not end due to a shortage of stones !
DontTalkToMe
Enthusiast
Enthusiast
Posts: 334
Joined: Mon Feb 04, 2013 5:28 pm

Re: How to Import glShaderSource()

Post by DontTalkToMe »

User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: How to Import glShaderSource()

Post 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
The Stone Age did not end due to a shortage of stones !
Post Reply