int Application5::Clean()
{
	/* 
	 * Clean up and exit 
	 */ 
	int	status = 0; 
	for (int i = 0; i < AAKERNEL_SIZE; i++)
	{
		status |= GzFreeRender(m_pRender[i]); 
		status |= GzFreeDisplay(m_pDisplay[i]);
	}
	status |= GzFreeDisplay(m_finalDisplay);
	if (status) 
		return(GZ_FAILURE); 
	else 
		return(GZ_SUCCESS);
}
int Application3::Clean()
{
	/*
	 * Clean up and exit
	 */
	int	status = 0;

	status |= GzFreeRender(m_pRender);
	status |= GzFreeDisplay(m_pDisplay);

	if (status)
		return(GZ_FAILURE);
	else
		return(GZ_SUCCESS);
}
int Application4::Clean()
{
	/* 
	 * Clean up and exit 
	 */ 
	int	status = 0; 
	int index = 0;
// ****************************************************************************************
//								START		HW6 CHANGE
// ****************************************************************************************
	for(index = 0; index < AAKERNEL_SIZE; index++){
		status |= GzFreeRender(m_pRender[index]); 
		status |= GzFreeDisplay(m_pDisplay[index]);
	}
// ****************************************************************************************
//								END			HW6 CHANGE
// ****************************************************************************************	
	if (status) 
		return(GZ_FAILURE); 
	else 
		return(GZ_SUCCESS);
}
Example #4
0
int GzFreeRender(GzRender *render)
{
/* 
-free all renderer resources
*/
	if (render == NULL) {
		return GZ_FAILURE;
	}
	//render->display == NULL;
	GzFreeDisplay(render->display);
	delete render->Ximage;
	//////render->Ximage = NULL;
	delete render->Xsp;
	//////render->Xsp = NULL
	delete render->camera.Xiw;
	delete render->camera.Xpi;
	delete render->camera.lookat;
	delete render->camera.position;
	delete render->camera.worldup;
	delete render;

	return GZ_SUCCESS;
}
Example #5
0
int Application1::Render() 
{
	int		i, j; 
	int		xRes, yRes, dispClass;	/* display parameters */ 
	int		status; 
 	 
	status = 0; 
 
	/* 
	 * initialize the display and the renderer 
	 */ 

	m_nWidth = 512;		// frame buffer and display width
	m_nHeight = 512;    // frame buffer and display height

	status |= GzNewFrameBuffer(&m_pFrameBuffer, m_nWidth, m_nHeight);

	status |= GzNewDisplay(&m_pDisplay, GZ_RGBAZ_DISPLAY, m_nWidth, m_nHeight); 
 
	status |= GzGetDisplayParams(m_pDisplay, &xRes, &yRes, &dispClass); 

	status |= GzInitDisplay(m_pDisplay);  /* init for new frame */
 
	if (status) exit(GZ_FAILURE); 
 
	// I/O File open

	FILE *infile;
	if( (infile = fopen( INFILE1 , "r" )) == NULL )
	{
         AfxMessageBox( "The input file was not opened\n" );
		 return GZ_FAILURE;
	}

	FILE *outfile;
	if( (outfile = fopen( OUTFILE1 , "wb" )) == NULL )
	{
         AfxMessageBox( "The output file was not opened\n" );
		 return GZ_FAILURE;
	}
	
	int	ulx, uly, lrx, lry, r, g, b;
	while( fscanf(infile, "%d %d %d %d %d %d %d", 
			&ulx, &uly, &lrx, &lry, &r, &g, &b) == 7) { 
		for (j = uly; j <= lry; j++) {
		  for (i = ulx; i <= lrx; i++) {
		    GzPutDisplay(m_pDisplay, i, j, r, g, b, 1, 0);
		  }
		}
	} 
	
	GzFlushDisplay2File(outfile, m_pDisplay); 	/* write out or update display to file*/
	GzFlushDisplay2FrameBuffer(m_pFrameBuffer, m_pDisplay);	// write out or update display to frame buffer
 
	/* 
	 * Clean up and exit 
	 */ 

	if( fclose( infile ) )
      AfxMessageBox( "The input file was not closed\n" );

	if( fclose( outfile ) )
      AfxMessageBox( "The output file was not closed\n" );

	status |= GzFreeDisplay(m_pDisplay); 
 
	if (status) 
		return(GZ_FAILURE); 
	else 
		return(GZ_SUCCESS); 

}
int Application2::Render() 
{
	GzToken		nameListTriangle[3]; 	/* vertex attribute names */
	GzPointer	valueListTriangle[3]; 		/* vertex attribute pointers */
	GzToken         nameListColor[3];       /* color type names */
	GzPointer       valueListColor[3];      /* color type rgb pointers */
	GzColor		color; 
	GzCoord		vertexList[3];	/* vertex position coordinates */ 
	GzCoord		normalList[3];	/* vertex normals */ 
	GzTextureIndex	uvList[3];		/* vertex texture map indices */ 
	char		dummy[256]; 
	int		i; 
	int		xRes, yRes, dispClass;	/* display parameters */ 
	int		status; 
 
	status = 0; 

	/* 
	 * initialize the display and the renderer 
	 */ 

	m_nWidth = 256;		// frame buffer and display width
	m_nHeight = 256;    // frame buffer and display height

	status |= GzNewFrameBuffer(&m_pFrameBuffer, m_nWidth, m_nHeight);
	status |= GzNewDisplay(&m_pDisplay, GZ_RGBAZ_DISPLAY, m_nWidth, m_nHeight); 
 
	status |= GzGetDisplayParams(m_pDisplay, &xRes, &yRes, &dispClass); 
	 
	status |= GzInitDisplay(m_pDisplay); 
 
	status |= GzNewRender(&m_pRender, GZ_Z_BUFFER_RENDER, m_pDisplay); 

	status |= GzBeginRender(m_pRender); 

	if (status) exit(GZ_FAILURE); 

	/* 
	 * Tokens associated with triangle vertex values 
	 */ 
	nameListTriangle[0] = GZ_POSITION; /* define vert coordinates only */

	// I/O File open
	FILE *infile;
	if( (infile  = fopen( INFILE2 , "r" )) == NULL )
	{
         AfxMessageBox( "The input file was not opened\n" );
		 return GZ_FAILURE;
	}

	FILE *outfile;
	if( (outfile  = fopen( OUTFILE2 , "wb" )) == NULL )
	{
         AfxMessageBox( "The output file was not opened\n" );
		 return GZ_FAILURE;
	}

	/* 
	* Walk through the list of triangles, set color 
	* and pass vert info to render/scan convert each triangle 
	*/ 
	i = 0; 

	while( fscanf(infile, "%s", dummy) == 1) { 	/* read in tri word */
	    fscanf(infile, "%f %f %f %f %f %f %f %f", 
		&(vertexList[0][0]), &(vertexList[0][1]),  
		&(vertexList[0][2]), 
		&(normalList[0][0]), &(normalList[0][1]), 	
		&(normalList[0][2]), 
		&(uvList[0][0]), &(uvList[0][1]) ); 
	    fscanf(infile, "%f %f %f %f %f %f %f %f", 
		&(vertexList[1][0]), &(vertexList[1][1]), 	
		&(vertexList[1][2]), 
		&(normalList[1][0]), &(normalList[1][1]), 	
		&(normalList[1][2]), 
		&(uvList[1][0]), &(uvList[1][1]) ); 
	    fscanf(infile, "%f %f %f %f %f %f %f %f", 
		&(vertexList[2][0]), &(vertexList[2][1]), 	
		&(vertexList[2][2]), 
		&(normalList[2][0]), &(normalList[2][1]), 	
		&(normalList[2][2]), 
		&(uvList[2][0]), &(uvList[2][1]) ); 

	    /* 
	    * Set up shading attributes for each triangle 
	    */ 
	    shade2(normalList[0], color);/* shade based on the norm of vert0 */
	    valueListColor[0] = (GzPointer)color; 
	    nameListColor[0] = GZ_RGB_COLOR; 
	    GzPutAttribute(m_pRender, 1, nameListColor, valueListColor); 
 
	    /* 
	     * Set the value pointers to the first vertex of the 	
	     * triangle, then feed it to the renderer 
	     */ 
	     valueListTriangle[0] = (GzPointer)vertexList; 


	     GzPutTriangle(m_pRender, 1, nameListTriangle, valueListTriangle);
	} 

	GzFlushDisplay2File(outfile, m_pDisplay); 	/* write out or update display to file*/
	GzFlushDisplay2FrameBuffer(m_pFrameBuffer, m_pDisplay);	// write out or update display to frame buffer
 
	/* 
	 * Clean up and exit 
	 */ 

	if( fclose( infile ) )
      AfxMessageBox( "The input file was not closed\n" );

	if( fclose( outfile ) )
      AfxMessageBox( "The output file was not closed\n" );

	status |= GzFreeRender(m_pRender); 
	status |= GzFreeDisplay(m_pDisplay); 
 
	if (status) 
		return(GZ_FAILURE); 
	else 
		return(GZ_SUCCESS); 
} 
int release_render()
{
	GzFreeDisplay(renderer->display);
	GzFreeRender(renderer);
	return 0;
}