delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/29/10:45:29

From: nv95olbj AT klippan DOT se (Olof Bjarnason)
Newsgroups: comp.os.msdos.djgpp
Subject: textures in Allegro
Date: Mon, 29 Dec 1997 14:47:32 GMT
Organization: Klippans Gymnasieskola, Sweden
Lines: 53
Message-ID: <34a7b7c8.8924245@news.klippan.se>
Reply-To: nv95olbj AT klippan DOT se
NNTP-Posting-Host: ppp205.klippan.se
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I just wondered if anyone could help me on a little problem with
Allegro's texture handling. It would be very appreciated :).

I am trying to build a 3d-graphics game a la BlackCrypt/Eye of the
Beholder/Hired Guns and to generate the block-textures I want to use
Allegro's polygon3d() function. The problem is: I don't get
polygon3d() to work :(. Please, could you tell me what is wrong with
this code.

/**** 3d_test.c ****/
#include <stdio.h>
#include <allegro.h>

BITMAP *texture;
V3D v3d[4];

int main(void)
{
	PALETTE newpal;
	int ad = 5, i;	
	char buf[80];
	
	allegro_init();
	install_keyboard();
	v3d[0].x = 0xFFFFFF; v3d[0].y = 0xFFFFFF; v3d[0].z = 170;
	v3d[1].x = 0x1FFFFFF; v3d[1].y = 0xFFFFFF; v3d[1].z = 170;
	v3d[2].x = 0x1FFFFFF; v3d[2].y = 0x1FFFFFF; v3d[2].z = 170;
	v3d[3].x = 0xFFFFFF; v3d[3].y = 0x1FFFFFF; v3d[3].z = 170;
	v3d[0].u = v3d[0].v = v3d[0].u = v3d[0].v =
		v3d[0].u = v3d[0].v = v3d[0].u = v3d[0].v = 0;
	texture = load_bitmap("3d_test.pcx", newpal);
// "3d_test.pcx" is a 99x99 8bit image
	if(!texture) exit(1);
	set_gfx_mode(GFX_VESA1, 640, 480, 0, 0);
	clear(screen);
	set_palette(newpal);
	vsync();
	set_projection_viewport(0, 0, 640, 480);
	quad3d(screen, POLYTYPE_PTEX, texture, &v3d[0], &v3d[1],
&v3d[2], &v3d[3]);
// will only produce a only-colored polygon!
	readkey();
	destroy_bitmap(texture);
}
/********/

How are the Z-coordinates measured? Not as the X- and Y-coordinates, I
figure at least (from checking EX22.C about polygon3d()).

Thankful for any help,


/Olof

- Raw text -


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