C Drawing 3D rotating cube using X11 only?

Hello,

Without acceleration, which code would draw a 3D rotating cube using X11 for fun !.

It is better SDL or openGL, but here it is for edu (basic x11 layer).

Thank you!
Best regards
 
You don't really think there's some "magic" code that could be given here, do you? With just X11, you'll use some drawing primitives and do all the calculations yourself... should be feasible for "wireframe" display.
 
For new code, use XCB in place of XLib.

Create a shared memory pixmap.
1. any operation that takes a drawable will work.
2. can directly address individual pixels.
3. memory is shared with X server so all those pixels are not actually copied over the socket.

It is very easy to create an animation loop around this.

If the X client and X server are separate hosts, a plain pixmap works at the expense of bandwidth.
 
For new code, use XCB in place of XLib.

Create a shared memory pixmap.
1. any operation that takes a drawable will work.
2. can directly address individual pixels.
3. memory is shared with X server so all those pixels are not actually copied over the socket.

It is very easy to create an animation loop around this.

If the X client and X server are separate hosts, a plain pixmap works at the expense of bandwidth.

I guess X11 is better for this because it teaches X11.
 
Re-implement double buffers ...
Re-implement Math matrix ...
Re-implement 3D to 2D projection ...
Re-implement camera perspective projection ...
Re-implement clip projection ...
Write GPU Accelerated code with the GPU Vendor's API, otherwise your cube is horrible slow.
 
Back
Top