just trying to get some idea about why my cube o death, is not rendering correctly. Without having a picture i would say that the vertices locations are messed up.
It seems that there is a vertice on location 0,0,0, because of how the cube renders. But why i mention that, is i'm curious if nim seq init, could allocate's with 0 if it was used the below code.
type
vert* = array[0 .. 2,GLfloat]
type
face* = array[0 .. 2,GLuint]
type
tex* = array[0 .. 1,GLfloat]
type
obj_data* = object
data_vert* : seq[vert]
data_face* : seq[face]
data_nrml* : seq[vert]
data_tex* : seq[tex]
mtl* : string
grp* : string
use* : string
s*: string
var data : array[1,string] = [readFile(path).string]
var str_seq = splitLines(data[0])
result.data_vert = @[]
result.data_face = @[]
result.data_nrml = @[]
result.data_tex = @[]
as you can see my seq is an array of 3 floats and i'm wondering if when nim has initialized the seq that it puts an extra seq[vert] that would throw my array of data to my vertex buffer object off on ordering of vertices. Like here in this code.
proc input_3fa*[T](a:ptr seq[T], vert_atr:GLint,draw_type:GLenum): GLuint =
glGenBuffers(GLint(1),vid[0].addr)
glBindBuffer(GL_ARRAY_BUFFER.GLenum,vid[0])
size_a = a[].len * 3
if instance < 0:
offset_f += size_a
#echo("offset_f: ", offset_f)
glBufferData(GL_ARRAY_BUFFER.GLenum, GLsizeiptr(size_a) * sizeof(GLfloat), a[0].addr, draw_type)
glEnableVertexAttribArray(vert_atr.GLuint)
glVertexAttribPointer(vert_atr.GLuint,3.GLint,cGL_FLOAT.GLenum,GL_FALSE.GLboolean,GLsizei(0),cast[ptr GLvoid](0))
return vid[0]
So does anyone have any experience with making a render in opengl that could help?
thanks u flyx for your reply i tried your suggestion.
i should probably mention my matrix is only a array of 16 GLfloats too. so here is my matrix code.
type
Mat4* = array[16,GLfloat]
i tried a[].addr and just a for variable where u suggested and i got a blank screen thank u for your help
About the typesafe nim api, I have a project that tries to do something like that, but sadly at the moment my hardware does not work, and I can't continue working on it. I am a poor student. But I recently updated it, so that I can compile it on the new Nim version.
Here is the project.
But the goal is somewhat beyond a typesafe opengl. The goal is more like generate all the code that is error prone to type errors, and be much more productive. It needs much more work though. But for basic usage I would be very happy if someone can give me some feedback, if this project is usable outside of my own computer.