1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
From fc642f1752caa156d41f5245e5f05b583bb8b886 Mon Sep 17 00:00:00 2001
From: Guillaume Seguin <guillaume@segu.in>
Date: Thu, 16 Aug 2007 02:14:17 +0200
Subject: [PATCH] * Add fragment program pretty printer
---
src/fragment.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/src/fragment.c b/src/fragment.c
index a1c9e6e..04ae571 100644
--- a/src/fragment.c
+++ b/src/fragment.c
@@ -154,6 +154,53 @@ static CompFunction initialLoadFunction = {
COMP_FUNCTION_MASK
};
+/*
+ * Print nicely formatted fragment program
+ */
+static void
+printPrettyFragment (char *source)
+{
+ char *result, *current;
+ int feeds = 1, length;
+
+ current = source;
+ while (*current != '\0')
+ {
+ if (strstr (current, ";") == current) break;
+ feeds++;
+ current = strstr (current, ";");
+ if (!current) break;
+ else current++;
+ }
+
+ result = malloc (sizeof (char) * (strlen (source) + feeds + 1));
+ if (!result)
+ result = source;
+ else
+ {
+ current = source;
+ strcpy (result, "!!ARBfp1.0\n");
+ current += 10;
+ while (*current != '\0')
+ {
+ if (strstr (current, ";"))
+ length = strstr (current, ";") + 1 - current;
+ else
+ length = strlen (current);
+ strncat (result, current, length);
+ strcat (result, "\n");
+ current = strstr (current, ";");
+ if (!current) break;
+ else current++;
+ }
+ result[strlen (source) + feeds] = '\0';
+ }
+ compLogMessage (NULL, "core", CompLogLevelInfo,
+ "Using fragment program :");
+ printf ("%s", result);
+ free (result);
+}
+
static CompFunction *
findFragmentFunction (CompScreen *s,
int id)
@@ -630,6 +677,8 @@ buildFragmentProgram (CompScreen *s,
glGetError ();
+ printPrettyFragment (info.data);
+
(*s->genPrograms) (1, &program->name);
(*s->bindProgram) (GL_FRAGMENT_PROGRAM_ARB, program->name);
(*s->programString) (GL_FRAGMENT_PROGRAM_ARB,
--
1.5.2.4
|