DIGIT-ARC read-only archive · snapshot: July 23, 2026

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

15 posts · originally from https://geek.digit.in/community/threads/a-3d-rubiks-cube-in-c-and-glut-without-mfc.173569/

Shah
Shah Original post #1
May 8, 2013 at 10:38 AM
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
May 8, 2013 at 11:54 AM
I dont know how to do it, but OpenGL is the best way to work with graphics.
Shah
Shah #3
May 8, 2013 at 12:00 PM
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
Neuron #4
May 8, 2013 at 4:56 PM
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


....
Shah
Shah #5
May 8, 2013 at 6:59 PM
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
RCuber #6
May 8, 2013 at 7:02 PM
Search - CodeProject
Shah
Shah #7
May 8, 2013 at 7:34 PM
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.
harshilsharma63
May 8, 2013 at 7:46 PM
@op; did you read the glut getting started wiki? Its very helpful.

@op; did you read the glut getting started wiki? Its very helpful.
H
May 8, 2013 at 7:47 PM
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.
Shah
Shah #10
May 8, 2013 at 7:54 PM
@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?
H
heidi2521 #11
May 8, 2013 at 9:33 PM
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. :|
Shah
Shah #12
May 9, 2013 at 9:53 AM
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.
G
May 9, 2013 at 1:53 PM
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.
Shah
Shah #14
May 9, 2013 at 1:58 PM
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.