|
||
|
GP Mailing List
ATXGPSIG List
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: Graphics (simple)
> Hi all, > > Am I right is saying that most of the people on this list know how to do > some sort of simple graphics??? > > I have written on numerous occasions asking about books, tutorials etc. on > this subject and had no real help. How did you guys learn??? > > Thanks, > Rob. > Hi, the Direct X SDK“s contain quite an ammount of dokumentation and sample code, http://www.flipcode.com is always worth a look. For a bloody simple way of doing some graphics these functions might help: #include <stdlib.h> #include <iostream.h> #include <dos.h> //The pointers to the framebuffer/memory mapping //vga points to the videomemory mapped in the normal //memory space unsigned char *vga=(unsigned char*)MK_FP(0xA000,0); //not essential, but its faster then writing directly //to the video memory unsigned char *frame; //create the framebuffer void CreateFrameBuffer() { frame=(unsigned char*)malloc(64000); if(frame==NULL) { cout<<"memory allocation failed"<<endl; exit(-1); } } //set the MCGA mode void SetMCGA() { asm mov ax,0x0013; asm int 0x10; } //set to the textmode void SetTEXT() { free(frame); frame=NULL; asm mov ax, 0x0003; asm int 0x10; } //draw the framebuffer to the screen void DRAW() { memcpy(vga, frame,64000); } //set the palette void SetCOLOR(unsigned char i, unsigned char red,unsigned char green, unsigned char blue) { //output the index of the color outp(0x3c8,i); //and set the RGB components outp(0x3c9,red); outp(0x3c9,green); outp(0x3c9,blue); } //put a pixel to the framebuffer void PutPixel(int x, int y, unsigned char color) { *(frame+(y*320)+x)=color; } yours Robert ================================================================= The GameProgrammer.Com mailing list is for the open discussion of any topic related to the art, science, and business of programming games. This list is especially tolerant of beginners. We were all beginners once To SUBSCRIBE or UNSUBSCRIBE please visit: http://gameprogrammer.com/mailinglist.html
|
|