Skip to content

Commit

Permalink
GLSL: Improvements (#2321)
Browse files Browse the repository at this point in the history
This improves GLSL by extending C instead of C-like.
  • Loading branch information
RunDevelopment committed Apr 29, 2020
1 parent 87a5c7a commit 33e4995
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 78 deletions.
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion components.json
Expand Up @@ -379,7 +379,7 @@
},
"glsl": {
"title": "GLSL",
"require": "clike",
"require": "c",
"owner": "Golmote"
},
"gml": {
Expand Down
15 changes: 1 addition & 14 deletions components/prism-glsl.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/prism-glsl.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 17 additions & 17 deletions examples/prism-glsl.html
Expand Up @@ -15,18 +15,18 @@ <h2>Vertex shader example</h2>
vec3 specularColor = vec3(1.0,1.0,1.0);

void main(void) {
// compute position
gl_Position = _mvProj * vec4(vertex, 1.0);
localPos = vertex;
// compute light info
vec3 n = normalize(_norm * normal);
vec3 diffuse;
float specular;
float glowingSpecular = 50.0;
getDirectionalLight(n, _dLight, glowingSpecular, diffuse, specular);
vColor = max(diffuse,_ambient.xyz)*materialColor+specular*specularColor+_ambient;
// compute position
gl_Position = _mvProj * vec4(vertex, 1.0);

localPos = vertex;

// compute light info
vec3 n = normalize(_norm * normal);
vec3 diffuse;
float specular;
float glowingSpecular = 50.0;
getDirectionalLight(n, _dLight, glowingSpecular, diffuse, specular);
vColor = max(diffuse,_ambient.xyz)*materialColor+specular*specularColor+_ambient;
}</code></pre>

<h2>Fragment shader example</h2>
Expand All @@ -42,17 +42,17 @@ <h2>Fragment shader example</h2>
varying vec3 localPos;
void main()
{
vec3 color;
vec3 color;
vec3 position, useBrick;


position = localPos / BrickSize.xyz;

if (fract(position.y * 0.5) > 0.5){
position.x += 0.5;
position.z += 0.5;
position.z += 0.5;
}

position = fract(position);

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

gl_FragColor = vec4(color, 1.0);
}
</code></pre>
</code></pre>
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.js
Expand Up @@ -42,7 +42,7 @@
"firestore-security-rules": "clike",
"flow": "javascript",
"ftl": "markup-templating",
"glsl": "clike",
"glsl": "c",
"gml": "clike",
"go": "clike",
"groovy": "clike",
Expand Down
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions tests/languages/glsl/keyword_feature.test
Expand Up @@ -89,15 +89,15 @@ uimage1DArray uimage2DArray
imageCubeArray iimageCubeArray uimageCubeArray
image2DMS iimage2DMS uimage2DMS
image2DMSArray iimage2DMSArray uimage2DMSArray
struct
struct;
common
partition
active
asm
class;
union
enum
typedef
enum;
typedef;
template
this
resource
Expand Down Expand Up @@ -220,15 +220,15 @@ using
["keyword", "imageCubeArray"], ["keyword", "iimageCubeArray"], ["keyword", "uimageCubeArray"],
["keyword", "image2DMS"], ["keyword", "iimage2DMS"], ["keyword", "uimage2DMS"],
["keyword", "image2DMSArray"], ["keyword", "iimage2DMSArray"], ["keyword", "uimage2DMSArray"],
["keyword", "struct"],
["keyword", "struct"], ["punctuation", ";"],
["keyword", "common"],
["keyword", "partition"],
["keyword", "active"],
["keyword", "asm"],
["keyword", "class"], ["punctuation", ";"],
["keyword", "union"],
["keyword", "enum"],
["keyword", "typedef"],
["keyword", "enum"], ["punctuation", ";"],
["keyword", "typedef"], ["punctuation", ";"],
["keyword", "template"],
["keyword", "this"],
["keyword", "resource"],
Expand Down Expand Up @@ -260,4 +260,4 @@ using

----------------------------------------------------

Checks for keywords.
Checks for keywords.
74 changes: 74 additions & 0 deletions tests/languages/glsl/macro_feature.test
@@ -0,0 +1,74 @@
#define
#undef
#if
#ifdef
#ifndef
#else
#elif
#endif
#error
#pragma
#extension
#version
#line

----------------------------------------------------

[
["macro", [
"#",
["directive", "define"]
]],
["macro", [
"#",
["directive", "undef"]
]],
["macro", [
"#",
["directive", "if"]
]],
["macro", [
"#",
["directive", "ifdef"]
]],
["macro", [
"#",
["directive", "ifndef"]
]],
["macro", [
"#",
["directive", "else"]
]],
["macro", [
"#",
["directive", "elif"]
]],
["macro", [
"#",
["directive", "endif"]
]],
["macro", [
"#",
["directive", "error"]
]],
["macro", [
"#",
["directive", "pragma"]
]],
["macro", [
"#",
["directive", "extension"]
]],
["macro", [
"#",
["directive", "version"]
]],
["macro", [
"#",
["directive", "line"]
]]
]

----------------------------------------------------

Checks for preprocessor instructions.
35 changes: 0 additions & 35 deletions tests/languages/glsl/preprocessor_feature.test

This file was deleted.

0 comments on commit 33e4995

Please sign in to comment.