Line | |
---|
1 | #version 120 |
---|
2 | #extension GL_EXT_geometry_shader4 : enable |
---|
3 | |
---|
4 | uniform vec4 origColor; |
---|
5 | uniform vec4 cloneColor; |
---|
6 | |
---|
7 | void main(void) |
---|
8 | { |
---|
9 | |
---|
10 | //increment variable |
---|
11 | int i; |
---|
12 | |
---|
13 | ///////////////////////////////////////////////////////////// |
---|
14 | //This example has two parts |
---|
15 | // step a) draw the primitive pushed down the pipeline |
---|
16 | // there are gl_Vertices # of vertices |
---|
17 | // put the vertex value into gl_Position |
---|
18 | // use EmitVertex => 'create' a new vertex |
---|
19 | // use EndPrimitive to signal that you are done creating a primitive! |
---|
20 | // step b) create a new piece of geometry (I.E. WHY WE ARE USING A GEOMETRY SHADER!) |
---|
21 | // I just do the same loop, but swizzle the x and y values |
---|
22 | // result => the line we want to draw, and the same line, but along the other axis |
---|
23 | |
---|
24 | //Pass-thru! |
---|
25 | for(i=0; i< gl_VerticesIn; i++){ |
---|
26 | gl_Position = gl_PositionIn[i]; |
---|
27 | gl_FrontColor = origColor; |
---|
28 | EmitVertex(); |
---|
29 | } |
---|
30 | EndPrimitive(); |
---|
31 | //New piece of geometry! We just swizzle the x and y terms |
---|
32 | for(i=0; i< gl_VerticesIn; i++){ |
---|
33 | gl_Position = gl_PositionIn[i]; |
---|
34 | gl_Position.xy = gl_Position.yx; |
---|
35 | gl_FrontColor = cloneColor; |
---|
36 | EmitVertex(); |
---|
37 | } |
---|
38 | EndPrimitive(); |
---|
39 | |
---|
40 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.