Function:ns2vf4xt

From S2PLOT

Jump to: navigation, search

ns2vf4xt

Draw a textured 4-vertex facet with alpha channel using a texture id.

Prototype

void ns2vf4xt(XYZ *P, COLOUR icol, unsigned int textureid, float iscale, char itrans, float ialpha);

Description

Draw a textured 4-vertex facet, using a texture id as returned by ss2lt; scale should be in the range [0,1] and trans = 'o' or 't' for opaque or transparent textures. The alpha channel is set by parameter ialpha.

See Also

Textures Important information on using textures in S2PLOT.
ss2lt Load a texture for future (generally repeated) use.
ns2vf4x Draw a textured 4-vertex facet using a texture id.
ns2vf4t Textured 4-vertex facet, scale in [0,1]; trans = 'o' or 't'.
struct_COLOUR Data structure for (r,g,b) colour indices.
struct_XYZ Data structure for (x,y,z) coordinates.


Code Example

#include <stdio.h>
#include <stdlib.h>
#include "s2plot.h"

int main(int argc, char *argv[])
{
   XYZ vertex[4];				/* 4 vertices */
   COLOUR col = { 1.0, 0.0, 1.0 };		/* Yellowish */
   float scale = 1.0;				/* Scale for texture */
   float ialpha = 0.5;				/* Alpha channel */
   int texid;					/* ID for this texture */
   char *texture = "firetile2_pow2_rgb.tga";	
		/* Texture in directory pointed to by S2PLOT_TEXPATH */ 

   s2opend("/?",argc, argv);			/* Open the display */
   s2swin(-1.,1., -1.,1., -1.,1.);		/* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);	/* Draw coordinate box */

   texid = ss2lt(texture);
   vertex[0].x = 0.0; vertex[0].y =  0.0; vertex[0].z = 0.0;
   vertex[1].x = 0.5; vertex[1].y =  0.0; vertex[1].z = 0.0;
   vertex[2].x = 0.5; vertex[2].y = -0.4; vertex[2].z = 1.0;
   vertex[3].x = 0.0; vertex[3].y = -0.4; vertex[3].z = 1.0;

   ns2vf4xt(vertex, col, texid, scale, 'o', ialpha); 	
						/* Draw the polygon */

   s2show(1);					/* Open the s2plot window */
   
   return 1;
}

Back to S2PLOT function list.


Personal tools