Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
DOOMReboot

DOOM From Scratch - Writing a DOOM engine in C++ and OpenGL

Recommended Posts

Hi guys, I was told to post here as you might be interested. 

 

I've spent the last few months writing a full game engine which can also run DOOM.  I started out with a clean slate, haven't ever peeked at the original source code, and have come pretty far I think.

 

I'm doing it to test my software development mettle and because it's simply been quite fun and I've learned a lot about OpenGL, C++, and general game engine development!

 

I'm also working on an extensive set of tutorials about pretty much everything that has gone into the engine from level and media loading, BSP stuff, audio, physics, and engine architecture, etc.

 

Here's the link to my twitter documenting my progress and then a link to my site where I'll be publishing the tutorials:

 

https://www.twitter.com/DOOMReboot

 

http://www.movax13h.com

 

 

screenshot_large.png

Share this post


Link to post

We should talk one of these days, I'm trying to learn game development myself!  By the way, know anything about using Blender with Id Tech 4?

Share this post


Link to post
On 18.04.2018 at 4:42 AM, Mike Anderson said:

  By the way, know anything about using Blender with Id Tech 4?

I've been using Blender to make static models for Doom 3 (under the ASE format). It's not trivial but you can find out the steps. Some Googling gave me the hints (which right now I've forgotten).

Share this post


Link to post

You have the aspect ratio wrong. Pixels in Doom are not square (should be 20% taller than they are wide).

Share this post


Link to post
1 hour ago, fraggle said:

You have the aspect ratio wrong. Pixels in Doom are not square (should be 20% taller than they are wide).

 

Seems really weird that it would work that way.  Does it work that way on the average computer monitor or HDTV?

Share this post


Link to post
23 hours ago, Mike Anderson said:

 

Seems really weird that it would work that way.

Hardly weird at all. The average consumer CRT was designed to be 4:3, regardless of input resolution, so video resolutions usually implied pixel ratios rather than aspect ratios. Fixed pixel ratios didn't really happen until LCDs became mainstream.

Edited by Edward850

Share this post


Link to post
On ‎18‎-‎4‎-‎2018 at 2:28 AM, DOOMReboot said:

Here's the link to my twitter documenting my progress

I have to say that I very much enjoyed going your twitter history. Step by step it details out how you went from basically an empty, black OpenGL window, through rendering vertices in an empty space, through the first wall textures, etc, until you got to the point where everything comes together to resemble a scene from Doom. I'm impressed by the progress you made in just a couple of months.

With that said, I can imagine that at some point you will hit the limits of what is currently documented about the Doom internals. You may have to peek in the source code to get for example the AI routines right.

Share this post


Link to post
22 hours ago, Mike Anderson said:

 

Seems really weird that it would work that way.  Does it work that way on the average computer monitor or HDTV?

Back then when people had CRT monitors, displaying a 320x200 image meant that pixels would be stretched vertically.

 

You've got to remember how cathode ray tubes worked. The name says it all: you have a cathode that emits rays in a tube. Here's the very first cathode ray tube:

tE7sJAu.jpg

 

 

The rays are electrons, and the surface that they hit is what's used as a screen. It's covered in phosphor, which glows when electrons excite them. So to go from there to a working screen that displays actual images, you need to have a way to change the trajectory of the cathode rays, exciting the parts of the screen that must be lit, but not the parts that must be dark. This is done with electromagnets that attract or repel the electrons just enough to bend their trajectory. Suffice to say that this is an analog process, not a digital one. Then there's an additional complexity to get color images, because you can't aim your electron beam selectively at individual subpixels to get red, green, or blue, so instead systems with shadow masks or aperture grills were invented for that, but that's besides the point.

 

Also, the inside of the tube is a relative vacuum -- you don't want anything to be an obstacle to your electron beam, and air is definitely an obstacle. Pressure differentials being a bitch, your CRT needs to be made of a strong material that can withstand the crushing pressure of the atmosphere compared to a near-vacuum, and you also want a shape that can handle pressure well -- and the best shape for that being a perfect sphere, it's hard to deviate too much from this. Hence, TVs had a rather squarish 4:3 ratio while cinemas, which used a completely different technology by projecting images on a big white sheet, could be much wider with their 16:9 ratio.

 

Anyway: you send an image to a CRT, it'll stretch it to fit. And if you have an image that is a 8:5 logical ratio (like a 320x200 image) but you display it on a 4:3 physical screen, then you get it vertically stretched. It'll occupy the same physical space as a 320x240 image.

 

LCDs use a completely different technology, one that is inherently digital instead of inherently analog like the CRTs. That means that while CRTs screens could naturally adapt to any resolution lower than their maximum, LCDs have troubles operating in resolutions other than their native one. Pixels aren't made of multiple tiny dots, the tiny dots are the pixels. The resolution doesn't depend on the precision of the deflection yoke, but on how many pixels there are. And that makes an LCD screen really poor at stretching and scaling, you'll get your image letterboxed, or clumsily stretched by having some pixels doubled up while others aren't. For these reasons, you want the image to look good, you'll need to do stretching in software and use aspect ratio correction. Really, the best way to think about it is in term of emulation -- you need to emulate in software something that the hardware no longer does.

Share this post


Link to post

That almost gives the impression that "emulating electrons" and CRT in general could be possible in the future through LCD...

Share this post


Link to post

I'm so glad I found this post. I'm in school for CS now and would love to watch your tutorials. I'm still trying to understand from the basics, so if you would please, when do you see a start to the first entry to the tutorials?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×