Example #1
0
void	VID_Init (void)
{
    refimport_t	ri;

    viddef.width = 320;
    viddef.height = 240;

    ri.Cmd_AddCommand = Cmd_AddCommand;
    ri.Cmd_RemoveCommand = Cmd_RemoveCommand;
    ri.Cmd_Argc = Cmd_Argc;
    ri.Cmd_Argv = Cmd_Argv;
    ri.Cmd_ExecuteText = Cbuf_ExecuteText;
    ri.Con_Printf = VID_Printf;
    ri.Sys_Error = VID_Error;
    ri.FS_LoadFile = FS_LoadFile;
    ri.FS_FreeFile = FS_FreeFile;
    ri.FS_Gamedir = FS_Gamedir;
	ri.Vid_NewWindow = VID_NewWindow;
    ri.Cvar_Get = Cvar_Get;
    ri.Cvar_Set = Cvar_Set;
    ri.Cvar_SetValue = Cvar_SetValue;
    ri.Vid_GetModeInfo = VID_GetModeInfo;

    re = GetRefAPI(ri);

    if (re.api_version != API_VERSION)
        Com_Error (ERR_FATAL, "Re has incompatible api_version");
    
        // call the init function
    if (re.Init (NULL, NULL) == -1)
		Com_Error (ERR_FATAL, "Couldn't start refresh");
}
Example #2
0
void *Sys_GetRefAPI (void *parms) 
{
	return (NULL);
#if 0
	return (void *)GetRefAPI(REF_API_VERSION, parms);
#endif
}
Example #3
0
/*
==============
VID_LoadRefresh
==============
*/
qboolean VID_LoadRefresh()
{
	refimport_t	ri;
	
	if ( reflib_active )
	{
		re.Shutdown();
	}

	ri.Cmd_AddCommand = Cmd_AddCommand;
	ri.Cmd_RemoveCommand = Cmd_RemoveCommand;
	ri.Cmd_Argc = Cmd_Argc;
	ri.Cmd_Argv = Cmd_Argv;
	ri.Cmd_ExecuteText = Cbuf_ExecuteText;
	ri.Con_Printf = VID_Printf;
	ri.Sys_Error = VID_Error;
	ri.FS_LoadFile = FS_LoadFile;
	ri.FS_FreeFile = FS_FreeFile;
	ri.FS_FOpenFile = FS_FOpenFile;
	ri.FS_FCloseFile = FS_FCloseFile;
	ri.FS_Read = FS_Read;
	ri.FS_Gamedir = FS_Gamedir;
	ri.Cvar_Get = Cvar_Get;
	ri.Cvar_Set = Cvar_Set;
	ri.Cvar_SetValue = Cvar_SetValue;
	ri.Vid_GetModeInfo = VID_GetModeInfo;
	ri.Vid_MenuInit = VID_MenuInit;
	ri.Vid_NewWindow = VID_NewWindow;

	re = GetRefAPI( ri );

	if (re.api_version != API_VERSION)
	{
		Com_Error (ERR_FATAL, "Refresh has incompatible api_version");
	}

	if ( re.Init( NULL, window ) == -1 )
	{
		re.Shutdown();
		return false;
	}

	reflib_active = true;

//======
//PGM
	vidref_val = VIDREF_GL;
//PGM
//======

	return true;
}
Example #4
0
int Q_EXTERNAL_CALL RE_Startup( int apiVersion, refexport_t *out, const refimport_t *in )
{
	if( apiVersion != REF_API_VERSION )
	{
		ri.Printf( PRINT_ALL, "Mismatched REF_API_VERSION: expected %i, got %i\n", 
			REF_API_VERSION, apiVersion );
		return 0;
	}

	ri = *in;
	GetRefAPI( out );
	return 1;
}
Example #5
0
/*
============
CL_InitRef
============
*/
void CL_InitRef( void ) {
	refimport_t	ri;
	refexport_t	*ret;

	Com_Printf( "----- Initializing Renderer ----\n" );

	ri.Cmd_AddCommand = Cmd_AddCommand;
	ri.Cmd_RemoveCommand = Cmd_RemoveCommand;
	ri.Cmd_Argc = Cmd_Argc;
	ri.Cmd_Argv = Cmd_Argv;
	ri.Cmd_ExecuteText = Cbuf_ExecuteText;
	ri.Printf = VID_Printf;
	ri.Error = Com_Error;
	ri.Milliseconds = Sys_Milliseconds;
	ri.flrand = Q_flrand;                      
	ri.Malloc = CL_ZMalloc_Helper;
	ri.Free = Z_Free;
	ri.Hunk_Clear = Hunk_ClearToMark;
	ri.Hunk_Alloc = Hunk_Alloc;
	ri.CM_DrawDebugSurface = CM_DrawDebugSurface;
	ri.FS_ReadFile = FS_ReadFile;
	ri.FS_FreeFile = FS_FreeFile;
	ri.FS_WriteFile = FS_WriteFile;
 	ri.FS_FreeFileList = FS_FreeFileList;
	ri.FS_ListFiles = FS_ListFiles;
	ri.FS_FileIsInPAK = FS_FileIsInPAK;
	ri.Cvar_Get = Cvar_Get;
	ri.Cvar_Set = Cvar_Set;
	ri.CM_PointContents = CM_PointContents;
	ri.ArgsBuffer = Cmd_ArgsBuffer;                    

	// cinematic stuff

	ri.CIN_UploadCinematic = CIN_UploadCinematic;
	ri.CIN_PlayCinematic = CIN_PlayCinematic;
	ri.CIN_RunCinematic = CIN_RunCinematic;


	ret = GetRefAPI( REF_API_VERSION, &ri );

	Com_Printf( "-------------------------------\n");

	if ( !ret ) {
		Com_Error (ERR_FATAL, "Couldn't initialize refresh" );
	}

	re = *ret;

	// unpause so the cgame definately gets a snapshot and renders a frame
	Cvar_Set( "cl_paused", "0" );
}
Example #6
0
/*
==============
VID_LoadRefresh
==============
*/
qboolean VID_LoadRefresh(void)
{
//	GetRefAPI_t	GetRefAPI;
	
	if ( reflib_active )
	{
		R_Shutdown();
		VID_FreeReflib ();
	}

	VID_Printf(PRINT_INFO, "-------- Loading OpenGL Ref --------\n");

#if 0
	if ( ( reflib_library = LoadLibrary( name ) ) == 0 )
	{
		VID_Printf(PRINT_ALL, "LoadLibrary(\"%s\") failed\n", name );

		return false;
	}
#endif

	Swap_Init();

#if 0
	if ( ( GetRefAPI = (void *) GetProcAddress( reflib_library, "GetRefAPI" ) ) == 0 )
		Com_Error( ERR_FATAL, "GetProcAddress failed on %s", name );

	re = GetRefAPI( ri );
#endif

#if 0
	if (re.api_version != API_VERSION)
	{
		VID_FreeReflib ();
		Com_Error (ERR_FATAL, "%s has incompatible api_version", name);
	}
#endif

	if ( R_Init( global_hInstance, MainWndProc ) == -1 )
	{
		R_Shutdown();
		VID_FreeReflib ();
		return false;
	}

	VID_Printf(PRINT_INFO, "------------------------------------\n");
	reflib_active = true;

	return true;
}
Example #7
0
/*
============
CL_InitRef
============
*/
void CL_InitRef( void ) {
	refexport_t	*ret;

	Com_Printf( "----- Initializing Renderer ----\n" );

	// cinematic stuff

	ret = GetRefAPI( REF_API_VERSION );

	Com_Printf( "-------------------------------\n");

	if ( !ret ) {
		Com_Error (ERR_FATAL, "Couldn't initialize refresh" );
	}

	re = *ret;

	// unpause so the cgame definately gets a snapshot and renders a frame
	Cvar_Set( "cl_paused", "0" );
}
Example #8
0
void *Sys_GetRefAPI (void *parms) 
{
	return (void *)GetRefAPI(REF_API_VERSION, parms);
}
Example #9
0
static void SV_InitRef( void ) {
	refimport_t	ri = {0};
	refexport_t	*ret;

	Com_Printf( "----- Initializing Renderer ----\n" );

	//set up the import table
	ri.Printf = SV_RefPrintf;
	ri.Error = Com_Error;
	ri.OPrintf = Com_OPrintf;
	ri.Milliseconds = Sys_Milliseconds2; //FIXME: unix+mac need this
	ri.Hunk_AllocateTempMemory = Hunk_AllocateTempMemory;
	ri.Hunk_FreeTempMemory = Hunk_FreeTempMemory;
	ri.Hunk_Alloc = Hunk_Alloc;
	ri.Hunk_MemoryRemaining = Hunk_MemoryRemaining;
	ri.Z_Malloc = Z_Malloc;
	ri.Z_Free = Z_Free;
	ri.Z_MemSize = Z_MemSize;
	ri.Z_MorphMallocTag = Z_MorphMallocTag;
	ri.Cmd_ExecuteString = Cmd_ExecuteString;
	ri.Cmd_Argc = Cmd_Argc;
	ri.Cmd_Argv = Cmd_Argv;
	ri.Cmd_ArgsBuffer = Cmd_ArgsBuffer;
	ri.Cmd_AddCommand = Cmd_AddCommand;
	ri.Cmd_RemoveCommand = Cmd_RemoveCommand;
	ri.Cvar_Set = Cvar_Set;
	ri.Cvar_Get = Cvar_Get;
	ri.Cvar_VariableStringBuffer = Cvar_VariableStringBuffer;
	ri.Cvar_VariableString = Cvar_VariableString;
	ri.Cvar_VariableValue = Cvar_VariableValue;
	ri.Cvar_VariableIntegerValue = Cvar_VariableIntegerValue;
	ri.Sys_LowPhysicalMemory = Sys_LowPhysicalMemory;
	ri.SE_GetString = SE_GetString;
	ri.FS_FreeFile = FS_FreeFile;
	ri.FS_FreeFileList = FS_FreeFileList;
	ri.FS_Read = FS_Read;
	ri.FS_ReadFile = FS_ReadFile;
	ri.FS_FCloseFile = FS_FCloseFile;
	ri.FS_FOpenFileRead = FS_FOpenFileRead;
	ri.FS_FOpenFileWrite = FS_FOpenFileWrite;
	ri.FS_FOpenFileByMode = FS_FOpenFileByMode;
	ri.FS_FileExists = FS_FileExists;
	ri.FS_FileIsInPAK = FS_FileIsInPAK;
	ri.FS_ListFiles = FS_ListFiles;
	ri.FS_Write = FS_Write;
	ri.FS_WriteFile = FS_WriteFile;
	ri.CM_BoxTrace = CM_BoxTrace;
	ri.CM_DrawDebugSurface = CM_DrawDebugSurface;
//	ri.CM_CullWorldBox = CM_CullWorldBox;
//	ri.CM_TerrainPatchIterate = CM_TerrainPatchIterate;
//	ri.CM_RegisterTerrain = CM_RegisterTerrain;
//	ri.CM_ShutdownTerrain = CM_ShutdownTerrain;
	ri.CM_ClusterPVS = CM_ClusterPVS;
	ri.CM_LeafArea = CM_LeafArea;
	ri.CM_LeafCluster = CM_LeafCluster;
	ri.CM_PointLeafnum = CM_PointLeafnum;
	ri.CM_PointContents = CM_PointContents;
	ri.VM_Call = VM_Call;
	ri.Com_TheHunkMarkHasBeenMade = Com_TheHunkMarkHasBeenMade;
	ri.SV_GetConfigstring = SV_GetConfigstring;
	ri.SV_SetConfigstring = SV_SetConfigstring;
//	ri.S_RestartMusic = S_RestartMusic;
//	ri.SND_RegisterAudio_LevelLoadEnd = SND_RegisterAudio_LevelLoadEnd;
//	ri.CIN_RunCinematic = CIN_RunCinematic;
//	ri.CIN_PlayCinematic = CIN_PlayCinematic;
//	ri.CIN_UploadCinematic = CIN_UploadCinematic;
//	ri.CL_WriteAVIVideoFrame = CL_WriteAVIVideoFrame;

	// g2 data access
	ri.GetSharedMemory = GetSharedMemory;
//	ri.GetCgameVM = GetCgameVM;
	ri.GetGameVM = GetGameVM;
	ri.GetCurrentVM = GetCurrentVM;

	// ugly win32 backend
	ri.CM_GetCachedMapDiskImage = CM_GetCachedMapDiskImage;
	ri.CM_SetCachedMapDiskImage = CM_SetCachedMapDiskImage;
	ri.CM_SetUsingCache = CM_SetUsingCache;

	//RAZFIXME: Might have to do something about this...
	ri.GetG2VertSpaceServer = GetG2VertSpaceServer;
	G2VertSpaceServer = &CMiniHeap_singleton;

	ret = GetRefAPI( REF_API_VERSION, &ri );

#if defined __USEA3D && defined __A3D_GEOM
	hA3Dg_ExportRenderGeom (ret);
#endif

//	Com_Printf( "-------------------------------\n");

	if ( !ret ) {
		Com_Error (ERR_FATAL, "Couldn't initialize refresh" );
	}

	re = *ret;
}
Example #10
0
void	VID_Init (void)
{
	TR;
    refimport_t	ri;

    viddef.width = 320;
    viddef.height = 240;

    ri.Cmd_AddCommand = Cmd_AddCommand;
    ri.Cmd_RemoveCommand = Cmd_RemoveCommand;
    ri.Cmd_Argc = Cmd_Argc;
    ri.Cmd_Argv = Cmd_Argv;
    ri.Cmd_ExecuteText = Cbuf_ExecuteText;
    ri.Con_Printf = VID_Printf;
    ri.Sys_Error = VID_Error;
    ri.FS_LoadFile = FS_LoadFile;
    ri.FS_FreeFile = FS_FreeFile;
    ri.FS_Gamedir = FS_Gamedir;
    ri.Vid_MenuInit = VID_MenuInit;
	ri.Vid_NewWindow = VID_NewWindow;
    ri.Cvar_Get = Cvar_Get;
    ri.Cvar_Set = Cvar_Set;
    ri.Cvar_SetValue = Cvar_SetValue;
    ri.Vid_GetModeInfo = VID_GetModeInfo;

    re = GetRefAPI(ri);
	xe=&_xe;
	
	Xe_Init(xe);
	
	edram_init(xe);
	Xe_SetRenderTarget(xe, Xe_GetFramebufferSurface(xe));
	static const struct XenosVBFFormat vbf = {
		3,
		{
			{XE_USAGE_POSITION, 0, XE_TYPE_FLOAT4},
			{XE_USAGE_COLOR, 0, XE_TYPE_UBYTE4},
			{XE_USAGE_TEXCOORD, 0, XE_TYPE_FLOAT2},
		}
	};
	
	pPixelShader = Xe_LoadShaderFromMemory(xe, (void*) g_xps_PS);
	Xe_InstantiateShader(xe, pPixelShader, 0);

	pVertexShader = Xe_LoadShaderFromMemory(xe, (void*) g_xvs_VS);
	Xe_InstantiateShader(xe, pVertexShader, 0);
	Xe_ShaderApplyVFetchPatches(xe, pVertexShader, 0, &vbf);
	
	// Create vb
	pVBSw = Xe_CreateVertexBuffer(xe, 3 * sizeof (DrawVerticeFormats));
	
	DrawVerticeFormats *Rect = Xe_VB_Lock(xe, pVBSw, 0, 3 * sizeof (DrawVerticeFormats), XE_LOCK_WRITE);
	{
		// top left
		Rect[0].x = -1;
		Rect[0].y = 1;
		Rect[0].u = 0;
		Rect[0].v = 0;
		Rect[0].color = 0;

		// bottom left
		Rect[1].x = -1;
		Rect[1].y = -1;
		Rect[1].u = 0;
		Rect[1].v = 1;
		Rect[1].color = 0;

		// top right
		Rect[2].x = 1;
		Rect[2].y = 1;
		Rect[2].u = 1;
		Rect[2].v = 0;
		Rect[2].color = 0;

		int i = 0;
		for (i = 0; i < 3; i++) {
			Rect[i].z = 0.0;
			Rect[i].w = 1.0;
		}
	}
	Xe_VB_Unlock(xe, pVBSw);
	
	pVideoSurface = NULL;
		
	if (re.api_version != API_VERSION)
        Com_Error (ERR_FATAL, "Re has incompatible api_version");
    
        // call the init function
    if (re.Init (NULL, NULL) == -1)
		Com_Error (ERR_FATAL, "Couldn't start refresh");
}