www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/09/27/11:47:46

Xref: news-dnh.mv.net comp.os.msdos.djgpp:2207
Path: news-dnh.mv.net!mv!news.sprintlink.net!howland.reston.ans.net!swrinde!sgigate.sgi.com!enews.sgi.com!decwrl!waikato!midland.co.nz!chrismac
From: chrismac AT midland DOT co DOT nz (Chris McFarlane)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: grx2.0 - page flipping example
Date: Wed, 27 Sep 95 15:15:58 GMT
Organization: .
Lines: 65
References: <446be3$5ti AT fu-berlin DOT de>
Nntp-Posting-Host: chrismac.midland.co.nz
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Dj-Gateway: from newsgroup comp.os.msdos.djgpp

In article <446be3$5ti AT fu-berlin DOT de>,
   amanjit AT fub46 DOT zedat DOT fu-berlin DOT de (Amanjit Gill) wrote:
>I know it´s a beta. And yes, i want to do one basic thing: page flipping. 

Amanjit, this is a simple page flipping test prog. Some minor changes in 
non-test code complete it, and give excellent linear buffer results.

#include <stdlib.h>
#include <stdio.h>
#include <dos.h>
#include "grx20.h"

#define DSPRIGHT 640
#define DSPBOTTOM 480

int main() {
GrContext *vscn, *page0, *page1;
int vpage0=0, vpage1=DSPBOTTOM, lineno;

   GrSetMode(GR_custom_graphics,
             DSPRIGHT, DSPBOTTOM,
             256,
             DSPRIGHT,2*DSPBOTTOM);

// check to see if you really got what you wanted:
   if((GrScreenX()  != DSPRIGHT)  ||
      (GrScreenY()  != DSPBOTTOM) ||
      (GrVirtualX() != DSPRIGHT)  ||
      (GrVirtualY() != DSPBOTTOM*2)) {
      return -1;
   }

   vscn = GrSaveContext( NULL );
   page0 = GrCreateSubContext(0, 0, DSPRIGHT-1,DSPBOTTOM-1, vscn, NULL);
   page1 = GrCreateSubContext(0,DSPBOTTOM,DSPRIGHT-1,DSPBOTTOM*2-1, vscn, 
NULL);
   GrSetViewport(0, vpage1);

   do {
      GrSetContext( page0 );
      GrClearContext( GrBlack() );

      for ( lineno=0; lineno < DSPBOTTOM; lineno+=4)
          GrHLine( 20, DSPRIGHT-20, lineno, GrWhite());
      GrTextXY( 20, DSPBOTTOM/2+10, "#Page0#", GrWhite(), GrBlack());
      GrSetViewport(0, vpage0);

      GrSetContext( page1 );
      GrClearContext( GrBlack() );

      for ( lineno=2; lineno < DSPBOTTOM; lineno+=4)
         GrHLine( 20, DSPRIGHT-20, lineno, GrWhite());
      GrTextXY( 20, DSPBOTTOM/2+10, "*Page1*", GrWhite(), GrBlack());
      GrSetViewport(0, vpage1);

      if ( kbhit() )
         if ( getkey() == 27 ) break;
   } while ( 1 );

   GrSetMode( GR_default_text );
   return 0;
};

rgds
Chris

- Raw text -


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