So, I am trying to program in opengl (3.3) a kind of robot. The idea is that I have some simple blocks that represent his body (4 rectangles for his arms, one for the torso and the last one representing the head). To simplify a made a bad picture of my idea.

enter image description here

So now what I want to do is to make him move his arms depending on keyboard commands. Doing that would be just rotating each arm the amount that you want (translating too). But I am stuck because the only way I found to make striped rectangles (just the borders) is using the geometry shader. From the little I know about opengl, transformations are applied in the vertex shader, which would not work for my idea. Would be inefficient to apply the transformations on the geometry shader? (It is from what I know). If so, is there an easier way of drawing those rectangles?

EDIT: Ok, I can simplify a lot this question. The thing is that I want to draw those "skeletal" rectangles, but the only way I know how to do it is using the geometry shader. But with this comes the problem of the transformations, so I would want to avoid doing that. There is another way to draw those skeletal shapes?

  • 1
    \$\begingroup\$ Hello and welcome, but first of all - please match question title with its contents, from your title is not clear what exactly are you asking. And second - what are you actually asking? There is more then one question in there. Do you need to know about skeletal animation or drawing wireframe or details about geometry shader? \$\endgroup\$ – wondra Sep 11 '14 at 22:53
  • \$\begingroup\$ oops, I will change the title \$\endgroup\$ – lhahn Sep 11 '14 at 23:39
  • \$\begingroup\$ Ok, I was probably not clear. The thing is that I want to draw skeletal rectangles (just borders) but the only way that I know is using the geometry shader. There is another way to do it? \$\endgroup\$ – lhahn Sep 11 '14 at 23:41
  • \$\begingroup\$ ...and what do you mean with "just borders"? Wireframe model or silhouette or something else? \$\endgroup\$ – wondra Sep 11 '14 at 23:45
  • 1
    \$\begingroup\$ I already found, there is GL_LINE_STRIP on the glDrawArrays command, so no problem \$\endgroup\$ – lhahn Sep 12 '14 at 1:36

Looks like you don't have a clear understanding of what you can do in each type shader. You don't need a geometry shader to do this, a vertex shader is enough.

I suggest you to have a look at this tutorial that shows how to draw triangles in modern OpenGL. Once you understand how you can draw, play with the function void CGLRenderer::SetData(), which is where you set the actual vertex positions of your primitives. What you probably want to do is modify the Vertex Buffer Object content depending on the key that you press, this will change the position/orientation/size of your shapes.

Perhaps this is another good tutorial for you. It shows how to create a spinning triangle in WebGL using fragment and vertex shaders. See the result here.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.