Simplifying texture formats a bit

Post Reply
Luomu
Posts: 58
Joined: Mon Jul 01, 2013 1:30 am

Simplifying texture formats a bit

Post by Luomu »

I'm in the mood for some mindless refactoring.

Texture.h has these three enums:

Code: Select all

enum TextureFormat {
	TEXTURE_RGBA,
	TEXTURE_RGB,
	...etc
};

enum ImageFormat {
	IMAGE_RGBA,
	IMAGE_RGB,
	...etc
};

enum ImageType {
	IMAGE_UNSIGNED_BYTE,
};
That's because when uploading OpenGL textures you specify a format, an internal format and a data type. DirectX has all the combinations in one enum (same formats are actually used with more than images, such as vertex data):

Code: Select all

typedef enum DXGI_FORMAT {
  DXGI_FORMAT_UNKNOWN                      = 0,
  DXGI_FORMAT_R32G32B32A32_TYPELESS        = 1,
  DXGI_FORMAT_R32G32B32A32_FLOAT           = 2,
  DXGI_FORMAT_R32G32B32A32_UINT            = 3,
  DXGI_FORMAT_R32G32B32A32_SINT            = 4,
  DXGI_FORMAT_R32G32B32_TYPELESS           = 5,
  DXGI_FORMAT_R32G32B32_FLOAT              = 6,
  DXGI_FORMAT_R32G32B32_UINT               = 7,
  DXGI_FORMAT_R32G32B32_SINT               = 8,
  DXGI_FORMAT_R16G16B16A16_TYPELESS        = 9,
  DXGI_FORMAT_R16G16B16A16_FLOAT
  ...etc
}
I think I would like to do the same (limited to formats we actually use). If anyone thinks it's bad idea I won't do it.
robn
Posts: 302
Joined: Mon Jul 01, 2013 1:11 am
Location: Melbourne, Australia

Re: Simplifying texture formats a bit

Post by robn »

I think its a good idea. Having them separate suggests that they can be mixed and matched, which probably isn't true.
Luomu
Posts: 58
Joined: Mon Jul 01, 2013 1:30 am

Re: Simplifying texture formats a bit

Post by Luomu »

Cool, I shall do it.
Post Reply