Fix tests some more
This commit is contained in:
parent
ee99771afa
commit
cb3c99fe1f
11 changed files with 22 additions and 25 deletions
|
|
@ -5,7 +5,8 @@ import
|
|||
from strutils import
|
||||
formatFloat,
|
||||
TFloatFormat,
|
||||
`%`
|
||||
`%`,
|
||||
ffDecimal
|
||||
|
||||
from unsigned import
|
||||
`shr`,
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ else:
|
|||
glRealType* = cGLfloat
|
||||
|
||||
proc setUniformV4*[T](loc: GLint, vecs: var openarray[TV4[T]]) =
|
||||
glUniform4fv(loc, vecs.len.GLsizei, cast[PGLfloat](vecs[0].addr))
|
||||
glUniform4fv(loc, vecs.len.GLsizei, cast[ptr GLfloat](vecs[0].addr))
|
||||
|
||||
proc setUniformV4*[T](loc: GLint, vec: TV4[T]) =
|
||||
var vecs = [vec]
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ type
|
|||
i* : GLuint
|
||||
size* : GLint
|
||||
stride* : GLsizei
|
||||
offset* : PGLvoid
|
||||
offset* : GLvoid
|
||||
TVertMode* = enum
|
||||
vmTriStrip = GLtriangleStrip,
|
||||
vmTriFan = GLtriangleFan
|
||||
|
|
@ -44,7 +44,7 @@ proc newVertQuad*(min, minRight, maxLeft, max: TV2[TR]): seq[TVert] =
|
|||
proc newVert*(rect: rect.TRect): seq[TVert] =
|
||||
newVertQuad(rect.min, newV2(rect.max.x, rect.min.y), newV2(rect.min.x, rect.max.y), rect.max)
|
||||
|
||||
proc newVertAttrib(i: GLuint, size: GLint, stride: GLsizei, offset: PGLvoid): TVertAttrib =
|
||||
proc newVertAttrib(i: GLuint, size: GLint, stride: GLsizei, offset: GLvoid): TVertAttrib =
|
||||
TVertAttrib(i: i, size: size, stride: stride, offset: offset)
|
||||
|
||||
proc genBuf*[T](vboTarget, objUsage: GLenum, data: var openarray[T]): GLuint =
|
||||
|
|
@ -90,7 +90,7 @@ proc disableVertAttribArrs*() =
|
|||
proc setVertAttribPointers*() =
|
||||
let vertSize {.global.} = TVert.sizeof.GLint
|
||||
?glVertexAttribPointer(0, 2, glRealType, false, vertSize, nil)
|
||||
?glVertexAttribPointer(1, 2, glRealType, false, vertSize, cast[PGLvoid](TR.sizeof * 2))
|
||||
?glVertexAttribPointer(1, 2, glRealType, false, vertSize, cast[GLvoid](TR.sizeof * 2))
|
||||
|
||||
proc updVerts*(o: PPrimitive, start, `end`: int, f: proc(i: int, vert: var TVert)) =
|
||||
assert start <= `end`
|
||||
|
|
@ -105,7 +105,7 @@ proc updVerts*(o: PPrimitive, start, `end`: int, f: proc(i: int, vert: var TVert
|
|||
?glBufferSubData(GLarrayBuffer,
|
||||
byteOffset.GLintptr, # Offset. Is this right?
|
||||
byteLen.GLsizeiptr, # Size.
|
||||
cast[PGLvoid](cast[int](o.verts[0].addr) + byteOffset))
|
||||
cast[GLvoid](cast[int](o.verts[0].addr) + byteOffset))
|
||||
|
||||
proc updAllVerts(o: PPrimitive, f: proc(i: int, vert: var TVert)) =
|
||||
for i in 0 .. <o.verts.len:
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ proc setSrc*(shader: TShader, src: string) =
|
|||
?glShaderSource(shader.id, 1, cast[cstringarray](s.addr), nil)
|
||||
|
||||
proc newShader*(id: GL_handle): TShader =
|
||||
if id != 0 and not (?glIsShader(id)).bool:
|
||||
if id.int != 0 and not (?glIsShader(id)).bool:
|
||||
raise newException(E_GL, "Invalid shader ID: " & $id)
|
||||
|
||||
result.id = id
|
||||
|
|
@ -33,7 +33,7 @@ proc newShader*(id: GL_handle): TShader =
|
|||
proc shaderInfoLog*(o: TShader): string =
|
||||
var log {.global.}: array[0..1024, char]
|
||||
var logLen: GLsizei
|
||||
?glGetShaderInfoLog(o.id, log.len.GLsizei, logLen, cast[PGLchar](log.addr))
|
||||
?glGetShaderInfoLog(o.id.GLuint, log.len.GLsizei, addr logLen, cast[cstring](log.addr))
|
||||
cast[string](log.addr).substr(0, logLen)
|
||||
|
||||
proc compile*(shader: TShader, path="") =
|
||||
|
|
@ -67,7 +67,7 @@ proc attach*(o: TProgram, shader: TShader) =
|
|||
proc infoLog*(o: TProgram): string =
|
||||
var log {.global.}: array[0..1024, char]
|
||||
var logLen: GLsizei
|
||||
?glGetProgramInfoLog(o.id, log.len.GLsizei, logLen, cast[PGLchar](log.addr))
|
||||
?glGetProgramInfoLog(o.id.GLuint, log.len.GLsizei, addr logLen, cast[cstring](log.addr))
|
||||
cast[string](log.addr).substr(0, logLen)
|
||||
|
||||
proc link*(o: TProgram) =
|
||||
|
|
@ -86,11 +86,11 @@ proc validate*(o: TProgram) =
|
|||
|
||||
proc newProgram*(shaders: seq[TShader]): TProgram =
|
||||
result.id = ?glCreateProgram()
|
||||
if result.id == 0:
|
||||
if result.id.int == 0:
|
||||
return
|
||||
|
||||
for shader in shaders:
|
||||
if shader.id == 0:
|
||||
if shader.id.int == 0:
|
||||
return
|
||||
|
||||
?result.attach(shader)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue