Mail Archives: djgpp/2000/09/24/23:46:57
From: | "23yrold3yrold" <cbarry AT pangea DOT ca>
|
Newsgroups: | comp.os.msdos.djgpp
|
References: | <39C9617E DOT A5EDE2E8 AT inwind DOT it>
|
Subject: | Re: problem with allegro
|
Date: | Sun, 24 Sep 2000 22:24:38 -0500
|
Lines: | 76
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
X-Newsreader: | Microsoft Outlook Express 5.00.2919.6600
|
X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2919.6600
|
NNTP-Posting-Host: | spamkiller
|
Message-ID: | <39cec7d7_3@spamkiller.newsfeeds.com>
|
X-Comments: | This message was posted through Newsfeeds.com
|
X-Comments2: | IMPORTANT: Newsfeeds.com does not condone, nor support, spam or any illegal or copyrighted postings.
|
X-Comments3: | IMPORTANT: Under NO circumstances will postings containing illegal or copyrighted material through this service be tolerated!!
|
X-Report: | Please report illegal or inappropriate use to <abuse AT newsfeeds DOT com> You may also use our online abuse reporting from: http://www.newsfeeds.com/abuseform.htm
|
X-Abuse-Info: | Please be sure to forward a copy of ALL headers, INCLUDING the body (DO NOT SEND ATTACHMENTS)
|
Organization: | Newsfeeds.com http://www.newsfeeds.com 73,000+ UNCENSORED Newsgroups.
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
"Ivan Ferrara" <ifalpsfun AT inwind DOT it> wrote in message
news:39C9617E DOT A5EDE2E8 AT inwind DOT it...
> I finally solved my DPMI memory error (thanks to Martin!!!), but a new
> problem occurred.
> I'm trying to draw 3D polygons using allegro functions.
Jumping right into 3D, eh? ;)
> Here's a piece of code; It should draw a shaded triangle but my screen
> looks white! Why
Because your missing some steps. As I've learned myself lately, 3D is far
more complicated than that:
>
>
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////
>
>
>
>
> #include <allegro.h>
> #include <stdio.h>
> #include <stdlib.h>
>
>
> BITMAP *texture;
> V3D v1 = {30 , 20 , 10 , 0 , 0 , 9 };
> V3D v2 = {30 , 40 , 10 , 0 , 0 , 9 };
> V3D v3 = {30 , 30 , 80 , 0 , 0 , 9 };
These coordinates will put your triangle in the far lower-right of the
screen, to make it more visible try
V3D v1 = {20, 0, 128, 0, 0, 9};
V3D v2 = {-25, -10, 140, 0, 0, 9};
V3D v3 = {-10, 20, 120, 0, 0, 9};
> int main()
> {
> allegro_init();
> install_keyboard();
> set_gfx_mode(GFX_AUTODETECT,800,600,0,0);
> set_palette(desktop_palette);
>
> triangle3d(screen,POLYTYPE_FLAT,texture,&v1,&v2,&v3);
Sorry, you can't just skip to that :). I'm not sure if it's mandatory, but
you should call
set_projection_viewport(0, 0, 800, 600);
Then - and this is the crucial part - you have to convert the 3D coordinates
to 2D ones (a monitor is 2D, not 3D, right?)
persp_project(v1.x, v1.y, v1.z, &v1.x, &v1.y);
persp_project(v2.x, v2.y, v2.z, &v2.x, &v2.y);
persp_project(v3.x, v3.y, v3.z, &v3.x, &v3.y);
NOW you can call
triangle3d(screen, POLYTYPE_FLAT, NULL, &v1, &v2, &v3);
I haven't tested this, but it should work. Also keep in mind it is a VERY
sloppy way to do 3D; fine to make a triangle, totally unfeasible for any
real application. Spend much time studying Allegro's 3D samples, and a LOT
of time on 3D web tutorials to understand the basics (which you obviously
don't yet). Learning 3D takes a major comitment.......
Chris
- Raw text -