www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/12/12:30:21

From: "Steven Peh" <CheePeh AT us DOT ibm DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: 3D functions in allegro
Date: Thu, 12 Nov 1998 11:05:25 -0600
Organization: IBM Rochester MN
Lines: 121
Message-ID: <72f45b$15lo$1@news.rchland.ibm.com>
References: <7287e8$ql8$1 AT nntp DOT gulfsouth DOT verio DOT net>
NNTP-Posting-Host: stevenp.rchland.ibm.com
X-Newsreader: Microsoft Outlook Express 4.72.3110.5
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

k....i'll try to give a simple example.  First of all there's a few things
to know before using those 3d functions..
1) According to the docs, these functions only support 256 colors
 yuck!)...and not truecolors...if anyone figures out how to use em in
truecolor mode...puhhleease.. post it so we can share =>
2) these functions takes the takes V3D objects as the parameters..This is
where i got caught up the first time i was using it...the x,y,z points in
V3D uses FIXED points format and V3D_f takes floating points...i was using
int to initialized it ( not good )..so when u initialized it, cast it to
fixed  via itofix() function..here's an example....

V3D v1 = { itofix( 10 ), itofix(10 ), 0, 0, 0, 0 };

the details of V3D is in allegro.txt


k..on to the example..note: part of it was copied from the example..

void progress ( int pos ) {
    if ( (pos&3) ==3 ){
        printf("*");
        fflush(stdout);
}   // this is used to emulate a progress bard when filling out the light
    // table

int main() {
    BITMAP *buffer;
    PALLETE pal;
    int c;

    // create the points for the 3d polygon...
    // we'll be drawing a 3d gouraud shaded triangle at points..
    // (10, 10), (10, 100 ), (100, 10) relative to the screen..

    V3D v1 = { itofix(10), itofix(10), 0, 0,  0, 0 };
    V3D v2 = { itofix(10), itofix(100), 0, 0, 0, 0 };
    V3D v3 = { itofix(100), itofix(10), 0, 0, 0, 0 };


    allegro_init();
    install_keyboard();
    install_mouse();

    // here's where you set up you pallete..this is just a short example
    // of how to set it up to black in array index1 of the 256 in the
pallete
    // ultimately you should fill up the whole pallete with color.....

    pal[0].r = pal[0].g = pal[0].b = 0;    // used for transparent drawing
    pal[1].r = pal[1].g = pal[1].b = 1;     // rgb of 1,1,1 - black;
    pal[2].r = pal[2].g = pal[2].b = 255; // white

    // set up a simple red gradient..
    for ( c = 3; c < 66; c++ ){
        pal[c].r = c-3;
        pal[c].g = pal[c].b = 0;
    }

    // next you need to build up the lighting table ....
    // here's the progress bar for it....

printf("<...................................................................
..........>\r<");
    // the example uses 65 columns for it .....

    // next you'll have to create a color_map for the light table...
    color_map = malloc(sizeof(COLOR_MAP));
    // note you dont actually create a color_map object...its an allegro
    // predefined...just allocate memory for it is all you need to do.

    // here's the light table...
    create_light_table( color_map, pal, 0, 0, 0, progress );

    // setup your video mode...
    set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0 );
    set_pallete( pal );

    // create the buffer...
    buffer = create_bitmap( SCREEN_W, SCREEN_H );
    clear(buffer);

    // here's where we initialize the points we created earlier with the
    // color we want ...
    v1.c = 65; // 65 corresponds to the index 65 of the pallete we
                      // created which should be bright red..
    v2.c = 3;    // these two should be dark red..or near black
    v3.c = 3;

    // k here's the grand finale...
    triangle3d( buffer, POLYTYPE_GCOL, NULL, &v1, &v2, &v3 );

    // the 3rd argument is for texture mapping, since we arent using
    // it just set it to NULL..

    vsync();
    // copy the memory buffer to screen..
    blit( buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H );

    readkey();
    destroy_bitmap( buffer );
    free( color_map );
    return 0;
} // well hope you get the picture....pardon for the overly commented
stuff...



Steven Peh
(Iax_Ikurachi AT hotmail DOT com)
Jameson wrote in message <7287e8$ql8$1 AT nntp DOT gulfsouth DOT verio DOT net>...
>hey,how do i make 3D in allegro...i mean in the Allegro .txt file..it says
>some stuff about polygon3D and Quad3D and triangle3D.I can't use these cuz
i
>don't understand how to use them.I have the syntax,but i need an SIMPLE
>example.Maybe everyone else uses something different to make 3D in
>DJGPP???can someone send me some source or a easy to understand
>syntax...(WITH SOURCE)
>
>


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019