views:

51

answers:

1

What is the "easiest" solution to code a Rubik's Cube with the following features in Opengl:

  • "Camera" moves to let user see the cube from any point of view
  • Smooth display of cube moves in response to user clicks when playing

I started with a solution drawing the cube "Face by Face" but I am not sure it's a good solution (I am facing many problems ...)

May be a solution "unit cube" by unit cube (27 cubes has to be drawn) is easier to implement ?

+1  A: 

You will have to draw 27 cubes because almost every cube belongs to several faces, so you want the faces to rotate...

What's the problem with this ? Are you worried about performance because you're on a mobile target ? 12x27 triangles is not a problem.

Calvin1602
No problem with drawing the 27 cubes. Just asking before implementing a new solution and discover new troubles. Why are you speaking about 12x17 triangles ? At a first try i was thinking to start to draw the 27 cubes as 27 GL11.glBegin(GL11.GL_LINE_LOOP); Is it wrong ?
Manuel Selva
Calvin wanted to say 12x27 triangles. 27 cubes, every cube has 6 sides, every side (square) has 2 triangles => 6x2x27 triangles to draw
dkson
Sorry, I thought I edited that. For your second question, yes it's wrong : 1) with lines you won't be able to see anything and 2) don't use glBegin but VBOs http://www.songho.ca/opengl/gl_vbo.html (even if it sounds more complicated)
Calvin1602
How can we make a Square with 2 triangles ?
Manuel Selva
?? Draw a square, draw a diagonal.. you've got two triangles
Calvin1602
Sorry I read 3 triangles !!! Is drawing 2 triangles more efficient than drawing square with GL_QUADS ?
Manuel Selva
No, but internally, openGL only knows triangles, hence my remark
Calvin1602
Ok. Many thanks for your help
Manuel Selva