Transparency Problem

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
User avatar
BB Hood
DC Developer
DC Developer
Posts: 189
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Fri Mar 30, 2007 12:09 am
Has thanked: 41 times
Been thanked: 10 times

Transparency Problem

Post by BB Hood »

I'm trying to port the NeHe OpenGL lessons to Dreamcast using the PLX (Parallax) library located in kos-ports. For NeHe lesson 8 (Blending: http://nehe.gamedev.net/data/lessons/le ... ?lesson=08) I have to get a cube to be transparent. The problem that I am having is that which ever face of the cube I draw first is not transparent which is weird. Can you guys see anything wrong with this code?:

Code: Select all

#include <kos.h>
#include <plx/prim.h>
#include <plx/matrix.h>
#include <plx/context.h>
#include <plx/texture.h>

extern uint8 romdisk[];
KOS_INIT_FLAGS(INIT_DEFAULT | INIT_MALLOCSTATS);
KOS_INIT_ROMDISK(romdisk);

void printControls() {
    printf("\n/**********Controls**********/\n");
    printf("START-Button: Exits program\n");
    printf("X-Button: Toggle filtering \n");
    printf("Y-Button: Toggle blending\n");
    printf("A-Button: Move the cube into the distance \n");
    printf("B-Button: Move the cube closer \n");
    
    printf("UP-Dir: Decrease x rotation speed \n");
    printf("DOWN-Dir: Increase x rotation speed \n");
    printf("LEFT-Dir: Decrease y rotation speed \n");
    printf("RIGHT-Dir: Increase y rotation speed \n");
    printf("/****************************/\n\n");
}

/**
  Like plx_vert_ifdm3, but uses plx_prim.
 */
static inline void plx_vert_ifpm3(int flags, float x, float y, float z, uint32 color, float u, float v) {
	plx_mat_tfip_3d(x, y, z);
	plx_vert_ifp(flags, x, y, z, color, u, v);
}

pvr_init_params_t params = {
	/* Enable opaque and translucent polygons with size 16 */
	{ PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_0 },
	
	/* Vertex buffer size 512K */
	512*1024
};

