# Simple 3d Rendering

Hello I am trying to make a very small 3d wire frame rendering system. Instead of throwing together a bunch of random stuff together…as I am doing now…I would like to know if there is some source code of how OpenGL would render a 3d wireframe cube using only software…no hardware…

So far I can render a wire frame cube and move it around, rotate it, and convert it to be displayed on the screen using matrices and a bunch of trig…then I just draw the lines between the calculated points on the screen…but I am now having some problems.
1…I can only Rotate about the world axis not the cube axis.
2…Translations are about the world axis not the cube axis.
3…I cannot control the orientation of the camera.

What I would like to do is be able to.
Create a 3d object by entering in 3d coordinates for the vertices into a matrix. I would like to have control of the rotation and position of the object in 3d space, and be able to move the camera around in 3d space as well. Then have the scene be rendered to the screen by only using 2d lines.

Like I said I have some code that does about half of this so far…and I have hit a wall patching things together from different sources…(those three problems above have not been addressed) so I was wondering if there was something useful around here that might be able to explain how to do this better.

I can post my source code(java) if that would help but I was hoping that somebody might know of something like this that already exists.

Most of the stuff I find is incomplete or way to high level. I just want bare bones linear algebra and then draw some 2d lines on the screen to make it look right.

I think I am basically looking for an example that someone wrote in open GL that does all this using only the 2d functions of openGL…to create the 3d objects, so that all of the math involved must be shown.

I think you want to read http://fly.cc.fer.hr/~unreal/theredbook/chapter03.html, it describes how OpenGL transforms an object’s vertices.

That is interesting…but I was looking for something that renders 3d stuff using only 2d line drawing functions…that article is pretty good but it still draws stuff using the 3d functions.

Carsten’s link is a starter. You need to create your own transformation matrices

1. Object transform (opengl’s MODELVIEW matrix)
2. Projection transform (opengl’s PROJECTION matrix)
3. Perform the perspective division
4. Viewport transform (opengl’s VIEWPORT matrix)

Then you apply those transformations as explained in the link above. You’ll end up with the 2D vertices you need to draw your lines.