Can anybody point me to a example of making and using a cstring array. I'm having trouble making a shader cstring work with the opengl wrapper. and can't find an example of making a cstring array like the compiler wants.
anyway thank u for your replies
You need to make an array of strings, then allocate a cstring array from that.
proc logShader(shader: GLuint) =
var length: GLint = 0
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, length.addr)
var log: string = newString(length.int)
glGetShaderInfoLog(shader, length, nil, log)
echo "Log: ", log
proc loadShader(typ: GLenum, file: string): GLuint =
if typ.int != GL_VERTEX_SHADER and typ.int != GL_FRAGMENT_SHADER:
return 0
var
fromfile: array[1, string] = [readFile(file).string]
source = allocCStringArray(fromfile)
compiled: GLint = 0
result = glCreateShader(typ)
glShaderSource(result, 1, source, nil)
glCompileShader(result)
glGetShaderiv(result, GL_COMPILE_STATUS, compiled.addr)
if compiled == 0:
logShader(result)
deallocCStringArray(source)
Thank u apollo for that information,
i was able to get beyond the glShaderSource proc;
but now i'm having trouble with glGetShaderiv, it seems the compiler thinks GL_COMPILE_STATUS is an int literal?
i'll dig around in the doc for a solution, but help would be appreciated.
GL_COMPILE_STATUS.GLenum
Thank u again apollo.
Seems i also keep running into type problems.
Nim seems to be very strict about its types >;)
It actually suprises me abit about that. but i like nim and will keep at it. But i wonder if we could ever get a user forum wiki for for all sorts of subjects like this cause i havent found anything on certain, subject topics like reading files and such like i did from your post.