Mail Archives: djgpp/1999/11/23/20:05:04
From: | Peter Danielsson <e96pd AT efd DOT lth DOT se>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: fast depth buffer
|
Date: | Wed, 24 Nov 1999 01:23:00 +0100
|
Organization: | Student
|
Lines: | 81
|
Message-ID: | <383B2FE4.E0128B49@efd.lth.se>
|
References: | <81eth3$95r$2 AT gxsn DOT com>
|
NNTP-Posting-Host: | dialin-45-34.student.lu.se
|
Mime-Version: | 1.0
|
X-Mailer: | Mozilla 4.6 [en] (Win98; I)
|
X-Accept-Language: | en
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
I have written some code that you perhaps would like. It is inside a program,
but I could cut it out for you. It is written in assembler and C/C++ and is
fast. It has a 640*480 integer Z-buffer and can scale an image in 256 colors
with the width 128 (easy modified to any power of 2) on another bitmap (ie.
unsigned char *). Of course it sets Z-buffer to newlength if it is closer. Is
ths something for you?
/Peter
Anthony Graham wrote:
> 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 -