Skip to content

Commit 33e4995

Browse files
GLSL: Improvements (#2321)
This improves GLSL by extending C instead of C-like.
1 parent 87a5c7a commit 33e4995

10 files changed

+104
-78
lines changed

components.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@
379379
},
380380
"glsl": {
381381
"title": "GLSL",
382-
"require": "clike",
382+
"require": "c",
383383
"owner": "Golmote"
384384
},
385385
"gml": {

components/prism-glsl.js

Lines changed: 1 addition & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/prism-glsl.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prism-glsl.html

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ <h2>Vertex shader example</h2>
1515
vec3 specularColor = vec3(1.0,1.0,1.0);
1616

1717
void main(void) {
18-
// compute position
19-
gl_Position = _mvProj * vec4(vertex, 1.0);
20-
21-
localPos = vertex;
22-
23-
// compute light info
24-
vec3 n = normalize(_norm * normal);
25-
vec3 diffuse;
26-
float specular;
27-
float glowingSpecular = 50.0;
28-
getDirectionalLight(n, _dLight, glowingSpecular, diffuse, specular);
29-
vColor = max(diffuse,_ambient.xyz)*materialColor+specular*specularColor+_ambient;
18+
// compute position
19+
gl_Position = _mvProj * vec4(vertex, 1.0);
20+
21+
localPos = vertex;
22+
23+
// compute light info
24+
vec3 n = normalize(_norm * normal);
25+
vec3 diffuse;
26+
float specular;
27+
float glowingSpecular = 50.0;
28+
getDirectionalLight(n, _dLight, glowingSpecular, diffuse, specular);
29+
vColor = max(diffuse,_ambient.xyz)*materialColor+specular*specularColor+_ambient;
3030
}</code></pre>
3131

3232
<h2>Fragment shader example</h2>
@@ -42,17 +42,17 @@ <h2>Fragment shader example</h2>
4242
varying vec3 localPos;
4343
void main()
4444
{
45-
vec3 color;
45+
vec3 color;
4646
vec3 position, useBrick;
47-
47+
4848

4949
position = localPos / BrickSize.xyz;
5050

5151
if (fract(position.y * 0.5) > 0.5){
5252
position.x += 0.5;
53-
position.z += 0.5;
53+
position.z += 0.5;
5454
}
55-
55+
5656
position = fract(position);
5757

5858
useBrick = step(position, BrickPct.xyz);
@@ -62,4 +62,4 @@ <h2>Fragment shader example</h2>
6262

6363
gl_FragColor = vec4(color, 1.0);
6464
}
65-
</code></pre>
65+
</code></pre>

plugins/autoloader/prism-autoloader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"firestore-security-rules": "clike",
4343
"flow": "javascript",
4444
"ftl": "markup-templating",
45-
"glsl": "clike",
45+
"glsl": "c",
4646
"gml": "clike",
4747
"go": "clike",
4848
"groovy": "clike",

plugins/autoloader/prism-autoloader.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/languages/glsl/keyword_feature.test

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ uimage1DArray uimage2DArray
8989
imageCubeArray iimageCubeArray uimageCubeArray
9090
image2DMS iimage2DMS uimage2DMS
9191
image2DMSArray iimage2DMSArray uimage2DMSArray
92-
struct
92+
struct;
9393
common
9494
partition
9595
active
9696
asm
9797
class;
9898
union
99-
enum
100-
typedef
99+
enum;
100+
typedef;
101101
template
102102
this
103103
resource
@@ -220,15 +220,15 @@ using
220220
["keyword", "imageCubeArray"], ["keyword", "iimageCubeArray"], ["keyword", "uimageCubeArray"],
221221
["keyword", "image2DMS"], ["keyword", "iimage2DMS"], ["keyword", "uimage2DMS"],
222222
["keyword", "image2DMSArray"], ["keyword", "iimage2DMSArray"], ["keyword", "uimage2DMSArray"],
223-
["keyword", "struct"],
223+
["keyword", "struct"], ["punctuation", ";"],
224224
["keyword", "common"],
225225
["keyword", "partition"],
226226
["keyword", "active"],
227227
["keyword", "asm"],
228228
["keyword", "class"], ["punctuation", ";"],
229229
["keyword", "union"],
230-
["keyword", "enum"],
231-
["keyword", "typedef"],
230+
["keyword", "enum"], ["punctuation", ";"],
231+
["keyword", "typedef"], ["punctuation", ";"],
232232
["keyword", "template"],
233233
["keyword", "this"],
234234
["keyword", "resource"],
@@ -260,4 +260,4 @@ using
260260

261261
----------------------------------------------------
262262

263-
Checks for keywords.
263+
Checks for keywords.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#define
2+
#undef
3+
#if
4+
#ifdef
5+
#ifndef
6+
#else
7+
#elif
8+
#endif
9+
#error
10+
#pragma
11+
#extension
12+
#version
13+
#line
14+
15+
----------------------------------------------------
16+
17+
[
18+
["macro", [
19+
"#",
20+
["directive", "define"]
21+
]],
22+
["macro", [
23+
"#",
24+
["directive", "undef"]
25+
]],
26+
["macro", [
27+
"#",
28+
["directive", "if"]
29+
]],
30+
["macro", [
31+
"#",
32+
["directive", "ifdef"]
33+
]],
34+
["macro", [
35+
"#",
36+
["directive", "ifndef"]
37+
]],
38+
["macro", [
39+
"#",
40+
["directive", "else"]
41+
]],
42+
["macro", [
43+
"#",
44+
["directive", "elif"]
45+
]],
46+
["macro", [
47+
"#",
48+
["directive", "endif"]
49+
]],
50+
["macro", [
51+
"#",
52+
["directive", "error"]
53+
]],
54+
["macro", [
55+
"#",
56+
["directive", "pragma"]
57+
]],
58+
["macro", [
59+
"#",
60+
["directive", "extension"]
61+
]],
62+
["macro", [
63+
"#",
64+
["directive", "version"]
65+
]],
66+
["macro", [
67+
"#",
68+
["directive", "line"]
69+
]]
70+
]
71+
72+
----------------------------------------------------
73+
74+
Checks for preprocessor instructions.

tests/languages/glsl/preprocessor_feature.test

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)