GearEngine  0.0.1
Gear::OpenGLTexture2D 클래스 참조

#include <OpenGLTexture.h>

Gear::OpenGLTexture2D에 대한 상속 다이어그램 :
Inheritance graph
Gear::OpenGLTexture2D에 대한 협력 다이어그램:
Collaboration graph

Public 멤버 함수

 OpenGLTexture2D (const std::string &path)
 
 OpenGLTexture2D (uint32_t width, uint32_t height)
 
virtual ~OpenGLTexture2D ()
 
virtual uint32_t GetWidth () const override
 
virtual uint32_t GetHeight () const override
 
virtual void SetData (void *data, uint32_t size) override
 
virtual void Bind (uint32_t slot=0) const override
 

정적 Public 멤버 함수

static Ref< Texture2DCreate (uint32_t width, uint32_t height)
 
static Ref< Texture2DCreate (const std::string &path)
 

Private 속성

std::string m_Path
 
uint32_t m_Width
 
uint32_t m_Height
 
uint32_t m_RendererID
 
GLenum m_InternalFormat
 
GLenum m_DataFormat
 

상세한 설명

OpenGLTexture.h 파일의 9 번째 라인에서 정의되었습니다.

생성자 & 소멸자 문서화

◆ OpenGLTexture2D() [1/2]

Gear::OpenGLTexture2D::OpenGLTexture2D ( const std::string &  path)

OpenGLTexture.cpp 파일의 26 번째 라인에서 정의되었습니다.

