3d - no graphics

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
User avatar
VolTeK
Member
Member
Posts: 815
Joined: Sat Nov 15, 2008 2:37 pm
Location: The Fire Nation

3d - no graphics

Post by VolTeK »

i was wondering if any one has tried making 3-d boxes out of characters, no graphics, no plotting pixels? sound cool, but worth it? or would it look like a wreck on the screen, if not (if it doesnt look bad on the screen) it sounds like a good challenge to be taken upon.
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: 3d - no graphics

Post by NickJohnson »

I think I've seen it done before. You can either use filled in or shaded "characters" sort of like pixels, or do an ASCII-art style thing (which is definitely more complex). I'm not sure how well the ASCII-art kind of thing would work on the PC text console though - nothing matches up correctly, most notably the slashes and backslashes.

Either way, it would be hard to give much of a 3D impression, but you could do some sort of low-res 2D vector graphics. Or just write a VGA driver. Your choice.
User avatar
VolTeK
Member
Member
Posts: 815
Joined: Sat Nov 15, 2008 2:37 pm
Location: The Fire Nation

Re: 3d - no graphics

Post by VolTeK »

i think i would go with 2D, but im not using slashes, i am using boxes (looks better to me).
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: 3d - no graphics

Post by NickJohnson »

I mean, it's really just a matter of resolution. If all you're doing is making Tetris, text mode graphics are perfect. But if you want to do something actually graphical, you are probably going to be much happier with VGA mode in the end. It would be sort of interesting to try and make 3D graphics with text mode, but you would get generally crappy pictures of simple objects at best - nothing much beyond proof-of-concept stuff. It's like how you *can* make a car with square wheels, but you're not going to be able to sell it to anyone.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: 3d - no graphics

Post by Combuster »

From the archives of one wretched programmer: :twisted:
Image
Like this?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: 3d - no graphics

Post by Troy Martin »

Combuster: It would work loads better in 8x8 mode :) square "pixels" ftw!
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: 3d - no graphics

Post by Combuster »

This does 8x9 pixels with a 16x9 font. No VGA code, always works :D
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: 3d - no graphics

Post by Troy Martin »

Hehe. Although it appears that the top half of the "pixels" are actually a real pixel shorter than the bottom half. In 8x8 it's like 320x200 just blown up. A lot.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Re: 3d - no graphics

Post by earlz »

You could always use a font set(if you configure it right, you can choose from 512 characters, but only 8 colors) perfected for such a thing, or make one yourself, all it is is a bitmap font.

*pulls out old pmode adapted geezer code from JouleOS(2006)

Code: Select all

void set_plane(unsigned p)
{
	unsigned char pmask;

	p &= 3;
	pmask = 1 << p;
/* set read plane */
	outportb(VGA_GC_INDEX, 4);
	outportb(VGA_GC_DATA, p);
/* set write plane */
	outportb(VGA_SEQ_INDEX, 2);
	outportb(VGA_SEQ_DATA, pmask);
}


void write_regs(unsigned char *regs)
{
	unsigned i;

/* write MISCELLANEOUS reg */
	outportb(VGA_MISC_WRITE, *regs);
	regs++;
/* write SEQUENCER regs */
	for(i = 0; i < VGA_NUM_SEQ_REGS; i++)
	{
		outportb(VGA_SEQ_INDEX, i);
		outportb(VGA_SEQ_DATA, *regs);
		regs++;
	}
/* unlock CRTC registers */
	outportb(VGA_CRTC_INDEX, 0x03);
	outportb(VGA_CRTC_DATA, inportb(VGA_CRTC_DATA) | 0x80);
	outportb(VGA_CRTC_INDEX, 0x11);
	outportb(VGA_CRTC_DATA, inportb(VGA_CRTC_DATA) & ~0x80);
/* make sure they remain unlocked */
	regs[0x03] |= 0x80;
	regs[0x11] &= ~0x80;
/* write CRTC regs */
	for(i = 0; i < VGA_NUM_CRTC_REGS; i++)
	{
		outportb(VGA_CRTC_INDEX, i);
		outportb(VGA_CRTC_DATA, *regs);
		regs++;
	}
/* write GRAPHICS CONTROLLER regs */
	for(i = 0; i < VGA_NUM_GC_REGS; i++)
	{
		outportb(VGA_GC_INDEX, i);
		outportb(VGA_GC_DATA, *regs);
		regs++;
	}
/* write ATTRIBUTE CONTROLLER regs */
	for(i = 0; i < VGA_NUM_AC_REGS; i++)
	{
		(void)inportb(VGA_INSTAT_READ);
		outportb(VGA_AC_INDEX, i);
		outportb(VGA_AC_WRITE, *regs);
		regs++;
	}
/* lock 16-color palette and unblank display */
	(void)inportb(VGA_INSTAT_READ);
	outportb(VGA_AC_INDEX, 0x20);
}

