| 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 | } |
|---|
| 41 | #version 120 |
|---|
| 42 | #extension GL_EXT_geometry_shader4 : enable |
|---|
| 43 | |
|---|
| 44 | uniform vec4 origColor; |
|---|
| 45 | uniform vec4 cloneColor; |
|---|
| 46 | |
|---|
| 47 | void main(void) |
|---|
| 48 | { |
|---|
| 49 | |
|---|
| 50 | //increment variable |
|---|
| 51 | int i; |
|---|
| 52 | |
|---|
| 53 | ///////////////////////////////////////////////////////////// |
|---|
| 54 | //This example has two parts |
|---|
| 55 | // step a) draw the primitive pushed down the pipeline |
|---|
| 56 | // there are gl_Vertices # of vertices |
|---|
| 57 | // put the vertex value into gl_Position |
|---|
| 58 | // use EmitVertex => 'create' a new vertex |
|---|
| 59 | // use EndPrimitive to signal that you are done creating a primitive! |
|---|
| 60 | // step b) create a new piece of geometry (I.E. WHY WE ARE USING A GEOMETRY SHADER!) |
|---|
| 61 | // I just do the same loop, but swizzle the x and y values |
|---|
| 62 | // result => the line we want to draw, and the same line, but along the other axis |
|---|
| 63 | |
|---|
| 64 | //Pass-thru! |
|---|
| 65 | for(i=0; i< gl_VerticesIn; i++){ |
|---|
| 66 | gl_Position = gl_PositionIn[i]; |
|---|
| 67 | gl_FrontColor = origColor; |
|---|
| 68 | EmitVertex(); |
|---|
| 69 | } |
|---|
| 70 | EndPrimitive(); |
|---|
| 71 | //New piece of geometry! We just swizzle the x and y terms |
|---|
| 72 | for(i=0; i< gl_VerticesIn; i++){ |
|---|
| 73 | gl_Position = gl_PositionIn[i]; |
|---|
| 74 | gl_Position.xy = gl_Position.yx; |
|---|
| 75 | gl_FrontColor = cloneColor; |
|---|
| 76 | EmitVertex(); |
|---|
| 77 | } |
|---|
| 78 | EndPrimitive(); |
|---|
| 79 | |
|---|
| 80 | } |
|---|