Jump to content
  • Advertisement
Sign in to follow this  
JoshuaWaring

One method of drawing works and another doesnt

This topic is 1942 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have two sections of code and one doesn't work which leaves me to question why. I'm using OpenGL 4.1 in the program and drawing with itemediate doesn't affect anything. The purpse of the function is to draw a texture at a position provided, the first drawing code in the snippet is something I ripped of the interwebs to see if it was drawing or some other problem I was having.

	static const GLfloat g_vertex_buffer_data[] = {
		-1.0f, -1.0f, 0.0f,
		1.0f, -1.0f, 0.0f,
		0.0f,  1.0f, 0.0f,
	};

	// This will identify our vertex buffer
	GLuint vertexbuffer;

	// Generate 1 buffer, put the resulting identifier in vertexbuffer
	glGenBuffers(1, &vertexbuffer);

	// The following commands will talk about our 'vertexbuffer' buffer
	glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);

	// Give our vertices to OpenGL.
	glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertex_buffer_data), g_vertex_buffer_data, GL_STATIC_DRAW);

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

	// Draw the triangle !
	glDrawArrays(GL_TRIANGLES, 0, 3); // Starting from vertex 0; 3 vertices total -> 1 triangle

	glDisableVertexAttribArray(0);

	 

	//glEnable(GL_TEXTURE_2D);
	//glBindTexture(GL_TEXTURE_2D, tex.textureID);

	glBegin(GL_QUADS);

	glVertex3d(position.x, position.y, position.z);
	//glTexCoord2i(0,0);
	glVertex3d(position.x + tex.width, position.y, position.z);
	//glTexCoord2i( 1,0);
	glVertex3d(position.x + tex.width, position.y + tex.height, position.z);
	//glTexCoord2i( 1, 1);
	glVertex3d(position.x, position.y + tex.height, position.z);
	//glTexCoord2i(0, 1);

	glEnd(); 

	//glDisable(GL_TEXTURE_2D);

Share this post


Link to post
Share on other sites
Advertisement

Immediate mode rendering was deprecated with OpenGL 3.0 but available in compatibility mode, and later completely removed from the API in, I think, OpenGL 3.2.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!