27  :m_Path(path)
28  {
30 
31  int width, height, channels;
32  stbi_set_flip_vertically_on_load(1);
33  stbi_uc* data = nullptr;
34  {
35  GR_PROFILE_SCOPE("stbi_load - OpenGlTexture2D::OpenGLTexture2D(const std::string&)");
36  data = stbi_load(path.c_str(), &width, &height, &channels, 0);
37  }
38  GR_CORE_ASSERT(data, "Failed to load image!");
39  m_Width = width;
40  m_Height = height;
41 
42  GLenum internalFormat = 0, dataFormat = 0;
43 
44  if (channels == 4)
45  {
46  internalFormat = GL_RGBA8;
47  dataFormat = GL_RGBA;
48  }
49  else if (channels == 3)
50  {
51  internalFormat = GL_RGB8;
52  dataFormat = GL_RGB;
53  }
54 
55  m_InternalFormat = internalFormat;
56  m_DataFormat = dataFormat;
57 
58  GR_CORE_ASSERT(internalFormat & dataFormat, "Format not supported!");
59 
60  glCreateTextures(GL_TEXTURE_2D, 1, &m_RendererID);
61  glTextureStorage2D(m_RendererID, 1, internalFormat, m_Width, m_Height);
62 
63  glTextureParameteri(m_RendererID, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
64  glTextureParameteri(m_RendererID, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
65 
66  glTextureParameteri(m_RendererID, GL_TEXTURE_WRAP_S, GL_REPEAT);
67  glTextureParameteri(m_RendererID, GL_TEXTURE_WRAP_T, GL_REPEAT);
68 
69  glTextureSubImage2D(m_RendererID, 0, 0, 0, m_Width, m_Height, dataFormat, GL_UNSIGNED_BYTE, data);
70 
71  stbi_image_free(data);
72  }

◆ OpenGLTexture2D() [2/2]

Gear::OpenGLTexture2D::OpenGLTexture2D ( uint32_t  width,
uint32_t  height 
)

OpenGLTexture.cpp 파일의 8 번째 라인에서 정의되었습니다.

9  : m_Width(width), m_Height(height)
10  {
12 
13  m_InternalFormat = GL_RGBA8;
14  m_DataFormat = GL_RGBA;
15 
16  glCreateTextures(GL_TEXTURE_2D, 1, &m_RendererID);
17  glTextureStorage2D(m_RendererID, 1, m_InternalFormat, m_Width, m_Height);
18 
19  glTextureParameteri(m_RendererID, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
20  glTextureParameteri(m_RendererID, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
21 
22  glTextureParameteri(m_RendererID, GL_TEXTURE_WRAP_S, GL_REPEAT);
23  glTextureParameteri(m_RendererID, GL_TEXTURE_WRAP_T, GL_REPEAT);
24  }

◆ ~OpenGLTexture2D()

Gear::OpenGLTexture2D::~OpenGLTexture2D ( )
virtual

OpenGLTexture.cpp 파일의 74 번째 라인에서 정의되었습니다.

75  {
77 
78  glDeleteTextures(1, &m_RendererID);
79  }

멤버 함수 문서화

◆ Bind()

void Gear::OpenGLTexture2D::Bind ( uint32_t  slot = 0) const
overridevirtual

Gear::Texture를 구현.

OpenGLTexture.cpp 파일의 90 번째 라인에서 정의되었습니다.

91  {
93 
94  glBindTextureUnit(slot, m_RendererID);
95  }

◆ Create() [1/2]

Ref< Texture2D > Gear::Texture2D::Create ( const std::string &  path)
staticinherited

Texture.cpp 파일의 23 번째 라인에서 정의되었습니다.

24  {
25  switch (Renderer::GetAPI())
26  {
28  GR_CORE_ASSERT(false, "RendererAPI::None is currently not supported!");
29  return nullptr;
31  return CreateRef<OpenGLTexture2D>(path);
32  }
33  GR_CORE_ASSERT(false, "Unknown RendererAPI!");
34  return nullptr;
35  }
이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ Create() [2/2]

Ref< Texture2D > Gear::Texture2D::Create ( uint32_t  width,
uint32_t  height 
)
staticinherited

Texture.cpp 파일의 9 번째 라인에서 정의되었습니다.

10  {
11  switch (Renderer::GetAPI())
12  {
14  GR_CORE_ASSERT(false, "RendererAPI::None is currently not supported!");
15  return nullptr;
17  return CreateRef<OpenGLTexture2D>(width, height);
18  }
19  GR_CORE_ASSERT(false, "Unknown RendererAPI!");
20  return nullptr;
21  }
이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ GetHeight()

virtual uint32_t Gear::OpenGLTexture2D::GetHeight ( ) const
inlineoverridevirtual

Gear::Texture를 구현.

OpenGLTexture.h 파일의 18 번째 라인에서 정의되었습니다.

18 { return m_Height; }

◆ GetWidth()

virtual uint32_t Gear::OpenGLTexture2D::GetWidth ( ) const
inlineoverridevirtual

Gear::Texture를 구현.

OpenGLTexture.h 파일의 17 번째 라인에서 정의되었습니다.

17 { return m_Width; }

◆ SetData()

void Gear::OpenGLTexture2D::SetData ( void *  data,
uint32_t  size 
)
overridevirtual

Gear::Texture를 구현.

OpenGLTexture.cpp 파일의 81 번째 라인에서 정의되었습니다.

82  {
84 
85  uint32_t bpc = m_DataFormat == GL_RGBA ? 4 : 3;
86  GR_CORE_ASSERT(size == m_Width * m_Height * bpc, "Data must be entire texture!");
87  glTextureSubImage2D(m_RendererID, 0, 0, 0, m_Width, m_Height, m_DataFormat, GL_UNSIGNED_BYTE, data);
88  }

멤버 데이터 문서화

◆ m_DataFormat

GLenum Gear::OpenGLTexture2D::m_DataFormat
private

OpenGLTexture.h 파일의 27 번째 라인에서 정의되었습니다.

◆ m_Height

uint32_t Gear::OpenGLTexture2D::m_Height
private

OpenGLTexture.h 파일의 25 번째 라인에서 정의되었습니다.

◆ m_InternalFormat

GLenum Gear::OpenGLTexture2D::m_InternalFormat
private

OpenGLTexture.h 파일의 27 번째 라인에서 정의되었습니다.

◆ m_Path

std::string Gear::OpenGLTexture2D::m_Path
private

OpenGLTexture.h 파일의 24 번째 라인에서 정의되었습니다.

◆ m_RendererID

uint32_t Gear::OpenGLTexture2D::m_RendererID
private

OpenGLTexture.h 파일의 26 번째 라인에서 정의되었습니다.

◆ m_Width

uint32_t Gear::OpenGLTexture2D::m_Width
private

OpenGLTexture.h 파일의 25 번째 라인에서 정의되었습니다.


이 클래스에 대한 문서화 페이지는 다음의 파일들로부터 생성되었습니다.:
Gear::OpenGLTexture2D::m_InternalFormat
GLenum m_InternalFormat
Definition: OpenGLTexture.h:27
GR_PROFILE_FUNCTION
#define GR_PROFILE_FUNCTION()
Definition: Instrumentor.h:131
Gear::RendererAPI::API::None
@ None
Gear::RendererAPI::API::OpenGL
@ OpenGL
Gear::Renderer::GetAPI
static RendererAPI::API GetAPI()
Definition: Renderer.h:23
Gear::OpenGLTexture2D::m_Width
uint32_t m_Width
Definition: OpenGLTexture.h:25
GR_PROFILE_SCOPE
#define GR_PROFILE_SCOPE(name)
Definition: Instrumentor.h:130
GR_CORE_ASSERT
#define GR_CORE_ASSERT(x,...)
Definition: Core.h:68
Gear::OpenGLTexture2D::m_DataFormat
GLenum m_DataFormat
Definition: OpenGLTexture.h:27
Gear::OpenGLTexture2D::m_Height
uint32_t m_Height
Definition: OpenGLTexture.h:25
GLenum
unsigned int GLenum
Definition: OpenGLShader.h:7
Gear::OpenGLTexture2D::m_RendererID
uint32_t m_RendererID
Definition: OpenGLTexture.h:26
Gear::OpenGLTexture2D::m_Path
std::string m_Path
Definition: OpenGLTexture.h:24