Using glfw to draw sprites

I am trying to draw 2 sprites to the screen so far I am able only to draw one. here is my code.

		// Set up vertex data (and buffer(s)) and attribute pointers
		GLfloat vertices[] =
		{
			// Positions          // Colors           // Texture Coords
			-0.10f+move_x,  -1.0f, 0.0f,   1.0f, 0.0f, 0.0f,   1.0f, 1.0f, // Top Right
			-0.10f+move_x, -0.80f, 0.0f,   0.0f, 1.0f, 0.0f,   1.0f, 0.0f, // Bottom Right
			0.10f+move_x, -0.80f, 0.0f,   0.0f, 0.0f, 1.0f,   0.0f, 0.0f, // Bottom Left
			0.10f+move_x,  -1.0f, 0.0f,   1.0f, 1.0f, 0.0f,   0.0f, 1.0f  // Top Left
		};
		GLuint indices[] =
		{  // Note that we start from 0!
			0, 1, 3, // First Triangle
			1, 2, 3  // Second Triangle
		};
		GLuint indices_one[] =
		{  // Note that we start from 0!
			0, 1, 3, // First Triangle
			1, 2, 3  // Second Triangle
		};
		GLfloat vertices_one[] =
		{
			// Positions          // Colors           // Texture Coords
			-0.10f,  1.0f, 0.0f,   1.0f, 0.0f, 0.0f,   1.0f, 1.0f, // Top Right
			-0.10f, 0.80f, 0.0f,   0.0f, 1.0f, 0.0f,   1.0f, 0.0f, // Bottom Right
			0.10f, 0.80f, 0.0f,   0.0f, 0.0f, 1.0f,   0.0f, 0.0f, // Bottom Left
			0.10f,  1.0f, 0.0f,   1.0f, 1.0f, 0.0f,   0.0f, 1.0f  // Top Left
		};
		GLuint VBO, VAO, EBO;
		GLuint VBO_one, VAO_one, EBO_one;
		glGenVertexArrays(1, &VAO);
		glGenVertexArrays(1, &VAO_one);
		glBindVertexArray(VAO);
		glBindVertexArray(VAO_one);

		glGenBuffers(1, &VBO);
		glGenBuffers(1, &EBO);
		glGenBuffers(1, &VBO_one);
		glGenBuffers(1, &EBO_one);


		glBindBuffer(GL_ARRAY_BUFFER, VBO);
		glBufferData(GL_ARRAY_BUFFER, sizeof(vertices_one), vertices_one, GL_STATIC_DRAW);

		glBindBuffer(GL_ARRAY_BUFFER, VBO_one);
		glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
		glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);

		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO_one);
		glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices_one), indices_one, GL_STATIC_DRAW);
		// Position attribute
		glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid *)0);
		glEnableVertexAttribArray(0);
		// Color attribute
		glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid *)(3 * sizeof(GLfloat)));
		glEnableVertexAttribArray(1);
		// Texture Coordinate attribute
		glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid *)(6 * sizeof(GLfloat)));
		glEnableVertexAttribArray(2);

		glBindVertexArray(0); // Unbind VAO

		// Load and create a texture
		GLuint texture;

		int width, height;

		// ===================
		// Texture
		// ===================
		glGenTextures(1, &texture);
		glBindTexture(GL_TEXTURE_2D, texture);
		// Set our texture parameters
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
		// Set texture filtering
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		// Load, create texture and generate mipmaps
		unsigned char *image = SOIL_load_image("res/images/plane.jpg", &width, &height, 0, SOIL_LOAD_RGBA);
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
		glGenerateMipmap(GL_TEXTURE_2D);
		SOIL_free_image_data(image);
		glBindTexture(GL_TEXTURE_2D, 0);

		GLuint texture_one;

		int width_one, height_one;

		// ===================
		// Texture
		// ===================
		glGenTextures(1, &texture_one);
		glBindTexture(GL_TEXTURE_2D, texture_one);
		// Set our texture parameters
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
		// Set texture filtering
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		// Load, create texture and generate mipmaps
		unsigned char *image_one = SOIL_load_image("res/images/plane.jpg", &width_one, &height_one, 0, SOIL_LOAD_RGBA);
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width_one, height_one, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_one);
		glGenerateMipmap(GL_TEXTURE_2D);
		SOIL_free_image_data(image_one);
		glBindTexture(GL_TEXTURE_2D, 0);

can I get a response to my question

The first glBindVertexArray call is redundant because the second call immediately overwrites the binding.

This populates both VBOs and both EBOs with data. Upon completion, VBO_one is bound to GL_ARRAY_BUFFER while EBO_one is bound to GL_ELEMENT_ARRAY_BUFFER.

This configures the data sources for three attributes, all of which source from VBO_one. The attribute state and EBO binding are stored in VAO_one. VAO never changes from its initial state; neither VBO nor EBO are used for anything.

In order to make use of VBO and EBO, you need to repeat the above block of code after calling

		glBindVertexArray(VAO);
		glBindBuffer(GL_ARRAY_BUFFER, VBO);

