A 3D Rubik's Cube in C++ and GLUT without MFC.

Shah

Cyborg Agent
Hi friends,

I thought of writing a program which could solve Rubik's cube. So, I used Google to search for some 3D Rubik's Cube solver written in C++ to get an idea on how to code a 3D Rubik's Cube with movements. but, Unfortunately all that I found were using MFC not GLUT. I need your help in writing code to get a 3D Rubik's Cube with animation. I can code the solver but not a 3D Rubik's Cube. As far as compiler is concerned. I have Code::Blocks 12.11, Netbeans 7.3 and Visual Studio 2010 Express Edition.

harshilsharma63

DIY FTW!
I dont know how to do it, but OpenGL is the best way to work with graphics.

OP

Shah

Cyborg Agent
I dont know how to do it, but OpenGL is the best way to work with graphics.

Yeah I too know that OpenGL is the best way but I can't find enough tutorials or examples on the internet to get started. Installing GLUT alongside Code::Blocks was itself very much confusing.

Neuron

Electronic.
Creating and rendering a 3D rubix cube is pretty complex. The easier thing you can do is to render all the faces of the cube in 2d one after another or even simpler, just output the color of each small block onto the screen like a matrix.

Something like this
3x3 cube
face 1

r b g
y r r
w o w

face 2

y b b
r r w
o o o

....

OP

Shah

Cyborg Agent
Creating and rendering a 3D rubix cube is pretty complex. The easier thing you can do is to render all the faces of the cube in 2d one after another or even simpler, just output the color of each small block onto the screen like a matrix.

Something like this
3x3 cube
face 1

r b g
y r r
w o w

face 2

y b b
r r w
o o o

....

One of the reasons I am writing this program is that I also want to learn to create and render a 3D model in C++ using GLUT. So, There is no use of writing this program if i have to render a 2D cube.

RCuber

The Mighty Unkel!!!
Staff member
Search - CodeProject

OP

Shah

Cyborg Agent
After googling further, I found a project written in C++ that should create a 3D Rubik's Cube. Unfortunately It doesn't work. Can someone check what is its problem?

Link to that program : How to Create a spinning 3D cube with OpenGL, GLUT and C++ « C++

BTW, I used Code::Blocks to compile and run it. I created a GLUT project and then added those 3 files included with the source. It gave no errors or warnings. But, It doesn't work as intended.

Attachments

• Untitled.jpg
95.3 KB · Views: 127

harshilsharma63

DIY FTW!
@op; did you read the glut getting started wiki? Its very helpful.

@op; did you read the glut getting started wiki? Its very helpful.

heidi2521

Draw a 3D Rubik cube using OpenGL utility toolkits GLUT with source code | Code in code::blocks

I didn't spot any afx headers so it should be MFC free.

OP

Shah

Cyborg Agent
@op; did you read the glut getting started wiki? Its very helpful.

@op; did you read the glut getting started wiki? Its very helpful.
Can I have a link to it?

Draw a 3D Rubik cube using OpenGL utility toolkits GLUT with source code | Code in code::blocks

I didn't spot any afx headers so it should be MFC free.

Will try it, buddy.
EDIT: This one too returns the same window. Did it work for you?

Last edited:

heidi2521

I haven't really programmed in cpp for some time and my PC is not set up to use openGL/GLUT. I posted it here because the code looked correct to me.

OP

Shah

Cyborg Agent
I haven't really programmed in cpp for some time and my PC is not set up to use openGL/GLUT. I posted it here because the code looked correct to me.

Anyway, Thanks. Posted a comment regarding this on that blog. Waiting for the admin to comment back.

I haven't really programmed in cpp for some time and my PC is not set up to use openGL/GLUT. I posted it here because the code looked correct to me.

Anyway, Thanks. Posted a comment regarding this on that blog. Waiting for the admin to comment back.

gopi_vbboy

Cyborg Agent
The question is are you interested in solving Rubik cube problem or rendering 3d cube?

Because you can solve rubik cube problem without necessarily rendering it on 3d by using 2d or console mathematically.

OP

Shah

Cyborg Agent
The question is are you interested in solving Rubik cube problem or rendering 3d cube?

Because you can solved rubik cube problem without rendering it on 3d by using 2d or console mathematically.

I am more interested in rendering a 3D cube with its movements.