From 2319321b04a5e2aa8d21ce50a6f5d5f33b83f7d3 Mon Sep 17 00:00:00 2001 From: Felix Krause Date: Fri, 11 Jul 2014 22:00:12 +0200 Subject: [PATCH] =?UTF-8?q?Disable=20error=20checking=20inside=20glBegin?= =?UTF-8?q?=20=E2=80=A6=20glEnd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/opengl.nim | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/opengl.nim b/src/opengl.nim index 00f7c1e..b4c26e5 100644 --- a/src/opengl.nim +++ b/src/opengl.nim @@ -306,7 +306,9 @@ const ## and ``enableAutoGlErrorCheck(bool)`` will have no effect when ## ``noAutoGlErrorCheck`` is defined. -var gAutoGlErrorCheck = true +var + gAutoGlErrorCheck = true + gInsideBeginEnd* = false # do not change manually. proc enableAutoGlErrorCheck*(yes: bool) = ## This determines (at run time) whether an exception should be raised if an @@ -327,7 +329,8 @@ macro wrapErrorChecking(f: stmt): stmt = ident"importc" , newLit($child.name)) ).add(ident"ogl") - glProc.name = ident($glProc.name & "Impl") + let rawGlProName = $glProc.name + glProc.name = ident(rawGlProName & "Impl") var body = newStmtList glProc returnsSomething = child.params[0].kind != nnkEmpty @@ -341,9 +344,14 @@ macro wrapErrorChecking(f: stmt): stmt = else: glCall + if rawGlProName == "glBegin": + body.add newAssignment(ident"gInsideBeginEnd", ident"true") + if rawGlProName == "glEnd": + body.add newAssignment(ident"gInsideBeginEnd", ident"false") + template errCheck: stmt = when not (NoAutoGlErrorCheck): - if gAutoGlErrorCheck: + if gAutoGlErrorCheck and not gInsideBeginEnd: checkGlError() body.add getAst(errCheck())