delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/11/23/17:06:26

From: "Anthony Graham" <Anthony AT fonzyco DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: fast depth buffer
Date: Tue, 23 Nov 1999 19:54:23 -0000
Organization: GXSN
Lines: 84
Message-ID: <81eth3$95r$2@gxsn.com>
NNTP-Posting-Host: 195.147.151.62
X-Trace: 943389027 1NNUCNF1G973EC393C gxsn.com
X-Complaints-To: abuse AT gxsn DOT com
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2314.1300
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Anyone good with speeding up code?

I need to code a Z-Buffer Manually (Can't use a library as it makes it too
easy and so i'd not get the grade i need in my A-Level).... This is how it
works, not the actual code, in DJGPP and ALLEGRO:

int THEZBUFFER[640][480];
BITMAP *SCREEN_BUFFER;


void ClearZBuffer()
{
 int xrun;
 int yrun;
 for (yrun=0;yrun<480;yrun++)
 {
 for (xrun=0;xrun<640;xrun++)
 {
  THEZBUFFER[yrun][xrun]=1000000;
 }
 }

}


void drawpixel(int x, int y, int z)
{
if (z<THEZBUFFER[y][x])
{
THEZBUFFER[y][x]=z;
{draw the pixel}
}



my first thoughts were to make an int BLANK_ZBUFFER[640][480] and clear that
and use the normal zbuffer and instead of clearing it:
THEZBUFFER=BLANK_ZBUFFER but i get an error about incompatable types!! even
though they're the exact same!!

any ideas?

I'll try upgrading to the latest versions of djgpp and allegro.

some libs use a bitmap??!! but they can only have 256 levels of depth as
they store chars not ints,

unfortunatly i can't follow the code in these libs, nor can i use them, If
anyone could explain how to use bitmaps as zbuffers i'd be very grateful.

Please use C not C++ as i don't understand C++
Please e mail me suggestions to the address below

Thanks in advance:

- Anthony
Anthony AT fonzyco DOT co DOT uk


My Engine Stats:

500 small persp correct textured triangles per scene:

both still check the zbuffer even though they don't clear it, this makes
them useless but it demonstrates how slow the clear of the zbuffer is:

with zbufferclear @640,480: 13.88 FPS
without zbufferclear @640,480: 24.9 FPS
with zbufferclear @320,240: 50 FPS
without zbufferclear @320,240: 100 FPS

This is without any game code, the triangles are hardcoded (and repeated
many times), there is no other things happening, like key checks animation
or anything!!!










- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019