Skip to content

The usage of OpenGL is not accurate(Template OpenGL-SDL) #148

@tim37021

Description

@tim37021

https://github.com/Pure-D/code-d/blob/master/templates/EmptyOpenGL_SDL/source/app.d#L170

You are using vertex array object(VAO) here. It stores all the necessary information for drawing. There's no need to re-enable attribute arrays and respecify their format.

You can move the following code to loadscene

	glEnableVertexAttribArray(0);
	glVertexAttribPointer(0, // attribute 0. No particular reason for 0, but must match the layout in the shader.
			3, // size
			GL_FLOAT, // type
			false, // normalized?
			0, // stride
			null  // array buffer offset
			);
	glEnableVertexAttribArray(1);
	glBindBuffer(GL_ARRAY_BUFFER, colorBuffer);
	glVertexAttribPointer(1, // attribute 1
			3, // size
			GL_FLOAT, // type
			false, // normalized?
			0, // stride
			null  // array buffer offset
			);

when rendering, simply...:

glBindVertexArray(vao);
glDrawArrays(GL_TRIANGLES, 0, 3);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions