Raw 3D

Anything related to SDL

Raw 3D

Postby Semmu » Mon Nov 21, 2011 12:34 pm

Hello everybody!

(this is my first post on this forum, and even the first on any english forum :D)
I'm Laszlo Boros from Hungary, but just call me Semmu :)
I'm programming in C++ since the last summer, and I use SDL as the main library. I find it simply awesome, I love that it's so portable!
Now I'm programming a 3D renderer system, in pure SDL (the CPU does everything - i don't use any OpenGL or sth. like that - I want to write my own 3D renderer! :D)
So it's on an early stage, but here's a picture about it:
http://dl.dropbox.com/u/5836383/temp/sdl_universe.png
On the image you can see 3 spheres and one simplified house... :D As you can see it's only able to render dots, but it's going to be able to render segment and even triangles - in the 3D world. So it's going to be a fairly complex program.
Of course I have a camera, which you can lift, rotate, and move in any direction. (I'm really proud of it! :D)
But I want to ask you, if you ever had programmed sth. like this? Because I would really appreciate some tips :D This version is not very optimized, and I use some very ugly methods, so your help would be useful :)
Soon i'm going to wrap all the things in a cool library (called SDL_universe :D) and i'm going to share the soure of the early stages too.
So what do you think about it? :) Every comment is appreciated :)

(and please answer me in "easy-english", it would be easier to me to understand :D :))
thanks for reading it :)
User avatar
Semmu
 
Posts: 4
Joined: Mon Nov 21, 2011 12:18 pm

Re: Raw 3D

Postby marvin » Fri Nov 25, 2011 9:55 am

Hi, and i must ask you to reconsider. Writing engine that runs only on processor is probably not something you want unless you have some very good reason for it (none of which i could think of). If you don't belive me, look at your fps, you are barely drawing anything on screen (a few thousand DOTS) and you get 140 fps. Now consider that you will have to draw a few thousand polygons, each with a few hundred dots, you'll kill your CPU instantly.
Now, i have no idea how optimal your solution is (not optimal i'd guess), but you'll have problems no matter how good your code is when you get a lot of dots to draw.
For this, i would use opengl. In opengl you can draw dots in 2d as well, and you can do all the math by yourself if you like, but it's way faster to draw that on your screen than processor is. And i see why you would do that by hand when learning, but i see no point to doing it once you have learned how it works.
42
User avatar
marvin
 
Posts: 49
Joined: Mon Oct 24, 2011 10:25 am

Re: Raw 3D

Postby Semmu » Fri Nov 25, 2011 6:59 pm

It's purely just for fun :)
This code isn't otimized at all, and I wont draw thousands of polygons at a time :) But for low 3D graphics it's suitable I think :) I'm going to finish it, and make at least 1 game with it, but for real 3D i would use OpenGL of course ;)
User avatar
Semmu
 
Posts: 4
Joined: Mon Nov 21, 2011 12:18 pm

Re: Raw 3D

Postby Semmu » Wed Dec 26, 2012 6:42 pm

I don't know if anyone is interested in my project, but now I had some time to improve this library.
Now I can render lines and filled triangles too. The rendering method is the famous painter's algorithm, which is slow and not very accurate, but I will definitely improve it, maybe mix with z-buffer rendering. But for now it's more than nothing :)

Here on this picture you can see 100 simple houses, this means 1200 filled triangles altogether. I think the performance is very good, didn't really expect it to be better.

The camera/viewport management is full complete of course, and the code is clean and simple (I think).
If anyone is interested in the code itself, just post a message.
Attachments
Screenshot-2.png
Screenshot-2.png (92.18 KiB) Viewed 722 times
User avatar
Semmu
 
Posts: 4
Joined: Mon Nov 21, 2011 12:18 pm

Re: Raw 3D

Postby Peter » Thu Dec 27, 2012 7:40 am

Nice! You said you were going to make at least one game with it. Have you started working on the game yet?
Peter
 
Posts: 45
Joined: Sun Nov 28, 2010 3:14 pm

Re: Raw 3D

Postby Semmu » Thu Dec 27, 2012 9:55 am

Nooo, not yet. First I would like to finish this software rendering engine. When I think it's mature enough, I definitely will create some kind of 3D space shooter with it.

But first the engine itself must be finished :)
User avatar
Semmu
 
Posts: 4
Joined: Mon Nov 21, 2011 12:18 pm


Return to SDL

Who is online

Users browsing this forum: No registered users and 0 guests

cron