int main(int argc, char **argv) {
    
    /* Controller Stuff */
    uint8 c;
    cont_cond_t cond;
    int xp = 0;    // False (True or False: Pressed X button last) Toggles Filtering
    int yp = 0;    // False (True or False: Pressed Y button last) Toggles Transparency
    int blend = 0; // False (True or False: Blending)
    
    /* Rotation and depth into screen */
    float xrot = 0;   // x rotation 
    float yrot = 0;   // y rotation 
    float xspeed = 0; // x rotation speed
    float yspeed = 0; // y rotation speed
    float z = -5.0f;  // depth into the screen.
    
    int filter = 0; // Start with no filtering
    uint32 color = plx_pack_color(0.5f, 1.0f, 1.0f, 1.0f); // plx_pack_color(a, r, g, b) a = 0.5 meaning it is see through
    plx_texture_t *textures[2];  /* Array of pointers to plx_texture(Holds two textures) */
    
	/* Init PVR API */
	if (pvr_init(&params) < 0)
		return -1;
	
	printControls();

        /* Sets the background color to black */
	pvr_set_bg_color(0.0f, 0.0f, 0.0f);
	
	/* Load the textures */
	textures[0] = plx_txr_load("/rd/glass.png", 0, PVR_TXRLOAD_16BPP);  
	textures[1] = plx_txr_load("/rd/glass.png", 0, PVR_TXRLOAD_16BPP);  

	plx_cxt_init();                   // Initialize the plx context system
        plx_cxt_culling(PLX_CULL_NONE);   // No culling
	
	// GET SOME 3D GOING!!
	plx_mat3d_init();                    /* Clear internal to an identity matrix */
	plx_mat3d_mode(PLX_MAT_PROJECTION);  /** Projection (frustum, screenview) matrix */
	plx_mat3d_identity();                /** Load an identity matrix */
	plx_mat3d_perspective(45.0f, 640.0f / 480.0f, 0.1f, 1000.0f);  // (float angle, float aspect, float znear, float zfar);
	plx_mat3d_mode(PLX_MAT_MODELVIEW);   /** Modelview (rotate, scale) matrix */
	
	/* Set the filtering for each texture */
	plx_txr_setfilter(textures[0], PLX_FILTER_NONE);
	plx_txr_setfilter(textures[1], PLX_FILTER_BILINEAR);
	
	c = maple_first_controller();
	
	while(1) {
        
        /* Check key status */
		if (cont_get_cond(c, &cond) < 0) {
			printf("Error reading controller\n");
			break;
		}
		if (!(cond.buttons & CONT_START))
			     break;           // exit the program
		if (!(cond.buttons & CONT_A))
			     z -= 0.02f;      // move the cube into the distance.
		if (!(cond.buttons & CONT_B))
			     z += 0.02f;      // move the cube closer.
		if (!(cond.buttons & CONT_X) && !xp) {
			     xp = 1;           
			     filter += 1;     // Toggle Filter 
			     if (filter > 1)
				     filter = 0;
		}
		if (cond.buttons & CONT_X)
			     xp = 0;
		if (!(cond.buttons & CONT_Y) && !yp) {
			     yp = 1;
			     blend = !blend;  // Toggle Blending
		}
		if (cond.buttons & CONT_Y)
			     yp = 0;
		if (!(cond.buttons & CONT_DPAD_UP))
			     xspeed -= 0.01f; // decrease x rotation speed
		if (!(cond.buttons & CONT_DPAD_DOWN))
			     xspeed += 0.01f; // increase x rotation speed   
		if (!(cond.buttons & CONT_DPAD_LEFT))
			     yspeed -= 0.01f; // decrease y rotation speed
		if (!(cond.buttons & CONT_DPAD_RIGHT))
			     yspeed += 0.01f; // increase y rotation speed	  
			     
		// Texture 'textures[filter]' will be used with the context system.  Depends on which filter is selected.    
        plx_cxt_texture(textures[filter]);  	     
                 
		pvr_wait_ready();
		pvr_scene_begin();
		
		if(blend) {
          plx_list_begin(PLX_LIST_TR_POLY);
          plx_cxt_blending(PLX_BLEND_SRCALPHA, PLX_BLEND_INVSRCALPHA);
          plx_cxt_send(PLX_LIST_TR_POLY);
        }
        else {
          plx_list_begin(PLX_LIST_OP_POLY);
          plx_cxt_blending(PLX_BLEND_ONE, PLX_BLEND_ZERO);
          plx_cxt_send(PLX_LIST_OP_POLY);
        }
  
        // DRAW THE BOX	
        plx_mat3d_identity();
	    plx_mat3d_translate(0.0f, 0.0f, z);        // Move Z units into/outof the screen
	    plx_mat3d_rotate(xrot, 1.0f, 0.0f, 0.0f);  // Rotate the BOX angle 'xrot' on the X axis   
	    plx_mat3d_rotate(yrot, 0.0f, 1.0f, 0.0f);  // Rotate the BOX angle 'yrot' on the Y axis
	    
  	    /* Clear internal to an identity matrix */
	    plx_mat_identity();
      
    	/* "Applying" all matrixs: multiply a matrix onto the "internal" one */
	    plx_mat3d_apply_all();    
	    
	    // Top Face of Box 
		plx_vert_ifpm3(PLX_VERT, -1, 1, 1, color, 0, 1);     // Bottom Left Of The Quad (Top)
		plx_vert_ifpm3(PLX_VERT, -1, 1, -1, color, 0, 0);    // Top Left Of The Quad (Top)
		plx_vert_ifpm3(PLX_VERT, 1, 1, 1, color, 1, 1);      // Bottom Right Of The Quad (Top)
		plx_vert_ifpm3(PLX_VERT_EOS, 1, 1, -1, color, 1, 0); // Top Right Of The Quad (Top)
	    
		// Bottom Face of Box 
		plx_vert_ifpm3(PLX_VERT, -1, -1, -1, color, 0, 1);   // Bottom Left Of The Quad (Bottom)
		plx_vert_ifpm3(PLX_VERT, -1, -1, 1, color, 0, 0);    // Top Left Of The Quad (Bottom)
		plx_vert_ifpm3(PLX_VERT, 1, -1, -1, color, 1, 1);    // Bottom Right Of The Quad (Bottom)
		plx_vert_ifpm3(PLX_VERT_EOS, 1, -1, 1, color, 1, 0); // Top Right Of The Quad (Bottom)	    
		
		// Front Face of Box 
		plx_vert_ifpm3(PLX_VERT, -1, -1, 1, color, 0, 1);    // Bottom Left Of The Quad (Front)
	    plx_vert_ifpm3(PLX_VERT, -1, 1, 1, color, 0, 0);     // Top Left Of The Quad (Front)
	    plx_vert_ifpm3(PLX_VERT, 1, -1, 1, color, 1, 1);     // Bottom Right Of The Quad (Front)
	    plx_vert_ifpm3(PLX_VERT_EOS, 1, 1, 1, color, 1, 0);  // Top Right Of The Quad (Front)
		
		// Back Face of Box 
		plx_vert_ifpm3(PLX_VERT, -1, 1, -1, color, 0, 1);    // Bottom Left Of The Quad (Back)
	    plx_vert_ifpm3(PLX_VERT, -1, -1, -1, color, 0, 0);   // Top Left Of The Quad (Back)
	    plx_vert_ifpm3(PLX_VERT, 1, 1, -1, color, 1, 1);     // Bottom Right Of The Quad (Back)
		plx_vert_ifpm3(PLX_VERT_EOS, 1, -1, -1, color, 1, 0);// Top Right Of The Quad (Back)
		
		// Left Face of Box 
		plx_vert_ifpm3(PLX_VERT, -1, -1, -1, color, 0, 1);   // Bottom Left Of The Quad (Left)
	    plx_vert_ifpm3(PLX_VERT, -1, 1, -1, color, 0, 0);    // Top Left Of The Quad (Left)
	    plx_vert_ifpm3(PLX_VERT, -1, -1, 1, color, 1, 1);    // Bottom Right Of The Quad (Left)
	    plx_vert_ifpm3(PLX_VERT_EOS, -1, 1, 1, color, 1, 0); // Top Right Of The Quad (Left)
	    
		// Right Face of Box 
		plx_vert_ifpm3(PLX_VERT, 1, -1, 1, color, 0, 1);     // Bottom Left Of The Quad (Right)
	    plx_vert_ifpm3(PLX_VERT, 1, 1, 1, color, 0, 0);      // Top Left Of The Quad (Right)
	    plx_vert_ifpm3(PLX_VERT, 1, -1, -1, color, 1, 1);    // Bottom Right Of The Quad (Right)
	    plx_vert_ifpm3(PLX_VERT_EOS, 1, 1, -1, color, 1, 0); // Top Right Of The Quad (Right)

		pvr_scene_finish();
		
		xrot += xspeed;   // Increase box's X Axis Rotation	
        yrot += yspeed;	  // Increase box's Y Axis Rotation
    }
    // Clean UP!!!
    plx_txr_destroy(textures[0]);
    plx_txr_destroy(textures[1]);

	return 0;
}
Since I draw the Top Face of Box first, when transparency is enabled it is still has no transparency but all the other faces of the box do.
Last edited by BB Hood on Sat Jul 17, 2010 12:18 pm, edited 4 times in total.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Transparency Problem

