Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Linestrip adds extra line at 0,0 (2D space)

This topic is 399 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

im trying to test GL_Line strip by drawing line strips between points and it always starts at 0,0 even i start to draw at the middle of the screen.

i simplified my test data to just draw two points but still the same.

the result is the line is drawn from 0,0 to any points in my vertices.


Im using orthographic projection and pases 2D vectors to my shaders to draw it on 3D, but that is not the concern.

here is my non simplified testing: im trying to draw linestrips using mouse, but it always starts at 0,0


Here is the code (the simplified version/first image)

	float vertices[] = {


		unsigned int VBO = 0;
		unsigned int VAO = 0;
		glGenBuffers(1, &VBO);
		glGenVertexArrays(1, &VAO);
		glBindBuffer(GL_ARRAY_BUFFER, VBO);
		glBufferData(GL_ARRAY_BUFFER, 4 * sizeof(float),			
			vertices, GL_STATIC_DRAW);

		glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), (void*)0);
		glDrawArrays(GL_LINE_STRIP, 0, 4); 

Im using OpenGL 3.1 right now on desktop as i am writing a code that will be ported to OpenGL ES 2.0 after i write it in desktop, (android studio is slow so i do my opengl coding in Visual Studio)

Edited by cebugdev

Share this post

Link to post
Share on other sites
39 minutes ago, _Silence_ said:

Why 4 if you only draw 2 vertices ?

oh god youre correct, silly me, i originally thought that the last parameter is for the number of data.

Thanks man! 

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!