delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/21/18:46:40

From: hackeroc3 AT aol DOT com (HackerOC3)
Newsgroups: comp.os.msdos.djgpp
Subject: Double Buffer
Date: 21 Mar 1998 23:31:08 GMT
Lines: 39
Message-ID: <1998032123310801.SAA04527@ladder03.news.aol.com>
NNTP-Posting-Host: ladder03.news.aol.com
Organization: AOL http://www.aol.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I have this function to create a double buffer, but it always returns 0, yet I
can still write to and copy the double buffer to the screen.

unsigned char *double_buffer = NULL;
unsigned int buffer_height = 200;
unsigned int buffer_size = 320 * 200;

int Create_Double_Buffer(int num_lines)
{
if ((double_buffer = (unsigned char *)malloc(320 * (num_lines + 1))) == NULL)
	return(0);

/*  Set the height of the buffer and compute its size */

buffer_height = num_lines;
buffer_size = 200 * num_lines/2;

/* Fill the buffer with black  (clear) */

memset(double_buffer, 0, 200 * num_lines);

/*  Everything was ok */

return (1);

}


void main(void)
{
int db;
db = Create_Double_Buffer(200);
printf("%d",db);
fflush(stdout);
getch();
}



- Raw text -


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