Ejemplo n.º 1
0
/*
 * R_Init
 */
void
R_Init(void)
{
	int	err;
	int	i;
	byte *ptr;

	ri.Printf(PRINT_ALL, "----- R_Init -----\n");

	/* clear all our internal state */
	Q_Memset(&tr, 0, sizeof(tr));
	Q_Memset(&backEnd, 0, sizeof(backEnd));
	Q_Memset(&tess, 0, sizeof(tess));

	if(sizeof(Glconfig) != 11332)
		ri.Error(ERR_FATAL, "Mod ABI incompatible: sizeof(Glconfig) == %u != 11332",
			(unsigned int)sizeof(Glconfig));

/*	Swap_Init(); */

	if((intptr_t)tess.xyz & 15){
		ri.Printf(PRINT_WARNING, "tess.xyz not 16 byte aligned\n");
	}
	/* Q_Memset( tess.constantColor255, 255, sizeof( tess.constantColor255 ) ); */

	/*
	 * init function tables
	 *  */
	for(i = 0; i < FUNCTABLE_SIZE; i++){
		tr.sinTable[i] = sin(DEG2RAD(i * 360.0f / (( float )(FUNCTABLE_SIZE - 1))));
		tr.squareTable[i]	= (i < FUNCTABLE_SIZE/2) ? 1.0f : -1.0f;
		tr.sawToothTable[i]	= (float)i / FUNCTABLE_SIZE;
		tr.inverseSawToothTable[i] = 1.0f - tr.sawToothTable[i];

		if(i < FUNCTABLE_SIZE / 2){
			if(i < FUNCTABLE_SIZE / 4){
				tr.triangleTable[i] = ( float )i / (FUNCTABLE_SIZE / 4);
			}else{
				tr.triangleTable[i] = 1.0f - tr.triangleTable[i-FUNCTABLE_SIZE / 4];
			}
		}else{
			tr.triangleTable[i] = -tr.triangleTable[i-FUNCTABLE_SIZE/2];
		}
	}

	R_InitFogTable();

	R_NoiseInit();

	R_Register();

	max_polys = r_maxpolys->integer;
	if(max_polys < MAX_POLYS)
		max_polys = MAX_POLYS;

	max_polyverts = r_maxpolyverts->integer;
	if(max_polyverts < MAX_POLYVERTS)
		max_polyverts = MAX_POLYVERTS;

	ptr = ri.hunkalloc(
		sizeof(*backEndData[0]) + sizeof(srfPoly_t) * max_polys + sizeof(Polyvert) * max_polyverts,
		Hlow);
	backEndData[0] = (backEndData_t*)ptr;
	backEndData[0]->polys = (srfPoly_t*)((char*)ptr + sizeof(*backEndData[0]));
	backEndData[0]->polyVerts =
		(Polyvert*)((char*)ptr + sizeof(*backEndData[0]) + sizeof(srfPoly_t) * max_polys);
	if(r_smp->integer){
		ptr =
			ri.hunkalloc(
				sizeof(*backEndData[1]) + sizeof(srfPoly_t) * max_polys +
				sizeof(Polyvert) * max_polyverts,
				Hlow);
		backEndData[1] = (backEndData_t*)ptr;
		backEndData[1]->polys = (srfPoly_t*)((char*)ptr + sizeof(*backEndData[1]));
		backEndData[1]->polyVerts =
			(Polyvert*)((char*)ptr + sizeof(*backEndData[1]) + sizeof(srfPoly_t) * max_polys);
	}else{
		backEndData[1] = NULL;
	}
	R_ToggleSmpFrame();

	InitOpenGL();

	R_InitImages();

	GLSL_InitGPUShaders();

	FBO_Init();

	R_InitVBOs();

	R_InitShaders();

	R_InitSkins();

	R_ModelInit();

	R_InitFreeType();

	R_InitQueries();


	err = qglGetError();
	if(err != GL_NO_ERROR)
		ri.Printf (PRINT_ALL, "glGetError() = 0x%x\n", err);

	/* print info */
	GfxInfo_f();

	ri.Printf(PRINT_ALL, "----- finished R_Init -----\n");
}
Ejemplo n.º 2
0
/*
===============
R_Init
===============
*/
void R_Init( void ) {	
	int	err;
	int i;
	byte *ptr;

	ri.Printf( PRINT_ALL, "----- R_Init -----\n" );

	// clear all our internal state
	Com_Memset( &tr, 0, sizeof( tr ) );
	Com_Memset( &backEnd, 0, sizeof( backEnd ) );
	Com_Memset( &tess, 0, sizeof( tess ) );

	if(sizeof(glconfig_t) != 11332)
		ri.Error( ERR_FATAL, "Mod ABI incompatible: sizeof(glconfig_t) == %u != 11332", (unsigned int) sizeof(glconfig_t));

//	Swap_Init();

	if ( (intptr_t)tess.xyz & 15 ) {
		ri.Printf( PRINT_WARNING, "tess.xyz not 16 byte aligned\n" );
	}
	//Com_Memset( tess.constantColor255, 255, sizeof( tess.constantColor255 ) );

	//
	// init function tables
	//
	for ( i = 0; i < FUNCTABLE_SIZE; i++ )
	{
		tr.sinTable[i]		= sin( DEG2RAD( i * 360.0f / ( ( float ) ( FUNCTABLE_SIZE - 1 ) ) ) );
		tr.squareTable[i]	= ( i < FUNCTABLE_SIZE/2 ) ? 1.0f : -1.0f;
		tr.sawToothTable[i] = (float)i / FUNCTABLE_SIZE;
		tr.inverseSawToothTable[i] = 1.0f - tr.sawToothTable[i];

		if ( i < FUNCTABLE_SIZE / 2 )
		{
			if ( i < FUNCTABLE_SIZE / 4 )
			{
				tr.triangleTable[i] = ( float ) i / ( FUNCTABLE_SIZE / 4 );
			}
			else
			{
				tr.triangleTable[i] = 1.0f - tr.triangleTable[i-FUNCTABLE_SIZE / 4];
			}
		}
		else
		{
			tr.triangleTable[i] = -tr.triangleTable[i-FUNCTABLE_SIZE/2];
		}
	}

	R_InitFogTable();

	R_NoiseInit();

	R_Register();

	max_polys = r_maxpolys->integer;
	if (max_polys < MAX_POLYS)
		max_polys = MAX_POLYS;

	max_polyverts = r_maxpolyverts->integer;
	if (max_polyverts < MAX_POLYVERTS)
		max_polyverts = MAX_POLYVERTS;

	ptr = ri.Hunk_Alloc( sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low);
	backEndData = (backEndData_t *) ptr;
	backEndData->polys = (srfPoly_t *) ((char *) ptr + sizeof( *backEndData ));
	backEndData->polyVerts = (polyVert_t *) ((char *) ptr + sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys);
	R_InitNextFrame();

	InitOpenGL();

	R_InitImages();

	if (glRefConfig.framebufferObject)
		FBO_Init();

	GLSL_InitGPUShaders();

	R_InitVaos();

	R_InitShaders();

	R_InitSkins();

	R_ModelInit();

	R_InitFreeType();

	R_InitQueries();


	err = qglGetError();
	if ( err != GL_NO_ERROR )
		ri.Printf (PRINT_ALL, "glGetError() = 0x%x\n", err);

	// print info
	GfxInfo_f();
	ri.Printf( PRINT_ALL, "----- finished R_Init -----\n" );
}