Post by BlueCrab »

You never set the blending mode of the context before you send it. Thus, the defaults happen, which isn't what you want in translucent mode. Take your if(blend) statement, and modify it a bit (I haven't tested this myself, but I think (in my current, sleep-deprived state) that it should work):

Code: Select all

        if(blend) {
          plx_list_begin(PLX_LIST_TR_POLY);
          plx_cxt_blending(PLX_BLEND_SRCALPHA, PLX_BLEND_INVSRCALPHA);
          plx_cxt_send(PLX_LIST_TR_POLY);
        }
        else {
          plx_list_begin(PLX_LIST_OP_POLY);
          plx_cxt_blending(PLX_BLEND_ONE, PLX_BLEND_ZERO);
          plx_cxt_send(PLX_LIST_OP_POLY);
        }
I've also touched up a few other things in there, like the fact that you probably shouldn't mix the pvr_ and plx_ stuff together, since the plx_ stuff is just a thin wrapper anyway (and that way, if plx were to be changed in some way, you'd be protected against said changes that way, in theory). Also, to grab the PLX_LIST_ stuff, you'll need to #include <plx/list.h> .

Also, instead of:

Code: Select all

pvr_wait_ready();
pvr_scene_begin();
use plx_scene_begin(). Likewise, instead of pvr_scene_finish(), use plx_scene_finish(). Oh yeah, and the default bg color is black already, so you don't technically need the pvr_set_bgcolor().
User avatar
BB Hood
DC Developer
DC Developer
Posts: 189
Joined: Fri Mar 30, 2007 12:09 am
Has thanked: 41 times
Been thanked: 10 times

Re: Transparency Problem

Post by BB Hood »

I thought of that blending mode of the context already. I think there might be a bug in the PLX library because by default the plx library creates it's context by the pvr_poly_cxt_col(pvr_poly_cxt_t *dst, pvr_list_t list) function which does this:

Code: Select all

dst->blend.src_enable = PVR_BLEND_DISABLE;
dst->blend.dst_enable = PVR_BLEND_DISABLE;
so I changed the plx_cxt_blending() to:

Code: Select all

void plx_cxt_blending(int src, int dst) {
	cxt_working.blend.src = src;
	cxt_working.blend.dst = dst;
	cxt_working.blend.src_enable = PVR_BLEND_ENABLE;
	cxt_working.blend.dst_enable = PVR_BLEND_ENABLE;

	compile_cxts();
}
from:

Code: Select all

void plx_cxt_blending(int src, int dst) {
	cxt_working.blend.src = src;
	cxt_working.blend.dst = dst;

	compile_cxts();
}
and used the settings found in the OpenGL port:
plx_cxt_blending(PLX_BLEND_SRCALPHA, PLX_BLEND_ONE); but it still didn't work...:^(

I also tried what you said and it still didn't work. I know the background is still black by default I just put it there by force of habit. Thanks for the help. I just don't get why one face of the box is not transparent why the rest is...just doesn't make sense.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Transparency Problem

Post by BlueCrab »

BB Hood wrote:I thought of that blending mode of the context already. I think there might be a bug in the PLX library because by default the plx library creates it's context by the pvr_poly_cxt_col(pvr_poly_cxt_t *dst, pvr_list_t list) function which does this:

Code: Select all

dst->blend.src_enable = PVR_BLEND_DISABLE;
dst->blend.dst_enable = PVR_BLEND_DISABLE;
so I changed the plx_cxt_blending() to:

Code: Select all

void plx_cxt_blending(int src, int dst) {
	cxt_working.blend.src = src;
	cxt_working.blend.dst = dst;
	cxt_working.blend.src_enable = PVR_BLEND_ENABLE;
	cxt_working.blend.dst_enable = PVR_BLEND_ENABLE;

	compile_cxts();
}
from:

Code: Select all

void plx_cxt_blending(int src, int dst) {
	cxt_working.blend.src = src;
	cxt_working.blend.dst = dst;

	compile_cxts();
}
You definitely shouldn't need to do that. I don't think I've ever touched the blend.src_enable and blend.dst_enable, and its always "just worked". That, and I know that at some point (a long time ago) I used the plx sprite stuff with no problems with blending.
and used the settings found in the OpenGL port:
plx_cxt_blending(PLX_BLEND_SRCALPHA, PLX_BLEND_ONE); but it still didn't work...:^(

I also tried what you said and it still didn't work. I know the background is still black by default I just put it there by force of habit. Thanks for the help. I just don't get why one face of the box is not transparent why the rest is...just doesn't make sense.
Hmm... now that I'm looking more heavily at it, I think I might have an idea...

Instead of using the plx_cxt_ (so comment out any calls to any plx_cxt_* stuff) stuff, try this:

Code: Select all

if(blend) {
    plx_list_begin(PLX_LIST_TR_POLY);
    plx_txr_send_hdr(textures[filter], PLX_LIST_TR_POLY, 0);
}
else {
    plx_list_begin(PLX_LIST_OP_POLY);
    plx_txr_send_hdr(textures[filter], PLX_LIST_OP_POLY, 0);
}
User avatar
BB Hood
DC Developer
DC Developer
Posts: 189
Joined: Fri Mar 30, 2007 12:09 am
Has thanked: 41 times
Been thanked: 10 times

Re: Transparency Problem

Post by BB Hood »

Tried it and it just darkens the textures when I enable blending. No transparency occurs at all for any face of the box.

I ported some drawables from Feet of Fury for Tsunami a while back including the Cube drawable. Blending works fine with it and I don't even have to do any of the "plx_cxt_blending(blah, blah);" stuff. I followed the same procedure included in that drawable and it still doesn't work....I give up. Thanks again for your help.

Just a note to anybody else reading this, you can download the PLX conversion of the NeHe tutorials here: http://sourceforge.net/projects/parallaxnehe/files/

I also updated DCMappy: http://sourceforge.net/projects/dcmappy/

- Now supports 24 bbp, and 32 bbp maps as well as 8 bbp and 16 bbp (like it did before).
- Also supports color keying with a color of your choice.
- Only supports FMP ver 0.5 and still no hexagonal or isometric map support.
Oh and you can load up to 4 different 8 bbp at once. Its limited because of the number of palette entries in the Dreamcast(using PVR_PAL_ARGB8888).
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Transparency Problem

Post by BlueCrab »

So... here's a working version (I just tested it):

Code: Select all

#include <kos.h>
#include <plx/dr.h>
#include <plx/list.h>
#include <plx/prim.h>
#include <plx/matrix.h>
#include <plx/context.h>
#include <plx/texture.h>

extern uint8 romdisk[];
KOS_INIT_FLAGS(INIT_DEFAULT | INIT_MALLOCSTATS);
KOS_INIT_ROMDISK(romdisk);

void printControls() {
    printf("\n/**********Controls**********/\n");
    printf("START-Button: Exits program\n");
    printf("X-Button: Toggle filtering \n");
    printf("Y-Button: Toggle blending\n");
    printf("A-Button: Move the cube into the distance \n");
    printf("B-Button: Move the cube closer \n");
    
    printf("UP-Dir: Decrease x rotation speed \n");
    printf("DOWN-Dir: Increase x rotation speed \n");
    printf("LEFT-Dir: Decrease y rotation speed \n");
    printf("RIGHT-Dir: Increase y rotation speed \n");
    printf("/****************************/\n\n");
}

/**
  Like plx_vert_ifdm3, but uses plx_prim.
 */
static inline void plx_vert_ifpm3(int flags, float x, float y, float z, uint32 color, float u, float v) {
	plx_mat_tfip_3d(x, y, z);
	plx_vert_ifp(flags, x, y, z, color, u, v);
}

pvr_init_params_t params = {
	/* Enable opaque and translucent polygons with size 16 */
	{ PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_0 },
	
	/* Vertex buffer size 512K */
	512*1024
};

int main(int argc, char **argv) {
    
    /* Controller Stuff */
    uint8 c;
    cont_cond_t cond;
    int xp = 0;    // False (True or False: Pressed X button last) Toggles Filtering
    int yp = 0;    // False (True or False: Pressed Y button last) Toggles Transparency
    int blend = 0; // False (True or False: Blending)
    
    /* Rotation and depth into screen */
    float xrot = 0;   // x rotation 
    float yrot = 0;   // y rotation 
    float xspeed = 0; // x rotation speed
    float yspeed = 0; // y rotation speed
    float z = -5.0f;  // depth into the screen.
    
    int filter = 0; // Start with no filtering
    uint32 color = plx_pack_color(0.5f, 1.0f, 1.0f, 1.0f); // plx_pack_color(a, r, g, b) a = 0.5 meaning it is see through
    plx_texture_t *textures[2];  /* Array of pointers to plx_texture(Holds two textures) */
    
	/* Init PVR API */
	if (pvr_init(&params) < 0)
		return -1;
	
	printControls();

    /* Sets the background color to black */
	pvr_set_bg_color(0.0f, 0.0f, 0.0f);
	
	/* Load the textures */
	textures[0] = plx_txr_load("/rd/glass.png", 0, PVR_TXRLOAD_16BPP);  
	textures[1] = plx_txr_load("/rd/glass.png", 0, PVR_TXRLOAD_16BPP);  

	plx_cxt_init();                   // Initialize the plx context system
	
	// GET SOME 3D GOING!!
	plx_mat3d_init();                    /* Clear internal to an identity matrix */
	plx_mat3d_mode(PLX_MAT_PROJECTION);  /** Projection (frustum, screenview) matrix */
	plx_mat3d_identity();                /** Load an identity matrix */
	plx_mat3d_perspective(45.0f, 640.0f / 480.0f, 0.1f, 1000.0f);  // (float angle, float aspect, float znear, float zfar);
	plx_mat3d_mode(PLX_MAT_MODELVIEW);   /** Modelview (rotate, scale) matrix */
	
	/* Set the filtering for each texture */
	plx_txr_setfilter(textures[0], PLX_FILTER_NONE);
	plx_txr_setfilter(textures[1], PLX_FILTER_BILINEAR);

    /* Disable culling on translucent polygons */
    textures[0]->cxt_trans.gen.culling = PLX_CULL_NONE;
    textures[1]->cxt_trans.gen.culling = PLX_CULL_NONE;
    plx_txr_flush_hdrs(textures[0]);
    plx_txr_flush_hdrs(textures[1]);
	
	c = maple_first_controller();
	
	while(1) {
        
        /* Check key status */
		if (cont_get_cond(c, &cond) < 0) {
			printf("Error reading controller\n");
			break;
		}
		if (!(cond.buttons & CONT_START))
			     break;           // exit the program
		if (!(cond.buttons & CONT_A))
			     z -= 0.02f;      // move the cube into the distance.
		if (!(cond.buttons & CONT_B))
			     z += 0.02f;      // move the cube closer.
		if (!(cond.buttons & CONT_X) && !xp) {
			     xp = 1;           
			     filter += 1;     // Toggle Filter 
			     if (filter > 1)
				     filter = 0;
		}
		if (cond.buttons & CONT_X)
			     xp = 0;
		if (!(cond.buttons & CONT_Y) && !yp) {
			     yp = 1;
			     blend = !blend;  // Toggle Blending
		}
		if (cond.buttons & CONT_Y)
			     yp = 0;
		if (!(cond.buttons & CONT_DPAD_UP))
			     xspeed -= 0.01f; // decrease x rotation speed
		if (!(cond.buttons & CONT_DPAD_DOWN))
			     xspeed += 0.01f; // increase x rotation speed   
		if (!(cond.buttons & CONT_DPAD_LEFT))
			     yspeed -= 0.01f; // decrease y rotation speed
		if (!(cond.buttons & CONT_DPAD_RIGHT))
			     yspeed += 0.01f; // increase y rotation speed 	     
                 
		plx_scene_begin();
		
		if(blend) {
          plx_list_begin(PVR_LIST_TR_POLY);
          plx_txr_send_hdr(textures[filter], PLX_LIST_TR_POLY, 0); 
        }
        else {
          plx_list_begin(PVR_LIST_OP_POLY);
          plx_txr_send_hdr(textures[filter], PLX_LIST_OP_POLY, 0);
        }  
  
        // DRAW THE BOX	
        plx_mat3d_identity();
	    plx_mat3d_translate(0.0f, 0.0f, z);        // Move Z units into/outof the screen
	    plx_mat3d_rotate(xrot, 1.0f, 0.0f, 0.0f);  // Rotate the BOX angle 'xrot' on the X axis   
	    plx_mat3d_rotate(yrot, 0.0f, 1.0f, 0.0f);  // Rotate the BOX angle 'yrot' on the Y axis
	    
  	    /* Clear internal to an identity matrix */
	    plx_mat_identity();
      
    	/* "Applying" all matrixs: multiply a matrix onto the "internal" one */
	    plx_mat3d_apply_all();    
	    
	    // Front Face of Box 
		plx_vert_ifpm3(PLX_VERT, -1, -1, 1, color, 0, 1);    // Bottom Left Of The Quad (Front)
	    plx_vert_ifpm3(PLX_VERT, -1, 1, 1, color, 0, 0);     // Top Left Of The Quad (Front)
	    plx_vert_ifpm3(PLX_VERT, 1, -1, 1, color, 1, 1);     // Bottom Right Of The Quad (Front)
	    plx_vert_ifpm3(PLX_VERT_EOS, 1, 1, 1, color, 1, 0);  // Top Right Of The Quad (Front)
		
		// Back Face of Box 
		plx_vert_ifpm3(PLX_VERT, -1, 1, -1, color, 0, 1);    // Bottom Left Of The Quad (Back)
	    plx_vert_ifpm3(PLX_VERT, -1, -1, -1, color, 0, 0);   // Top Left Of The Quad (Back)
	    plx_vert_ifpm3(PLX_VERT, 1, 1, -1, color, 1, 1);     // Bottom Right Of The Quad (Back)
		plx_vert_ifpm3(PLX_VERT_EOS, 1, -1, -1, color, 1, 0);// Top Right Of The Quad (Back)
	    
	    // Top Face of Box 
		plx_vert_ifpm3(PLX_VERT, -1, 1, 1, color, 0, 1);     // Bottom Left Of The Quad (Top)
		plx_vert_ifpm3(PLX_VERT, -1, 1, -1, color, 0, 0);    // Top Left Of The Quad (Top)
		plx_vert_ifpm3(PLX_VERT, 1, 1, 1, color, 1, 1);      // Bottom Right Of The Quad (Top)
		plx_vert_ifpm3(PLX_VERT_EOS, 1, 1, -1, color, 1, 0); // Top Right Of The Quad (Top)
	    
		// Bottom Face of Box 
		plx_vert_ifpm3(PLX_VERT, -1, -1, -1, color, 0, 1);   // Bottom Left Of The Quad (Bottom)
		plx_vert_ifpm3(PLX_VERT, -1, -1, 1, color, 0, 0);    // Top Left Of The Quad (Bottom)
		plx_vert_ifpm3(PLX_VERT, 1, -1, -1, color, 1, 1);    // Bottom Right Of The Quad (Bottom)
		plx_vert_ifpm3(PLX_VERT_EOS, 1, -1, 1, color, 1, 0); // Top Right Of The Quad (Bottom)	    
		
		// Right Face of Box 
		plx_vert_ifpm3(PLX_VERT, 1, -1, 1, color, 0, 1);     // Bottom Left Of The Quad (Right)
	    plx_vert_ifpm3(PLX_VERT, 1, 1, 1, color, 0, 0);      // Top Left Of The Quad (Right)
	    plx_vert_ifpm3(PLX_VERT, 1, -1, -1, color, 1, 1);    // Bottom Right Of The Quad (Right)
	    plx_vert_ifpm3(PLX_VERT_EOS, 1, 1, -1, color, 1, 0); // Top Right Of The Quad (Right)
		
		// Left Face of Box 
		plx_vert_ifpm3(PLX_VERT, -1, -1, -1, color, 0, 1);   // Bottom Left Of The Quad (Left)
	    plx_vert_ifpm3(PLX_VERT, -1, 1, -1, color, 0, 0);    // Top Left Of The Quad (Left)
	    plx_vert_ifpm3(PLX_VERT, -1, -1, 1, color, 1, 1);    // Bottom Right Of The Quad (Left)
	    plx_vert_ifpm3(PLX_VERT_EOS, -1, 1, 1, color, 1, 0); // Top Right Of The Quad (Left)
	    
		plx_scene_end();
		
		xrot += xspeed;   // Increase box's X Axis Rotation	
        yrot += yspeed;	  // Increase box's Y Axis Rotation
    }
    // Clean UP!!!
    plx_txr_destroy(textures[0]);
    plx_txr_destroy(textures[1]);

	return 0;
}
Oh yeah, and one comment about all of that. If you're going to be doing example code, please don't use the deprecated maple functions (maple_first_controller and cont_get_cond), use the newer (and more sane) maple_enum_type and maple_dev_status functions instead. The deprecated functions will be removed at some point in the near future, and I'd hate to see your examples stop working when that happens. All of the examples in KOS have been updated to use the newer functions for a while now, so it should be pretty easy to figure them out.
User avatar
BB Hood
DC Developer
DC Developer
Posts: 189
Joined: Fri Mar 30, 2007 12:09 am
Has thanked: 41 times
Been thanked: 10 times

Re: Transparency Problem

Post by BB Hood »

You tested that on a dreamcast didn't you? If so I feel bad. I've been using NullDC to test. Too lazy to get my Dreamcast and hook it up.

I just tested it right now the way I originally had it and it works on Dreamcast. I'm really sorry for wasting your time dude. I'll test on the Dreamcast from now on before posting.

Thanks for the heads up about the maple stuff.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Transparency Problem

Post by BlueCrab »

BB Hood wrote:You tested that on a dreamcast didn't you? If so I feel bad. I've been using NullDC to test. Too lazy to get my Dreamcast and hook it up.

I just tested it right now the way I originally had it and it works on Dreamcast. I'm really sorry for wasting your time dude. I'll test on the Dreamcast from now on before posting.

Thanks for the heads up about the maple stuff.
There's a reason I say never to test things on an emulator :wink:. They always have their own set of bugs to deal with.

That said, I think the way I put it there is a bit more clean than the way you were doing it originally... Also, it got me to actually take a good look at KOS for the first time in a while, so its not really a waste. :lol:
Post Reply