commit
edc45726b7
11 changed files with 22 additions and 25 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
ouput: '''foo
|
output: '''foo
|
||||||
true'''
|
true'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
line: "13"
|
line: "13"
|
||||||
errormsg: "for a 'var' type a variable needs to be passed"
|
errormsg: "type mismatch: got (int literal(8), int literal(5), int, int)"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc divmod(a, b: int, res, remainder: var int) =
|
proc divmod(a, b: int, res, remainder: var int) =
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,8 @@ import
|
||||||
from strutils import
|
from strutils import
|
||||||
formatFloat,
|
formatFloat,
|
||||||
TFloatFormat,
|
TFloatFormat,
|
||||||
`%`
|
`%`,
|
||||||
|
ffDecimal
|
||||||
|
|
||||||
from unsigned import
|
from unsigned import
|
||||||
`shr`,
|
`shr`,
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ else:
|
||||||
glRealType* = cGLfloat
|
glRealType* = cGLfloat
|
||||||
|
|
||||||
proc setUniformV4*[T](loc: GLint, vecs: var openarray[TV4[T]]) =
|
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]) =
|
proc setUniformV4*[T](loc: GLint, vec: TV4[T]) =
|
||||||
var vecs = [vec]
|
var vecs = [vec]
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ type
|
||||||
i* : GLuint
|
i* : GLuint
|
||||||
size* : GLint
|
size* : GLint
|
||||||
stride* : GLsizei
|
stride* : GLsizei
|
||||||
offset* : PGLvoid
|
offset* : GLvoid
|
||||||
TVertMode* = enum
|
TVertMode* = enum
|
||||||
vmTriStrip = GLtriangleStrip,
|
vmTriStrip = GLtriangleStrip,
|
||||||
vmTriFan = GLtriangleFan
|
vmTriFan = GLtriangleFan
|
||||||
|
|
@ -44,7 +44,7 @@ proc newVertQuad*(min, minRight, maxLeft, max: TV2[TR]): seq[TVert] =
|
||||||
proc newVert*(rect: rect.TRect): 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)
|
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)
|
TVertAttrib(i: i, size: size, stride: stride, offset: offset)
|
||||||
|
|
||||||
proc genBuf*[T](vboTarget, objUsage: GLenum, data: var openarray[T]): GLuint =
|
proc genBuf*[T](vboTarget, objUsage: GLenum, data: var openarray[T]): GLuint =
|
||||||
|
|
@ -90,7 +90,7 @@ proc disableVertAttribArrs*() =
|
||||||
proc setVertAttribPointers*() =
|
proc setVertAttribPointers*() =
|
||||||
let vertSize {.global.} = TVert.sizeof.GLint
|
let vertSize {.global.} = TVert.sizeof.GLint
|
||||||
?glVertexAttribPointer(0, 2, glRealType, false, vertSize, nil)
|
?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)) =
|
proc updVerts*(o: PPrimitive, start, `end`: int, f: proc(i: int, vert: var TVert)) =
|
||||||
assert start <= `end`
|
assert start <= `end`
|
||||||
|
|
@ -105,7 +105,7 @@ proc updVerts*(o: PPrimitive, start, `end`: int, f: proc(i: int, vert: var TVert
|
||||||
?glBufferSubData(GLarrayBuffer,
|
?glBufferSubData(GLarrayBuffer,
|
||||||
byteOffset.GLintptr, # Offset. Is this right?
|
byteOffset.GLintptr, # Offset. Is this right?
|
||||||
byteLen.GLsizeiptr, # Size.
|
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)) =
|
proc updAllVerts(o: PPrimitive, f: proc(i: int, vert: var TVert)) =
|
||||||
for i in 0 .. <o.verts.len:
|
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)
|
?glShaderSource(shader.id, 1, cast[cstringarray](s.addr), nil)
|
||||||
|
|
||||||
proc newShader*(id: GL_handle): TShader =
|
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)
|
raise newException(E_GL, "Invalid shader ID: " & $id)
|
||||||
|
|
||||||
result.id = id
|
result.id = id
|
||||||
|
|
@ -33,7 +33,7 @@ proc newShader*(id: GL_handle): TShader =
|
||||||
proc shaderInfoLog*(o: TShader): string =
|
proc shaderInfoLog*(o: TShader): string =
|
||||||
var log {.global.}: array[0..1024, char]
|
var log {.global.}: array[0..1024, char]
|
||||||
var logLen: GLsizei
|
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)
|
cast[string](log.addr).substr(0, logLen)
|
||||||
|
|
||||||
proc compile*(shader: TShader, path="") =
|
proc compile*(shader: TShader, path="") =
|
||||||
|
|
@ -67,7 +67,7 @@ proc attach*(o: TProgram, shader: TShader) =
|
||||||
proc infoLog*(o: TProgram): string =
|
proc infoLog*(o: TProgram): string =
|
||||||
var log {.global.}: array[0..1024, char]
|
var log {.global.}: array[0..1024, char]
|
||||||
var logLen: GLsizei
|
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)
|
cast[string](log.addr).substr(0, logLen)
|
||||||
|
|
||||||
proc link*(o: TProgram) =
|
proc link*(o: TProgram) =
|
||||||
|
|
@ -86,11 +86,11 @@ proc validate*(o: TProgram) =
|
||||||
|
|
||||||
proc newProgram*(shaders: seq[TShader]): TProgram =
|
proc newProgram*(shaders: seq[TShader]): TProgram =
|
||||||
result.id = ?glCreateProgram()
|
result.id = ?glCreateProgram()
|
||||||
if result.id == 0:
|
if result.id.int == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
for shader in shaders:
|
for shader in shaders:
|
||||||
if shader.id == 0:
|
if shader.id.int == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
?result.attach(shader)
|
?result.attach(shader)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
file: "tinc.nim"
|
file: "tinc.nim"
|
||||||
line: 8
|
line: 8
|
||||||
errormsg: "for a \'var\' type a variable needs to be passed"
|
errormsg: "type mismatch: got (int)"
|
||||||
"""
|
"""
|
||||||
var x = 0
|
var x = 0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
file: "tinout.nim"
|
file: "tinout.nim"
|
||||||
line: 12
|
line: 12
|
||||||
errormsg: "for a \'var\' type a variable needs to be passed"
|
errormsg: "type mismatch: got (int literal(3))"
|
||||||
"""
|
"""
|
||||||
# Test in out checking for parameters
|
# Test in out checking for parameters
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
file: "tadrdisc.nim"
|
file: "tadrdisc.nim"
|
||||||
line: 20
|
line: 20
|
||||||
errormsg: "for a \'var\' type a variable needs to be passed"
|
errormsg: "type mismatch: got (TKind)"
|
||||||
"""
|
"""
|
||||||
# Test that the address of a dicriminants cannot be taken
|
# Test that the address of a dicriminants cannot be taken
|
||||||
|
|
||||||
|
|
@ -12,12 +12,9 @@ type
|
||||||
of ka: x, y: int
|
of ka: x, y: int
|
||||||
of kb: a, b: string
|
of kb: a, b: string
|
||||||
of kc: c, d: float
|
of kc: c, d: float
|
||||||
|
|
||||||
proc setKind(k: var TKind) =
|
proc setKind(k: var TKind) =
|
||||||
k = kc
|
k = kc
|
||||||
|
|
||||||
var a: TA
|
var a: TA
|
||||||
setKind(a.k) #ERROR_MSG for a 'var' type a variable needs to be passed
|
setKind(a.k)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ proc manyLoc(r: var TResults, cat: Category, options: string) =
|
||||||
for kind, dir in os.walkDir("tests/manyloc"):
|
for kind, dir in os.walkDir("tests/manyloc"):
|
||||||
if kind == pcDir:
|
if kind == pcDir:
|
||||||
let mainfile = findMainFile(dir)
|
let mainfile = findMainFile(dir)
|
||||||
if mainfile != ".nim":
|
if mainfile != "":
|
||||||
testNoSpec r, makeTest(mainfile, options, cat)
|
testNoSpec r, makeTest(mainfile, options, cat)
|
||||||
|
|
||||||
proc compileExample(r: var TResults, pattern, options: string, cat: Category) =
|
proc compileExample(r: var TResults, pattern, options: string, cat: Category) =
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,6 @@ proc codegenCheck(test: TTest, check: string, given: var TSpec) =
|
||||||
try:
|
try:
|
||||||
let (path, name, ext2) = test.name.splitFile
|
let (path, name, ext2) = test.name.splitFile
|
||||||
let genFile = generatedFile(path, name, test.target)
|
let genFile = generatedFile(path, name, test.target)
|
||||||
echo genFile
|
|
||||||
let contents = readFile(genFile).string
|
let contents = readFile(genFile).string
|
||||||
if check[0] == '\\':
|
if check[0] == '\\':
|
||||||
# little hack to get 'match' support:
|
# little hack to get 'match' support:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue