MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / R_ParseImageProgram_r

Function R_ParseImageProgram_r

neo/renderer/Image_program.cpp:371–604  ·  view source on GitHub ↗

=================== R_ParseImageProgram_r If pic is NULL, the timestamps will be filled in, but no image will be generated If both pic and timestamps are NULL, it will just advance past it, which can be used to parse an image program from a text stream. =================== */

Source from the content-addressed store, hash-verified

369===================
370*/
371static bool R_ParseImageProgram_r( idLexer &src, byte **pic, int *width, int *height,
372 ID_TIME_T *timestamps, textureDepth_t *depth ) {
373 idToken token;
374 float scale;
375 ID_TIME_T timestamp;
376
377 src.ReadToken( &token );
378 AppendToken( token );
379
380 if ( !token.Icmp( "heightmap" ) ) {
381 MatchAndAppendToken( src, "(" );
382
383 if ( !R_ParseImageProgram_r( src, pic, width, height, timestamps, depth ) ) {
384 return false;
385 }
386
387 MatchAndAppendToken( src, "," );
388
389 src.ReadToken( &token );
390 AppendToken( token );
391 scale = token.GetFloatValue();
392
393 // process it
394 if ( pic ) {
395 R_HeightmapToNormalMap( *pic, *width, *height, scale );
396 if ( depth ) {
397 *depth = TD_BUMP;
398 }
399 }
400
401 MatchAndAppendToken( src, ")" );
402 return true;
403 }
404
405 if ( !token.Icmp( "addnormals" ) ) {
406 byte *pic2 = NULL;
407 int width2, height2;
408
409 MatchAndAppendToken( src, "(" );
410
411 if ( !R_ParseImageProgram_r( src, pic, width, height, timestamps, depth ) ) {
412 return false;
413 }
414
415 MatchAndAppendToken( src, "," );
416
417 if ( !R_ParseImageProgram_r( src, pic ? &pic2 : NULL, &width2, &height2, timestamps, depth ) ) {
418 if ( pic ) {
419 R_StaticFree( *pic );
420 *pic = NULL;
421 }
422 return false;
423 }
424
425 // process it
426 if ( pic ) {
427 R_AddNormalMaps( *pic, *width, *height, pic2, width2, height2 );
428 R_StaticFree( pic2 );

Callers 2

R_LoadImageProgramFunction · 0.85
R_ParsePastImageProgramFunction · 0.85

Calls 15

AppendTokenFunction · 0.85
MatchAndAppendTokenFunction · 0.85
R_HeightmapToNormalMapFunction · 0.85
R_StaticFreeFunction · 0.85
R_AddNormalMapsFunction · 0.85
R_SmoothNormalMapFunction · 0.85
R_ImageAddFunction · 0.85
R_ImageScaleFunction · 0.85
R_InvertAlphaFunction · 0.85
R_InvertColorFunction · 0.85
R_LoadImageFunction · 0.85
GetFloatValueMethod · 0.80

Tested by

no test coverage detected