c++ - Rotating verticies created by a geometry shader -


i trying generate cube 6 points (each point representing side, 2 values if rotated face on x, or y axis, z axis doesn't need 1 because default). problem comes in when try multiply gl_position value mat4 rotation matrix make sides of cube rotated properly. doesn't glitch out, doesn't display faces @ (it when dont have matrices multiplying values).

heres geometry shader:

layout(points) in; layout(triangle_strip, max_vertices = 4) out;  in vec3 gfacepos[];  out vec2 texcoord;  mat4 xtrans = mat4( //rotate on x axis 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 );  mat4 ytrans = mat4( //rotate on y 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 );  mat4 rtrans = (gfacepos[0].x * xtrans) + (gfacepos[0].y * ytrans); //figure out current point wants rotate on  void main() { //this whole thing makes square @ requested point     gl_position = gl_in[0].gl_position + vec4(-0.5, 0.5, 0.0, 0.0);     gl_position *= rtrans; //these break     texcoord = vec2(0.0, 0.0);     emitvertex();     gl_position = gl_in[0].gl_position + vec4(0.5, 0.5, 0.0, 0.0);     gl_position *= rtrans;     texcoord = vec2(1.0, 0.0);     emitvertex();     gl_position = gl_in[0].gl_position + vec4(-0.5, -0.5, 0.0, 0.0);     gl_position *= rtrans;     texcoord = vec2(0.0, 1.0);     emitvertex();     gl_position = gl_in[0].gl_position + vec4(0.5, -0.5, 0.0, 0.0);     gl_position *= rtrans;     texcoord = vec2(1.0, 1.0);     emitvertex();     endprimitive(); } 

fragment , vertex pretty standard (vertex has basic camera stuff on it).


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

html - Repeat image to extend header to fill screen -

javascript - Backbone.js getting target attribute -