Click here to Skip to main content
15,890,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I draw a cube please help me. thanks for you assistance
Posted


  1. We're not going to do your homework for you.
  2. You're homework isn't to draw a cube; you merely need to construct one in memory according to the parameters given.
 
Share this answer
 
Use SDL to draw to the screen. You can draw a cube by constructing each side of it with triangles (2 triangles to a side). Do some 3D math to rotate the cube into the correct viewing position and with the correct projection. Then draw each pixel of each triangle to a buffer. If a point was already drawn to the buffer and the z-coordinate is closer than the one that may get drawn, then don't draw the new one. If you want an image on the cube rather than a solid color, map an image to each triangle so each pixel on the screen can be transformed to the corresponding pixel in the image. And if you want to add lighting, create a light source and do some calculations to see how the light interacts with the surface of each triangle and the viewing camera. Finally, once you've finished drawing everything to that buffer, transfer it to the screen using SDL.

That's the hard way of doing it. There are various libraries out there for simplifying things (SDL actually has some ways of simplifying this task). If you are an absolute beginner, I recommend XNA, but then you'd have to learn some C#. OpenGL is another option (I believe SDL is actually built on top of OpenGL).
 
Share this answer
 
v2
This is a hard question to answer. Where do you want to draw it ? Do you expect it to move ? GDI has methods for drawing lines, which can be made to look like a cube, but you'd need to use DirectX to draw an actual 3D shape that can be moved in 3D.
 
Share this answer
 
thanks for your help but i do not want a complete solution you are right.because of my learning proccess i should do this however i am really in need of some different perception to understand it. i am really sorry if i was misunderstood
 
Share this answer
 
actually my main question is in

http://www.cmpe.boun.edu.tr/courses/cmpe160/fall2009/cmpe160project1.htm

can you check it out for me?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900