home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Computer Panoráma
/
computer_panorama_1997-12-hibas.iso
/
SHARE
/
GRAPH
/
PTC051.ZIP
/
EXAMPLES
/
PRIMARY.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1997-09-04
|
1KB
|
61 lines
////////////////////////////////////////////////////////////////
// random pixels direct to the display (ARGB8888 modes only!) //
////////////////////////////////////////////////////////////////
#include "ptc.h"
#include <conio.h>
#include <iostream.h>
#include <stdlib.h>
int main()
{
// resolution
int xres=320;
int yres=200;
// initialize ptc
PTC ptc(xres,yres,ARGB8888);
if (!ptc.ok())
{
ptc.Close();
cout << "this example requires a 32bit ARGB8888 video mode\n";
return 1;
}
// get primary surface (display surface)
Surface *primary=ptc.GetPrimary();
if (!primary || !primary->ok())
{
ptc.Close();
cout << "could not access primary surface\n";
return 0;
}
// main loop
while (!ptc.kbhit())
{
// lock primary surface
uint* buffer=(uint*)primary->Lock();
if (!buffer) return 1;
// plot 100 random pixels
for (int i=0; i<100; i++)
{
int x=random(xres);
int y=random(yres);
uint* dest=buffer + (xres*y)+x;
*dest=RGB32(random(255),random(255),random(255));
}
// unlock primary
primary->Unlock();
}
return 0;
}