Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


One method of drawing works and another doesnt


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Joshhua5   Members   -  Reputation: 1061

Like
0Likes
Like

Posted 19 August 2013 - 10:54 AM

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);


Sponsor:

#2 Brother Bob   Moderators   -  Reputation: 9470

Like
1Likes
Like

Posted 19 August 2013 - 11:01 AM

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.



#3 Joshhua5   Members   -  Reputation: 1061

Like
0Likes
Like

Posted 19 August 2013 - 11:08 AM

Well There's my problem.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS