コード例 #1
0
ファイル: gl_resources.cpp プロジェクト: excalybure/renderdoc
GLenum GetSizedFormat(const GLHookSet &gl, GLenum target, GLenum internalFormat)
{
	switch(internalFormat)
	{
		case eGL_RED:
		case eGL_RG:
		case eGL_RGB:
		case eGL_RGBA:
		case eGL_DEPTH_COMPONENT:
		case eGL_DEPTH_STENCIL:
			break;
		default:
			return internalFormat; // already explicitly sized
	}

	switch(target)
	{
		case eGL_TEXTURE_CUBE_MAP_POSITIVE_X:
		case eGL_TEXTURE_CUBE_MAP_NEGATIVE_X:
		case eGL_TEXTURE_CUBE_MAP_POSITIVE_Y:
		case eGL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
		case eGL_TEXTURE_CUBE_MAP_POSITIVE_Z:
		case eGL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
			target = eGL_TEXTURE_CUBE_MAP;
		default:
			break;
	}
	
	GLint red, depth;
	if(gl.glGetInternalformativ)
	{
		gl.glGetInternalformativ(target, internalFormat, eGL_INTERNALFORMAT_RED_SIZE, sizeof(GLint), &red);
		gl.glGetInternalformativ(target, internalFormat, eGL_INTERNALFORMAT_DEPTH_SIZE, sizeof(GLint), &depth);
	}
	else
	{
		// without the query function, just default to sensible defaults
		red = 8;
		depth = 32;
	}

	switch(internalFormat)
	{
		case eGL_RED:
			if(red == 32)
				return eGL_R32F;
			else if(red == 16)
				return eGL_R16;
			else
				return eGL_R8;
		case eGL_RG:
			if(red == 32)
				return eGL_RG32F;
			else if(red == 16)
				return eGL_RG16;
			else
				return eGL_RG8;
		case eGL_RGB:
			if(red == 32)
				return eGL_RGB32F;
			else if(red == 16)
				return eGL_RGB16;
			else
				return eGL_RGB8;
		case eGL_RGBA:
			if(red == 32)
				return eGL_RGBA32F;
			else if(red == 16)
				return eGL_RGBA16;
			else
				return eGL_RGBA8;
		case eGL_DEPTH_COMPONENT:
			if(depth == 32)
				return eGL_DEPTH_COMPONENT32F;
			else if(depth == 16)
				return eGL_DEPTH_COMPONENT16;
			else
				return eGL_DEPTH_COMPONENT24;
		case eGL_DEPTH_STENCIL:
			if(depth == 32)
				return eGL_DEPTH32F_STENCIL8;
			else
				return eGL_DEPTH24_STENCIL8;
		default:
			break;
	}

	return internalFormat;
}
コード例 #2
0
ファイル: gl_resources.cpp プロジェクト: Nexuapex/renderdoc
GLenum GetSizedFormat(const GLHookSet &gl, GLenum target, GLenum internalFormat)
{
  switch(internalFormat)
  {
    // pick sized format ourselves for generic formats
    case eGL_COMPRESSED_RED: return eGL_COMPRESSED_RED_RGTC1;
    case eGL_COMPRESSED_RG: return eGL_COMPRESSED_RG_RGTC2;
    case eGL_COMPRESSED_RGB: return eGL_COMPRESSED_RGB_S3TC_DXT1_EXT;
    case eGL_COMPRESSED_RGBA: return eGL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
    case eGL_COMPRESSED_SRGB: return eGL_COMPRESSED_SRGB_S3TC_DXT1_EXT;
    case eGL_COMPRESSED_SRGB_ALPHA:
      return eGL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;

    // only one sized format for SRGB
    case eGL_SRGB: return eGL_SRGB8;
    case eGL_SRGB_ALPHA: return eGL_SRGB8_ALPHA8;

    case eGL_RED:
    case eGL_RG:
    case eGL_RGB:
    case eGL_RGBA:
    case eGL_DEPTH_COMPONENT:
    case eGL_STENCIL:
    case eGL_STENCIL_INDEX:
    case eGL_DEPTH_STENCIL: break;
    default:
      return internalFormat;    // already explicitly sized
  }

  switch(target)
  {
    case eGL_TEXTURE_CUBE_MAP_POSITIVE_X:
    case eGL_TEXTURE_CUBE_MAP_NEGATIVE_X:
    case eGL_TEXTURE_CUBE_MAP_POSITIVE_Y:
    case eGL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
    case eGL_TEXTURE_CUBE_MAP_POSITIVE_Z:
    case eGL_TEXTURE_CUBE_MAP_NEGATIVE_Z: target = eGL_TEXTURE_CUBE_MAP;
    default: break;
  }

  GLint red, depth, stencil;
  if(gl.glGetInternalformativ)
  {
    gl.glGetInternalformativ(target, internalFormat, eGL_INTERNALFORMAT_RED_SIZE, sizeof(GLint),
                             &red);
    gl.glGetInternalformativ(target, internalFormat, eGL_INTERNALFORMAT_DEPTH_SIZE, sizeof(GLint),
                             &depth);
    gl.glGetInternalformativ(target, internalFormat, eGL_INTERNALFORMAT_STENCIL_SIZE, sizeof(GLint),
                             &stencil);
  }
  else
  {
    // without the query function, just default to sensible defaults
    red = 8;
    depth = 32;
    stencil = 8;
  }

  switch(internalFormat)
  {
    case eGL_RED:
      if(red == 32)
        return eGL_R32F;
      else if(red == 16)
        return eGL_R16;
      else
        return eGL_R8;
    case eGL_RG:
      if(red == 32)
        return eGL_RG32F;
      else if(red == 16)
        return eGL_RG16;
      else
        return eGL_RG8;
    case eGL_RGB:
      if(red == 32)
        return eGL_RGB32F;
      else if(red == 16)
        return eGL_RGB16;
      else
        return eGL_RGB8;
    case eGL_RGBA:
      if(red == 32)
        return eGL_RGBA32F;
      else if(red == 16)
        return eGL_RGBA16;
      else
        return eGL_RGBA8;
    case eGL_STENCIL:
    case eGL_STENCIL_INDEX:
      if(stencil == 16)
        return eGL_STENCIL_INDEX16;
      else
        return eGL_STENCIL_INDEX8;
    case eGL_DEPTH_COMPONENT:
      if(depth == 32)
        return eGL_DEPTH_COMPONENT32F;
      else if(depth == 16)
        return eGL_DEPTH_COMPONENT16;
      else
        return eGL_DEPTH_COMPONENT24;
    case eGL_DEPTH_STENCIL:
      if(depth == 32)
        return eGL_DEPTH32F_STENCIL8;
      else
        return eGL_DEPTH24_STENCIL8;
    default: break;
  }

  return internalFormat;
}