@@ -305,53 +305,26 @@ sub generate_glew_xs {
305
305
$decl .= " $xs_args ;\n " ;
306
306
}
307
307
308
- my $error_check = $name eq " glGetError" ? " " : <<"XS" ;
309
- if ( _auto_check_errors ) {
310
- int err = GL_NO_ERROR;
311
- int error_count = 0;
312
- while ( ( err = glGetError() ) != GL_NO_ERROR ) {
313
- /* warn( "OpenGL error: %d ", err ); */
314
- warn( "$name : OpenGL error: %d %s ", err, gl_error_string(err) );
315
- error_count++;
316
- }
317
- if( error_count )
318
- croak( "$name : %d OpenGL errors encountered.", error_count );
319
- }
320
- XS
321
- chomp $error_check ; # trailing newline needs to be done conditionally
308
+ my $error_check = $name eq " glGetError" ? " " : " OGLM_CHECK_ERR($name )" ;
322
309
323
310
my $res = $decl . <<XS ;
324
311
CODE:
325
- if ( ! _done_glewInit ) {
326
- GLenum err;
327
- glewExperimental = GL_TRUE;
328
- err = glewInit();
329
- if (GLEW_OK != err)
330
- croak("Error: %s ", glewGetErrorString(err));
331
- _done_glewInit++;
332
- }
333
- $error_check
312
+ OGLM_GLEWINIT@{[$error_check && "\n $error_check "]}
334
313
XS
335
314
336
315
if ( $item -> {glewtype } eq ' fun' and $glewImpl ) {
337
- $res .= <<XS ;
338
- if ( ! $glewImpl ) {
339
- croak("$name not available on this machine");
340
- };
341
- XS
316
+ $res .= " OGLM_AVAIL_CHECK($glewImpl , $name )\n " ;
342
317
}
343
318
344
- $error_check = " \n $error_check " if $error_check ; # otherwise glGetError gets a stray newline
345
-
346
319
if ( $no_return_value ) {
347
320
$res .= <<XS ;
348
- $name ($args );$error_check
321
+ $name ($args );@{[ $error_check && " \n $error_check "]}
349
322
XS
350
323
}
351
324
else {
352
325
my $arg_list = $item -> {glewtype } eq ' var' ? " " : " ($args )" ;
353
326
$res .= <<XS ;
354
- RETVAL = $name$arg_list ;$error_check
327
+ RETVAL = $name$arg_list ;@{[ $error_check && " \n $error_check "]}
355
328
OUTPUT:
356
329
RETVAL
357
330
XS
0 commit comments