@@ -109,8 +109,9 @@ static const int openGLBlendFuncEnums[] = {
109
109
RAS_OpenGLRasterizer::ScreenPlane::ScreenPlane ()
110
110
{
111
111
// Generate the VBO and IBO for screen overlay plane.
112
- glGenBuffersARB (1 , &m_vbo);
113
- glGenBuffersARB (1 , &m_ibo);
112
+ glGenBuffers (1 , &m_vbo);
113
+ glGenBuffers (1 , &m_ibo);
114
+ glGenVertexArrays (1 , &m_vao);
114
115
115
116
// Vertexes for screen plane, it contains the vertex position (3 floats) and the vertex uv after (2 floats, total size = 5 floats).
116
117
static const float vertices[] = {
@@ -123,50 +124,45 @@ RAS_OpenGLRasterizer::ScreenPlane::ScreenPlane()
123
124
// Indices for screen plane.
124
125
static const GLubyte indices[] = {3 , 2 , 1 , 0 };
125
126
127
+ glBindVertexArray (m_vao);
128
+
126
129
// Send indices in the sreen plane IBO.
127
- glBindBufferARB (GL_ELEMENT_ARRAY_BUFFER_ARB , m_ibo);
130
+ glBindBuffer (GL_ELEMENT_ARRAY_BUFFER , m_ibo);
128
131
glBufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (indices), indices, GL_STATIC_DRAW);
129
132
130
133
// Send vertexes in the screen plane VBO.
131
- glBindBufferARB (GL_ARRAY_BUFFER_ARB , m_vbo);
134
+ glBindBuffer (GL_ARRAY_BUFFER , m_vbo);
132
135
glBufferData (GL_ARRAY_BUFFER, sizeof (vertices), vertices, GL_STATIC_DRAW);
133
136
134
- // Unbind modified VBOs
135
- glBindBufferARB (GL_ARRAY_BUFFER_ARB, 0 );
136
- glBindBufferARB (GL_ELEMENT_ARRAY_BUFFER_ARB, 0 );
137
+ // Enable vertex/uv pointer.
138
+ glEnableClientState (GL_VERTEX_ARRAY);
139
+ glEnableClientState (GL_TEXTURE_COORD_ARRAY);
140
+
141
+ // Bind vertex/uv pointer with VBO offset. (position = 0, uv = 3 * float, stride = 5 * float).
142
+ glVertexPointer (3 , GL_FLOAT, sizeof (float ) * 5 , 0 );
143
+ glTexCoordPointer (2 , GL_FLOAT, sizeof (float ) * 5 , ((char *)nullptr ) + sizeof (float ) * 3 );
144
+
145
+ // Unbind VBO
146
+ glBindBuffer (GL_ARRAY_BUFFER, 0 );
147
+
148
+ glBindVertexArray (0 );
137
149
}
138
150
139
151
RAS_OpenGLRasterizer::ScreenPlane::~ScreenPlane ()
140
152
{
141
- // Delete screen overlay plane VBO/IBO
142
- glDeleteBuffersARB (1 , &m_vbo);
143
- glDeleteBuffersARB (1 , &m_ibo);
153
+ // Delete screen overlay plane VBO/IBO/VAO
154
+ glDeleteVertexArrays (1 , &m_vao);
155
+ glDeleteBuffers (1 , &m_vbo);
156
+ glDeleteBuffers (1 , &m_ibo);
144
157
}
145
158
146
159
inline void RAS_OpenGLRasterizer::ScreenPlane::Render ()
147
160
{
148
- // Bind screen plane VBO/IBO
149
- glBindBufferARB (GL_ARRAY_BUFFER_ARB, m_vbo);
150
- glBindBufferARB (GL_ELEMENT_ARRAY_BUFFER_ARB, m_ibo);
151
-
152
- // Enable vertex/uv pointer.
153
- glEnableClientState (GL_VERTEX_ARRAY);
154
- glEnableClientState (GL_TEXTURE_COORD_ARRAY);
155
-
156
- // Bind vertex/uv pointer with VBO offset. (position = 0, uv = 3*float, stride = 5*float).
157
- glVertexPointer (3 , GL_FLOAT, sizeof (float ) * 5 , 0 );
158
- glTexCoordPointer (2 , GL_FLOAT, sizeof (float ) * 5 , ((char *)nullptr ) + sizeof (float ) * 3 );
159
-
160
- // Draw in traignel fan mode to reduce IBO size.
161
+ glBindVertexArray (m_vao);
162
+ // Draw in triangle fan mode to reduce IBO size.
161
163
glDrawElements (GL_TRIANGLE_FAN, 4 , GL_UNSIGNED_BYTE, 0 );
162
164
163
- // Disable vertex/uv pointer.
164
- glDisableClientState (GL_VERTEX_ARRAY);
165
- glDisableClientState (GL_TEXTURE_COORD_ARRAY);
166
-
167
- // Unbind screen plane VBO/IBO.
168
- glBindBufferARB (GL_ARRAY_BUFFER_ARB, 0 );
169
- glBindBufferARB (GL_ELEMENT_ARRAY_BUFFER_ARB, 0 );
165
+ glBindVertexArray (0 );
170
166
}
171
167
172
168
RAS_OpenGLRasterizer::RAS_OpenGLRasterizer (RAS_Rasterizer *rasterizer)
0 commit comments