Note that you’ll also need two calls to glDrawElements, one with VAO bound and one with VAO_one bound.

thanks for the input, I am working on my program, is there anywhere I can learn more about VAO’s and VBO’s and EBO’s.

well I reworked my code but am still stuck, need a little help. here is my code.

		// Set up vertex data (and buffer(s)) and attribute pointers
		GLfloat vertices[] =
		{
			// Positions          // Colors           // Texture Coords
			-0.10f+move_x,  -1.0f, 0.0f,   1.0f, 0.0f, 0.0f,   1.0f, 1.0f, // Top Right
			-0.10f+move_x, -0.80f, 0.0f,   0.0f, 1.0f, 0.0f,   1.0f, 0.0f, // Bottom Right
			0.10f+move_x, -0.80f, 0.0f,   0.0f, 0.0f, 1.0f,   0.0f, 0.0f, // Bottom Left
			0.10f+move_x,  -1.0f, 0.0f,   1.0f, 1.0f, 0.0f,   0.0f, 1.0f  // Top Left
		};
		GLfloat vertices_one[] =
		{
			// Positions          // Colors           // Texture Coords
			-0.10f + move_x,  1.0f, 0.0f,   1.0f, 0.0f, 0.0f,   1.0f, 1.0f, // Top Right
			-0.10f + move_x, 0.80f, 0.0f,   0.0f, 1.0f, 0.0f,   1.0f, 0.0f, // Bottom Right
			0.10f + move_x, 0.80f, 0.0f,   0.0f, 0.0f, 1.0f,   0.0f, 0.0f, // Bottom Left
			0.10f + move_x,  1.0f, 0.0f,   1.0f, 1.0f, 0.0f,   0.0f, 1.0f  // Top Left
		};
		GLuint indices[] =
		{  // Note that we start from 0!
			0, 1, 3, // First Triangle
			1, 2, 3  // Second Triangle
		};
		
		GLuint vbo[2], vao[2];
		vao[0] = 1, vao[1] = 2;

		glGenVertexArrays(2, vao);

		glBindVertexArray(vao[0]);
		glGenBuffers(2, vbo);
		glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
		glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
		glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid *)0);
		glEnableVertexAttribArray(0);
		glBindBuffer(GL_ARRAY_BUFFER, 0);
		glBindVertexArray(0);

		glBindVertexArray(vao[1]);
		glBindBuffer(GL_ARRAY_BUFFER, vbo[1]);
		glBufferData(GL_ARRAY_BUFFER, sizeof(vertices_one), vertices_one, GL_STATIC_DRAW);
		glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid *)0);
		glEnableVertexAttribArray(0);
		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
		glBindVertexArray(0);

		GLuint EBO = 0;
		glGenBuffers(1, &EBO);
		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
		glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);

This needs to be done with a VAO bound (the GL_ELEMENT_ARRAY_BUFFER binding is stored in the EBO rather than in the context). So in this case you’d need to do it for both VAOs, e.g.

	glBindVertexArray(vao[0]);
	GLuint EBO = 0;
	glGenBuffers(1, &EBO);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
	glBindVertexArray(vao[1]);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
	glBindVertexArray(0);

Alternatively, if you’re only binding the buffer in order to populate it with data, you can bind it to some other binding point, e.g.:

	GLuint EBO = 0;
	glGenBuffers(1, &EBO);
	glBindBuffer(GL_COPY_WRITE_BUFFER, EBO);
	glBufferData(GL_COPY_WRITE_BUFFER , sizeof(indices), indices, GL_STATIC_DRAW);
	glBindBuffer(GL_COPY_WRITE_BUFFER, 0);

Then to assign it within each VAO:

	glBindVertexArray(vao[0]);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
	glBindVertexArray(vao[1]);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
	glBindVertexArray(0);

Having the GL_ELEMENT_ARRAY_BUFFER binding stored in the VAO is useful (it’s typical to want to use a different index array whenever you use a different set of attribute arrays), but it can be a bit confusing because it makes that specific binding point behave differently to the others.

are there any sites where I can learn more about VAO’s , VBO’s and EBO’s?

There are many places to learn about vertex specification. You could even Google those terms rather than asking us to do that for you.

well I printed out the modernopengl book and am reading it hopefully it will help.

I am still confused on how to use vao’s and vbo’s and ebo’s is there anything I can do to remedy this situation.

Simply saying the equivalent of “I don’t get it” doesn’t really allow anyone to know how to help you. We need to know exactly what you do understand and exactly what you don’t understand. If what you don’t understand is just “everything,” then the only thing we can do is re-explain how it works. And since I linked to 4 separate places that contain such explanations, that would be a re-re-re-re-re-explanation. Which, without further information, is unlikely to be useful to you. That is, if 4 separate websites by 3 separate people couldn’t explain it from first-principles in a way that you could understand, then how likely is it that a 4th person could succeed?

