delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/29/18:33:27

From: T DOT Harte AT bigfoot DOT com (Thomas Harte)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: textures in Allegro
Date: Mon, 29 Dec 1997 23:21:55 GMT
Organization: BT Internet
Lines: 54
Message-ID: <34a8287b.2884187@news.btinternet.com>
References: <34a7b546 DOT 8281377 AT news DOT klippan DOT se>
NNTP-Posting-Host: host5-99-62-217.btinternet.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Okay,

	a couple of things. Firstly, this bit :

>	texture = load_bitmap("3d_test.pcx", newpal);
>// "3d_test.pcx" is a 99x99x256 image

	The dimensions of the image HAVE to be a power of 2. Try loading
your image into some art package, and resizing it to 128x128 or
something (the closest power of 2 to 99 that is larger than 99).

	Secondly :

>	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;

	Here you are telling it to stretch the texture over the polygon
so that each corner is at position 0,0 on the texture map. Or, you would
be if you were doing :

	v3d[0].u = v3d[0].v = v3d[1].u = v3d[1].v =
		v3d[2].u = v3d[2].v = v3d[3].u = v3d[3].v = 0;

	anyway. If your polygon is defined with the points arranged :

			0	1
			3	2

	then set 0 to low u and v, 1 to high u, low v,  2 to high u and
v, and 3 to low u, high v. Or something like that.

	Now, one last thing. You are doing :

>	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;

	remember, you have defined these are _fixed point_ numbers. If
you just want a polygon that fills the screen, set

	v3d[0].x = ftofix(0); v3d[0].y = ftofix(0);
	v3d[1].x = ftofix(SCREEN_W0; v3d[1].y = ftofix(0);
	v3d[2].x = ftofix(SCREEN_W); v3d[2].y = ftofix(SCREEN_H);
	v3d[3].x = ftofix(0); v3d[3].y = ftofix(SCREEN_H);

	ignore the z component, and use affine texturing. If you want to
start having placing things in a 3d world, you need to define some
structures and stuff so that you also have a list of V3D's to project
your points into (ie convert them to screen space). Too much to explain
here. If I knew any of the games you referred to, I might be able to
help more.

		-Thomas

- Raw text -


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