Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

back to the roots

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I'm really hopeing someone here can help me with this. I want to produce graphics useing C...but I don't want to use someone elses library with jargin that I don't need, I want to know how to do it myself. I know that I need at least the following;

1: A function to access and alocate video memory
2: A function to set the video mode, and display directly
to the screen.

If someone can give me an example of something as simple is displaying a bit map immage into windows (preferably layered over the desktop) i would be very pleased. Keep in mind I DO NOT want to use someone elses library, I want this to do that function and ONLY that fuction.

I'm just REALLY curious to learn this for my self, and possibly develop my own GUI interface.

Any help is appriciated.

Thank you,
Rob

Please email responces to roemmer@btol.com, so I can check them easily ;) thank you
 
search at google for VBE
VESA Bios Extention.
those are standard bios functions for using your standard graphics card
you could also search for INT10H bios interrupt 10,
that is the standard graphics interrupt
i think that you need to use inline assembler to control the graphics bios.

i've been working on a pascal unit to control graphic functions a while ago, and i can tell you that it's quite hard to understand and to imblement. and i'd like to wish you the best on this subject.
 
PS could you update me on your progress?
i'm very interested.
I'm a starting c programmer and i have experience in pascal and also a little in programming graphic user interfaces.
so if you want advice or you have problems you may ask me
mailto : cyclofrene@hotmail.com
page : http//wbssoftware.tripod.com
Best Regards
cyclofrene.
 
i am preassuming you are working in dos, if anything else pls let me know..:)
you can write your own graphics library,
first what all you need
1. mode converter functions (by default we run normal mode HEX 3 )
2. a function to display a pixel at any x,y location.
3. utility functions like circle, rectangle, line etc. which can be based on the pixel.

for the first set of function you should know about the interrup 10, which is associated with display and lets you select the mode like i have written setmode function

void setmode(int mode)
{
union REGS regs;
regs.h.ah=0x0;
regs.h.al=(unsigned char)mode;
int86(0x10,&regs,&regs);
}

sorry for not providing error handling mode can be 0x12 or any other you wish.

for setpixel it is bit tricky it depends upon the mode like for 0x12 i have written like

void setpix(int x,int y)
{
char far * v=(char far *)0xA0000000UL;
int address;
int offset,i;
if(col == 0){
for(i=0;i<y;i++)
v+=80;
Find_Address_Block(x, &address ,&offset);
// printf(&quot;offset= %d %d %d&quot;,offset,power(2,7-offset),!power(2,7-offset));
v[address]=(char)(v[address] & ( 255 - power(2 , 7-offset)) );

}
else{
for(i=0;i<y;i++)
v+=80;
Find_Address_Block(x, &address ,&offset);
v[address]=(char)(v[address] | power(2,7-offset) );
}
}

void Find_Address_Block(int x, int *address ,int *offset)
{
(*address)=x/8;
(*offset)=x%8;
}

here far * address refers to the memory of VRAM so according you manupulate. say if my mode have been 0x13 my set pixel would be like


col is the color (between 0 to 15). 0 correponds to black and 15 corresponds to white.
void setpix(int x,int y)
{
char far * v=(char far *)0xA0000000UL;
v[y*320+x]=col;
}


you have to see the mode and see how much memory is taken by each pixel like in 0x12 case each pixel takes the memory of 1 bit whereas in case of 0x13 each pixel is one byte. also you have to see how colors are generated like in 0x12 case a separate pallet of colors has to initialized (function will be similar to setmode). but in case of 0x13 pixel information conatins that.

hopefully it gives you start
cancer

 
But if you start drawing lines using that same pixel function, then you get a F*cking slow line function.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top