So here is a sort of quiz to help us help you. Describe the following subjects as clearly and completely as you can. If you can’t explain a topic, try your best to explain it, then explain what you don’t understand about it.

  • OpenGL objects. This description should include, but is not limited to:
    • how objects are created
    • how objects are bound
    • how binding an object affects OpenGL and the behavior of subsequent OpenGL commands
  • The overall function of a VAO. That is, what you are trying to accomplish by creating/using it.
  • The function of a buffer object.
  • The nature of a vertex attribute.
  • The concept of a vertex array.
  • The association between arrays of vertex data and the vertex attribute that will consume them.

well I did what you said to do. I made 2 vertex arrays and 2 buffers I used glGenVertexArrays to make v ertex arrays and glGenBuffers to make buffers. I also used vao and vao_one to glBindBuffer and glBindVertexArray but glBufferData draws only one sprite which is the one using vertices_one array. I want to draw 2 sprite objects. here is my updated code.
// Set up vertex data (and buffer(s)) and attribute pointers
GLfloat vertices[] =
{
// Positions // Colors // Texture Coords
-0.10f + move_x, -1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, // Top Right
-0.10f + move_x, -0.80f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, // Bottom Right
0.10f + move_x, -0.80f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, // Bottom Left
0.10f + move_x, -1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f // Top Left
};
GLfloat vertices_one[] =
{
// Positions // Colors // Texture Coords
-0.10f + move_x, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, // Top Right
-0.10f + move_x, 0.80f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, // Bottom Right
0.10f + move_x, 0.80f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, // Bottom Left
0.10f + move_x, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f // Top Left
};
GLuint indices[] =
{ // Note that we start from 0!
0, 1, 3, // First Triangle
1, 2, 3 // Second Triangle
};
GLuint VBO=0, VAO=0, EBO=0, VAO_one=0, VBO_one=0, EBO_one=0;
glGenVertexArrays(2, &VAO);
glGenBuffers(2, &VBO);
glGenBuffers(2, &EBO);

	glBindVertexArray(VAO_one);
	glBindBuffer(GL_ARRAY_BUFFER, VBO_one);
	glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

	glBindVertexArray(VAO);
	glBindBuffer(GL_ARRAY_BUFFER, VBO);
	glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices_one, GL_STATIC_DRAW);

	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);

	// Position attribute
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid *)0);
	glEnableVertexAttribArray(0);
	// Color attribute
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid *)(3 * sizeof(GLfloat)));
	glEnableVertexAttribArray(1);
	// Texture Coordinate attribute
	glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid *)(6 * sizeof(GLfloat)));
	glEnableVertexAttribArray(2);

	glBindVertexArray(0); // Unbind VAO

	glBindVertexArray(VAO);
	glBindBuffer(GL_ARRAY_BUFFER, VBO);

	// Position attribute
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid *)0);
	glEnableVertexAttribArray(0);
	// Color attribute
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid *)(3 * sizeof(GLfloat)));
	glEnableVertexAttribArray(1);
	// Texture Coordinate attribute
	glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid *)(6 * sizeof(GLfloat)));
	glEnableVertexAttribArray(2);

	glBindVertexArray(0); // Unbind VAO

well I understand objects better but I am still stuck on my problem, can someone please give me some more advice on my code.

can I please get some more input on my problem

can I please get some more input

I am working very diligently on my problem but I just can’t draw two objects.

well I have done a lot of googling on my problem but I cant seem to figure out how to draw two sprites on the screen here is my code so far this seems like it should work.
GLuint VBO=0, VAO=0, EBO=0, VAO_one=0, VBO_one=0, EBO_one=0;
glGenVertexArrays(2, &VAO);
glGenBuffers(2, &VBO);
glGenBuffers(2, &EBO);

	glBindVertexArray(VAO_one);
	glBindBuffer(GL_ARRAY_BUFFER, VBO_one);
	glBufferData(GL_ARRAY_BUFFER, sizeof(vertices_one), vertices_one, GL_DYNAMIC_DRAW);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid *)0);
	glEnableVertexAttribArray(0);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid *)(3 * sizeof(GLfloat)));
	glEnableVertexAttribArray(1);
	glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid *)(6 * sizeof(GLfloat)));
	glEnableVertexAttribArray(2);


	glBindVertexArray(VAO);
	glBindBuffer(GL_ARRAY_BUFFER, VBO);
	glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_DYNAMIC_DRAW);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0 * sizeof(GLfloat), (GLvoid *)0);
	glEnableVertexAttribArray(0);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0 * sizeof(GLfloat), (GLvoid *)(3 * sizeof(GLfloat)));
	glEnableVertexAttribArray(1);
	glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 0 * sizeof(GLfloat), (GLvoid *)(6 * sizeof(GLfloat)));
	glEnableVertexAttribArray(2);


	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO_one);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_DYNAMIC_DRAW);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices_one), indices_one, GL_DYNAMIC_DRAW);

	// Position attribute
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid *)0);
	glEnableVertexAttribArray(0);
	// Color attribute
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid *)(3 * sizeof(GLfloat)));
	glEnableVertexAttribArray(1);
	// Texture Coordinate attribute
	glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid *)(6 * sizeof(GLfloat)));
	glEnableVertexAttribArray(2);

	glBindVertexArray(0); // Unbind VAO