Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / 3D Theory & Graphics / HELP ME WITH 3D and Sprites, anyone, please! Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
Why?

July 15, 1999, 10:00 PM

I'm amazed at all the amature web sites i've found with lots of 3d engines.
How would i go about writing one?
i've been taking CS classes in C++ for about a year, although i started C++ 1 and
a half years ago. I need help in designing a simple sprite engine or a raycasting engine.
Although i have focussed heavely on object oriented programming, i've been stumbling about
in the dark with graphics in DOS. I have Visual Sutdio 6 and Turbo C++. Could someone tell me
what i need to do to learn 3d graphics programming in C++ (C is slightly obscure to me),
because the best i can do is a little animation with lines and dots (i've attempted to write
a PCX reader 4 times!;each resulted in a crash)
on a side note: what is near and far in C++?

 
Dimitris

July 16, 1999, 07:08 AM



Why? wrote:
>>I'm amazed at all the amature web sites i've found with lots of 3d engines.
>>How would i go about writing one?
>>i've been taking CS classes in C++ for about a year, although i started C++ 1 and
>>a half years ago. I need help in designing a simple sprite engine or a raycasting engine.
>>Although i have focussed heavely on object oriented programming, i've been stumbling about
>>in the dark with graphics in DOS. I have Visual Sutdio 6 and Turbo C++. Could someone tell me
>>what i need to do to learn 3d graphics programming in C++ (C is slightly obscure to me),
>>because the best i can do is a little animation with lines and dots (i've attempted to write
>>a PCX reader 4 times!;each resulted in a crash)
>>on a side note: what is near and far in C++?

If you tried four times to write a pcx reader and you didn't make it, then you must
forgot 3d graphics for now. Better learn first how to code basic things and trie
making some small programs and then go to 2d and then to 3d. This is what all we did :)

Greets, Dimitris


 
Why?

July 16, 1999, 01:02 PM

even tho my little PCX reader "worked" in the sense that it read and decoded a PCX file,
i couldn't get it to read in the pallete, and after it displayed the file, it would
reboot automatically. how can i fix this? i first declare a byte pointer to the starting
segment of the VGA memory. then i load the PCX and decompress it into a temporary
byte pointer array. i then copy that buffer to the VGA address. it works, it decodes fine,
but the pallete is messed up because i haven't gotten to that part yet. still why
does it crash? i've tried it medium and large memory models. do i have to use near or
far thingies instead of regular byte pointers? any suggestions?

 
Daniel

July 16, 1999, 03:51 PM



Why? wrote:
>>even tho my little PCX reader "worked" in the sense that it read and decoded a PCX file,
>>i couldn't get it to read in the pallete, and after it displayed the file, it would
>>reboot automatically. how can i fix this? i first declare a byte pointer to the starting
>>segment of the VGA memory. then i load the PCX and decompress it into a temporary
>>byte pointer array. i then copy that buffer to the VGA address. it works, it decodes fine,
>>but the pallete is messed up because i haven't gotten to that part yet. still why
>>does it crash? i've tried it medium and large memory models. do i have to use near or
>>far thingies instead of regular byte pointers? any suggestions?

Do not worry about near and far's for right now. Once you get the hang of C++ and move to Visual C++, they will no longer be of use to you. To settle your curiosity, near stuff is generally in the same memory segment, far stuff is in a different memory segment. example: to access a near variable, only 2 bytes are needed (0000) but a far variable requires 4 bytes (0000:0000). I may be wrong on the number of bytes, etc. That is why the video address is almost always defined as far - It is in it's own segment.

As for your palette problem, Get yourself a good book. 'The Black Art of 3d Game Programming' by Andre LaMothe is an excellent place to start. It covers PCX loading, palette manipulation, VGA mode 13h, etc. and then it introduces you to 3D programming. 'Tips and Tricks of the Game Programming Gurus' is another good book that thouroughly explains PCX loading, decoding and displaying.

Happy Coding!

 
Dimitris

July 16, 1999, 06:14 PM



Why? wrote:
>>even tho my little PCX reader "worked" in the sense that it read and decoded a PCX file,
>>i couldn't get it to read in the pallete, and after it displayed the file, it would
>>reboot automatically. how can i fix this? i first declare a byte pointer to the starting
>>segment of the VGA memory. then i load the PCX and decompress it into a temporary
>>byte pointer array. i then copy that buffer to the VGA address. it works, it decodes fine,
>>but the pallete is messed up because i haven't gotten to that part yet. still why
>>does it crash? i've tried it medium and large memory models. do i have to use near or
>>far thingies instead of regular byte pointers? any suggestions?

The pallete table of the picture, as far as i remember, is at end of the file. It is 768 bytes
long and it has 3 bytes for each one of 256 colors of the screen. So, when you load the
pallete table do this to change the pallete(after you have enter graphics mode):
port(0x3c8)=0
for i=0 to 767
{ port(0x3c9)=paltbl/4 } I divided with 4 because R, G, B values in pcx format have 256 different values and the vga use only 64 different values, so we divide it with four(you can make modern vgas to use 256 dif values but this is another subject). I hope i help a little Greets, Dimitris.

 
Dimitris

July 16, 1999, 06:14 PM



Why? wrote:
>>even tho my little PCX reader "worked" in the sense that it read and decoded a PCX file,
>>i couldn't get it to read in the pallete, and after it displayed the file, it would
>>reboot automatically. how can i fix this? i first declare a byte pointer to the starting
>>segment of the VGA memory. then i load the PCX and decompress it into a temporary
>>byte pointer array. i then copy that buffer to the VGA address. it works, it decodes fine,
>>but the pallete is messed up because i haven't gotten to that part yet. still why
>>does it crash? i've tried it medium and large memory models. do i have to use near or
>>far thingies instead of regular byte pointers? any suggestions?

The pallete table of the picture, as far as i remember, is at end of the file. It is 768 bytes
long and it has 3 bytes for each one of 256 colors of the screen. So, when you load the
pallete table do this to change the pallete(after you have enter graphics mode):
port(0x3c8)=0
for i=0 to 767
{ port(0x3c9)=paltbl/4 } I divided with 4 because R, G, B values in pcx format have 256 different values and the vga use only 64 different values, so we divide it with four(you can make modern vgas to use 256 dif values but this is another subject). I hope i help a little Greets, Dimitris.

 
Why?

July 17, 1999, 04:55 PM

thanks guys!

 
This thread contains 7 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.