Changeset 41 for trunk/luigi/gldraw.d
- Timestamp:
- 01/25/07 20:13:21 (2 years ago)
- Files:
-
- trunk/luigi/gldraw.d (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/luigi/gldraw.d
r33 r41 32 32 import luigi.base; 33 33 import std.math : PI,sin,cos; 34 35 class GLException : Exception 36 { 37 this(char[] msg) { super(msg); } 38 } 39 34 40 35 41 void translate(float x, float y) … … 365 371 } 366 372 367 void checkGLErrors(char[] file = null, int line = 0)373 char[] getGLErrors(char[] file = null, int line = -1) 368 374 { 369 375 GLenum err; 376 char[] errstr = null; 377 int count = 0; 370 378 while ( (err=glGetError()) != GL_NO_ERROR) 371 379 { 372 char[] errstr; 373 if (file) errstr = std.string.format("OpenGL error: %s(%s): ", file, line); 380 if (!errstr) errstr = "OpenGL error: "; 381 else errstr ~= std.string.format("\nOpenGL error(%d) : ", ++count); 382 if (file) errstr ~= std.string.format("%s(%s): ", file, line); 383 else if (line >= 0) errstr ~= std.string.format("(%s): ", line); 374 384 switch(err) { 375 385 case GL_INVALID_ENUM: … … 416 426 errstr ~= std.string.format("Unknown error code: %s", err); 417 427 } 418 writefln(errstr); 428 } 429 return errstr; 430 } 431 432 void checkGLErrors(char[] file = null, int line = -1) 433 { 434 char[] ret = getGLErrors(file,line); 435 if (ret) { 436 writefln(ret); 437 } 438 } 439 void throwGLErrors(char[] file = null, int line = -1) 440 { 441 char[] ret = getGLErrors(file,line); 442 if (ret) { 443 throw new GLException(ret); 419 444 } 420 445 }
