CSEngine
Loading...
Searching...
No Matches
CSE::OGLMgr Class Reference
Inheritance diagram for CSE::OGLMgr:
CSE::CoreBase CSE::RenderCoreBase

Public Member Functions

void Init () override
 
void setBuffers ()
 
void setupEGLGraphics ()
 
void Render () const override
 
void ResizeWindow (GLuint width, GLuint height)
 
void releaseBuffers ()
 
- Public Member Functions inherited from CSE::CoreBase
virtual void Update (float elapsedTime)
 

Detailed Description

Definition at line 8 of file OGLMgr.h.

Constructor & Destructor Documentation

◆ OGLMgr()

OGLMgr::OGLMgr ( )

Definition at line 16 of file OGLMgr.cpp.

16 : m_projectionRatio(-1) {
17}

◆ ~OGLMgr()

OGLMgr::~OGLMgr ( )
override

Definition at line 23 of file OGLMgr.cpp.

23 {
24 releaseBuffers();
25}

Member Function Documentation

◆ Init()

void OGLMgr::Init ( )
overridevirtual

Implements CSE::CoreBase.

Definition at line 19 of file OGLMgr.cpp.

19 {
20 setupEGLGraphics();
21}

◆ releaseBuffers()

void OGLMgr::releaseBuffers ( )

Definition at line 117 of file OGLMgr.cpp.

117 {
118 glDeleteRenderbuffers(1, &m_colorRenderbuffer);
119 m_colorRenderbuffer = 0;
120
121 if (m_depthRenderbuffer) {
122 glDeleteRenderbuffers(1, &m_depthRenderbuffer);
123 m_depthRenderbuffer = 0;
124 }
125
126 glDeleteFramebuffers(1, &m_framebuffer);
127 m_framebuffer = 0;
128}

◆ Render()

void OGLMgr::Render ( ) const
overridevirtual

Implements CSE::RenderCoreBase.

Definition at line 80 of file OGLMgr.cpp.

80 {
81 glClearColor(0.4f, 0.4f, 0.4f, 1.0f);
82 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
83
85 glBindBuffer(GL_ARRAY_BUFFER, 0);
86 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
87
88 // 유효하지 않은 값이라서 주석처리함.
89// glEnable(GL_TEXTURE_2D);
90}

◆ ResizeWindow()

void OGLMgr::ResizeWindow ( GLuint  width,
GLuint  height 
)

Definition at line 92 of file OGLMgr.cpp.

92 {
93 if (m_depthRenderbuffer) {
94 glDeleteRenderbuffers(1, &m_depthRenderbuffer);
95 m_depthRenderbuffer = 0;
96 }
97
98 // Create the depth buffer.
99 glGenRenderbuffers(1, &m_depthRenderbuffer);
100 glBindRenderbuffer(GL_RENDERBUFFER, m_depthRenderbuffer);
101 glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
102
103 // Protect against a divide by zero
104 if (height == 0) {
105 height = 1;
106 }
107
108 // Setup our viewport.
109 glViewport(0, 0, static_cast<GLsizei>(width), static_cast<GLsizei>(height));
110
111 SEnvironmentMgr::SetWidth(width);
112 SEnvironmentMgr::SetHeight(height);
113
114 setProjectionRatio(width, height);
115}

◆ setBuffers()

void OGLMgr::setBuffers ( )

Definition at line 27 of file OGLMgr.cpp.

27 {
28 //렌더버퍼 생성
29 glGenRenderbuffers(1, &m_colorRenderbuffer);
30 glBindRenderbuffer(GL_RENDERBUFFER, m_colorRenderbuffer);
31
32 //깊이버퍼 생성 및 바인딩(옮김)
33 //glGenRenderbuffers(1, &m_depthRenderbuffer);
34 //glBindRenderbuffer(GL_RENDERBUFFER, m_depthRenderbuffer);
35 //glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, m_width, m_height);
36
37 //프레임버퍼 생성
38 glGenFramebuffers(1, &m_framebuffer);
39 glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);
40 glFramebufferRenderbuffer(GL_FRAMEBUFFER,
41 GL_COLOR_ATTACHMENT0,
42 GL_RENDERBUFFER,
43 m_colorRenderbuffer);
44 glFramebufferRenderbuffer(GL_FRAMEBUFFER,
45 GL_DEPTH_ATTACHMENT,
46 GL_RENDERBUFFER,
47 m_depthRenderbuffer);
48
49 // 렌더버퍼 바인딩
50 glBindRenderbuffer(GL_RENDERBUFFER, m_colorRenderbuffer);
51
52 glEnable(GL_DEPTH_TEST);
53 glClearDepthf(1.0f);
54
55#ifndef PLATFORM_IOS
56 //프레임버퍼 바인딩
57 glBindFramebuffer(GL_FRAMEBUFFER, 0);
58#endif
59}

◆ setupEGLGraphics()

void OGLMgr::setupEGLGraphics ( )

Definition at line 61 of file OGLMgr.cpp.

61 {
62 setBuffers();
63 setProjectionRatio(0, 0);
64
65 glEnable(GL_DEPTH_TEST);
66 glEnable(GL_CULL_FACE);
67 glCullFace(GL_BACK);
68 glFrontFace(GL_CCW);
69 glDepthFunc(GL_LEQUAL);
70 glDepthMask(true);
71 glBindFramebuffer(GL_FRAMEBUFFER, 0);
72 //glDepthRangef(0.0,1.0);
73}

The documentation for this class was generated from the following files: