http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

Wise2Food



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Basic graphics



Here goes (this'll run under Dos, and works with my Borland C++):

#include <iostream.h>
#include <stdio.h>

void plot(int x, int y, unsigned char color);
void setmode13h();
void settextmode();
int main();

void plot(int x, int y, unsigned char color) {
    unsigned int voffset;	
    asm {			// since C++ doesn't directly support graphics, we use Assembler code
	mov ax, 0a000h
	mov es, ax
	mov di, voffset
	mov ax, color
	mov [es:di], ax
    }
}

void setmode13h() {
    asm {
        mov ax, 13h
	int 10h
    }
}

void settextmode() {
    asm {
        mov ax, 3h
	int 10h
    }
}

int main() {
    setmode13h();
    plot(5, 5, 5);
    getch();
    settextmode();
    return 0;
}

I think this code should give you an idea, if not, ask!

Kind regards,

Lionel Pinkhard

In response to the following message from Jason Chaplin, dated Tue, Jul 25, 2000 11:30:11p +0100:
> Hi, 
>      I am just starting to learn C/C++ via a distance learning course and so far so good. However I would really like to start playing around with graphics programming (I have a deep yearning to program a scrolling starfield for some reason) I feel I wo
uld pick up the language much faster by actually coding things that I find interesting. I have searched the net but all the source code I have downloaded will not compile for one reason or another. I have downloaded Borland C++ 5.5 and that is the compile
r I am using. All I really want to get me started is a program that will work with the compiler I am using that explains how to open a screen and plot a pixel to screen. I realise that your website is for people that are far more experienced than me but y
ours is one of the best and friendliest sites I have found and I 
> would be very grateful if you could point me in the right direction.
> 
> Regards Jay Chaplin
> 

=================================================================
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 UNSUBSCꫨ please visit:
http://gameprogrammer.com/mailinglist.html