开发者

Selectively rotating 2d objects in openGLnGL

I am completely new to openGl. I have so far studied how to draw basic shapes and how to rotate them etc.

I want to create an application where there is will be a half circular dial and a clock hand that will rotate continuously on it. (may be from 0-180 degrees and back).

How do I go about it?

There might be several ways to do this but what will be the best way to do it given the broader pictu开发者_开发问答re of what I am trying to build.

  1. A user will create layers. In above example the circular dial is the background layer. Where as the clock hand will be foreground layer.

  2. Some layers will be static which means they will never move.

  3. Layer movement will be provided by a user (may be in a config file). In above example user will provide (some point and angle range for the clock hand layer and the layer will rotate in that range around the provided point).

Please suggest how possibly this can be achieved. Since I am using only 2D object I wonder if each layer can be a plane along z axis etc.


OpenGL is not a scene graph. It's more like pencil, brushes, dye and masks. And programming OpenGL means breaking down a scene into the drawing steps needed for creating the desired picture. So in your case it's as simple as using the Painter's Algorithm to draw in order

  1. dial
  2. first hand
  3. second hand
  4. thrird hand

There's no such thing like a "plane" primitive in OpenGL. There are just point (sprites), lines, triangles and quads; and to some degree polygons, but heavily constrained. One can apply colour and textures to those primitives and do vector math to emulate lighting.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