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



## Shah (May 8, 2013)

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)

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


----------



## Shah (May 8, 2013)

harshilsharma63 said:


> 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 (May 8, 2013)

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 (May 8, 2013)

Neuron said:


> 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
> ...



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 (May 8, 2013)

Search - CodeProject


----------



## Shah (May 8, 2013)

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)

@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 (May 8, 2013)

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 (May 8, 2013)

harshilsharma63 said:


> @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?



dead5 said:


> 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?


----------



## heidi2521 (May 8, 2013)

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 (May 9, 2013)

dead5 said:


> 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.



dead5 said:


> 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 (May 9, 2013)

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 (May 9, 2013)

gopi_vbboy said:


> 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.


----------



## harshilsharma63 (May 9, 2013)

Shah said:


> Can I have a link to it?


Getting Started - OpenGL.org


----------

