Esempio n. 1
0
/**
 * Create the \c GL_RENDERER string for DRI drivers.
 * 
 * Almost all DRI drivers use a \c GL_RENDERER string of the form:
 *
 *    "Mesa DRI <chip> <driver date> <AGP speed) <CPU information>"
 *
 * Using the supplied chip name, driver data, and AGP speed, this function
 * creates the string.
 * 
 * \param buffer         Buffer to hold the \c GL_RENDERER string.
 * \param hardware_name  Name of the hardware.
 * \param driver_date    Driver date.
 * \param agp_mode       AGP mode (speed).
 * 
 * \returns
 * The length of the string stored in \c buffer.  This does \b not include
 * the terminating \c NUL character.
 */
unsigned
driGetRendererString( char * buffer, const char * hardware_name,
		      const char * driver_date, GLuint agp_mode )
{
   unsigned offset;
   char *cpu;

   offset = sprintf( buffer, "Mesa DRI %s %s", hardware_name, driver_date );

   /* Append any AGP-specific information.
    */
   switch ( agp_mode ) {
   case 1:
   case 2:
   case 4:
   case 8:
      offset += sprintf( & buffer[ offset ], " AGP %ux", agp_mode );
      break;
	
   default:
      break;
   }

   /* Append any CPU-specific information.
    */
   cpu = _mesa_get_cpu_string();
   if (cpu) {
      offset += sprintf(buffer + offset, " %s", cpu);
      _mesa_free(cpu);
   }

   return offset;
}
const GLubyte*
MesaSoftwareRenderer::_GetString(gl_context* ctx, GLenum name)
{

	switch (name) {
		case GL_VENDOR:
			return (const GLubyte*) "Mesa Project";
		case GL_RENDERER: {
			_mesa_get_cpu_features();
			static char buffer[256] = { '\0' };

			if (!buffer[0]) {
				char* cpuInfo = _mesa_get_cpu_string();
				// Let's build an renderer string
				sprintf(buffer, "Software Rasterizer for %s", cpuInfo);
				free(cpuInfo);
			}
			return (const GLubyte*) buffer;
		}
		default:
			// Let core library handle all other cases
			return NULL;
	}
}