1//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
2//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
3#pragma once
4
5#include "BsGLPrerequisites.h"
6#include "Image/BsPixelUtil.h"
7
8namespace bs { namespace ct
9{
10 /** @addtogroup GL
11 * @{
12 */
13
14 /** Converts pixel formats to OpenGL formats */
15 class GLPixelUtil
16 {
17 public:
18 /** Finds the closest pixel format that OpenGL supports. */
19 static PixelFormat getClosestSupportedPF(PixelFormat format, TextureType texType, int usage);
20
21 /** Returns matching OpenGL base pixel format type if one is found, zero otherwise. */
22 static GLenum getGLOriginFormat(PixelFormat format);
23
24 /** Returns OpenGL data type used in the provided format. */
25 static GLenum getGLOriginDataType(PixelFormat format);
26
27 /**
28 * Returns matching OpenGL internal pixel format type if one is found, zero otherwise. Optionally returns an SRGB
29 * format if @p hwGamma is specified and such format exists.
30 */
31 static GLenum getGLInternalFormat(PixelFormat format, bool hwGamma = false);
32
33 /** Returns an OpenGL type that should be used for creating a buffer for the specified depth/stencil format. */
34 static GLenum getDepthStencilTypeFromPF(PixelFormat format);
35
36 /** Returns an OpenGL format that should be used for creating a buffer for the specified depth/stencil format. */
37 static GLenum getDepthStencilFormatFromPF(PixelFormat format);
38
39 /** Converts engine GPU buffer format to OpenGL GPU buffer format. */
40 static GLenum getBufferFormat(GpuBufferFormat format);
41
42 };
43
44 /** @} */
45}}