Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use VAO #64

Open
wants to merge 1 commit into
base: Omega
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/StarField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ int CStarField::Create(int iWidth, int iHeight)
if (!LoadShaderFiles(vertShader, fraqShader) || !CompileAndLink())
return -1;

glGenVertexArrays(1, &m_vao);

glGenBuffers(1, &m_vertexVBO);

glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
Expand Down Expand Up @@ -260,6 +262,8 @@ void CStarField::Destroy(void)
glDeleteBuffers(1, &m_vertexVBO);
m_vertexVBO = 0;

glDeleteVertexArrays(1, &m_vao);

#else
SAFE_RELEASE(m_pVBuffer);
SAFE_RELEASE(m_pPShader);
Expand Down Expand Up @@ -430,6 +434,8 @@ void CStarField::DoDraw(void)

size_t nVSize = m_nDrawnStars * POINTSPERSTAR;

glBindVertexArray(m_vao);

EnableShader();

glBindBuffer(GL_ARRAY_BUFFER, m_vertexVBO);
Expand All @@ -451,6 +457,8 @@ void CStarField::DoDraw(void)

DisableShader();

glBindVertexArray(0);

#else
m_pContext->Unmap(m_pVBuffer, 0);
m_pContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINELIST);
Expand Down
3 changes: 2 additions & 1 deletion src/StarField.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ class ATTR_DLL_LOCAL CStarField
// override functions for kodi::gui::gl::CShaderProgram
void OnCompiledAndLinked() override;
bool OnEnabled() override { return true; }


GLuint m_vao = 0;
GLuint m_vertexVBO = 0;
GLint m_aPosition = -1;
GLint m_aColor = -1;
Expand Down