static void vmemwr(unsigned dst_off, unsigned char *src, unsigned count)
{
	memcpy(dst_off|0xB8000, src, count);
}






 void write_font(unsigned char *buf, unsigned font_height) //buf is pointer to our font.
{
	unsigned char seq2, seq4, gc4, gc5, gc6;
	unsigned i;

/* save registers
set_plane() modifies GC 4 and SEQ 2, so save them as well */
	outportb(VGA_SEQ_INDEX, 2);
	seq2 = inportb(VGA_SEQ_DATA);

	outportb(VGA_SEQ_INDEX, 4);
	seq4 = inportb(VGA_SEQ_DATA);
/* turn off even-odd addressing (set flat addressing)
assume: chain-4 addressing already off */
	outportb(VGA_SEQ_DATA, seq4 | 0x04);

	outportb(VGA_GC_INDEX, 4);
	gc4 = inportb(VGA_GC_DATA);

	outportb(VGA_GC_INDEX, 5);
	gc5 = inportb(VGA_GC_DATA);
/* turn off even-odd addressing */
	outportb(VGA_GC_DATA, gc5 & ~0x10);

	outportb(VGA_GC_INDEX, 6);
	gc6 = inportb(VGA_GC_DATA);
/* turn off even-odd addressing */
	outportb(VGA_GC_DATA, gc6 & ~0x02);
/* write font to plane P4 */
	set_plane(2);
/* write font 0 */
	for(i = 0; i < 256; i++)
	{
		vmemwr(16384u * 0 + i * 32, buf, font_height);
		buf += font_height;
	}
#if 0
/* write font 1 */
	for(i = 0; i < 256; i++)
	{
		vmemwr(16384u * 1 + i * 32, buf, font_height);
		buf += font_height;
	}
#endif
/* restore registers */
	outportb(VGA_SEQ_INDEX, 2);
	outportb(VGA_SEQ_DATA, seq2);
	outportb(VGA_SEQ_INDEX, 4);
	outportb(VGA_SEQ_DATA, seq4);
	outportb(VGA_GC_INDEX, 4);
	outportb(VGA_GC_DATA, gc4);
	outportb(VGA_GC_INDEX, 5);
	outportb(VGA_GC_DATA, gc5);
	outportb(VGA_GC_INDEX, 6);
	outportb(VGA_GC_DATA, gc6);
}

User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: 3d - no graphics

Post by Combuster »

If you allow something as complex as font reprogramming, you could just as well use graphics mode. Besides, you can only put two pixels in a character cell since that's the amount of color data you can put in the text buffer.

Speaking of which, for the best results, set a 4x8 font with codepage 437 and then use the left-right pair of box-drawing characters. Again, setting mode 13 is easier.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
VolTeK
Member
Member
Posts: 815
Joined: Sat Nov 15, 2008 2:37 pm
Location: The Fire Nation

Re: 3d - no graphics

Post by VolTeK »

Combuster wrote:Like this?
yes thats it, i want to construct a macro that the user can just put in some parameters and make a shape like that and give it an effect to make it at an angle or some kind a 3-d effect, it would ask the user for a color for each side of the shape depending upon how many sides there will be, but at the momen, i havent come up with even making a window with one macro, (i make my windows line by line, but with a macro to make each line)

untill i can create the whole (one macro does it all) effect on a window i will start on this project
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: 3d - no graphics

Post by Combuster »

having a putpixel for any (80x50x3 included) resolution just works :wink:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: 3d - no graphics

Post by Love4Boobies »

GhostXoPCorp wrote:
Combuster wrote:Like this?
yes thats it, i want to construct a macro that the user can just put in some parameters and make a shape like that and give it an effect to make it at an angle or some kind a 3-d effect, it would ask the user for a color for each side of the shape depending upon how many sides there will be, but at the momen, i havent come up with even making a window with one macro, (i make my windows line by line, but with a macro to make each line)

untill i can create the whole (one macro does it all) effect on a window i will start on this project
You keep mentioning macros... Sometimes function calls might be a better idea than macros (like in the 2 cases mentioned above).
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: 3d - no graphics

Post by gravaera »

I understand what you're saying. That may or may not be useful during the absolute earliest stages of development, but if I were you, I'd concentrate on altering the charset od the driver (plane 0, 1, etc) to create a Text User Interface. (Google it)

It's a lot more efficient, and less stressful once you get past the reprogramming part. And you could use it for stylish bootup screens and whatnot, and other UI services that you may need before you initialize GFX mode.

Anyway: wish you luck.
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
User avatar
VolTeK
Member
Member
Posts: 815
Joined: Sat Nov 15, 2008 2:37 pm
Location: The Fire Nation

Re: 3d - no graphics

Post by VolTeK »

You keep mentioning macros... Sometimes function calls might be a better idea than macros (like in the 2 cases mentioned above).
i was going to put macro this, macro that after every thing, i know i used macro to many times, but what else was i going to use, i am an assemby programmer, never was much in to any other language, i figured macro was the proper way to say it.
sorry if that is a little annoying, i thought it was myself.

isnt a function call in assembly
call <function>
a macro is
<function> thats why i use macros, it easier to me to use, less time to type the extra stuff(makes me a little bit lazy)
but what ever works :)
Post Reply