PDA

View Full Version : I'm able to render with element buffers but not GLbegin/GLend?



bNoCoad
06-21-2015, 05:29 PM
I'm trying to render simple lines, for some reason, this code...


while (!glfwWindowShouldClose(window))
{
glfwPollEvents();

glClearColor(0,0,0,1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D,TX_RECON);
glUniform1i(TEX_S,0);

glBegin(GL_LINES);
glVertex2f(0,0);
glVertex2f(100,100);
glEnd();

glfwSwapBuffers(window);
}

... doesn't work.

I can render element buffers fine but I'd rather use glBegin for what I'm planning to do.

Is there some way to fix this? Or are there other ways to render simple lines?

Alfonse Reinheart
06-21-2015, 07:25 PM
First, it's not clear if you're creating a compatibility context (https://www.opengl.org/wiki/Compatibility_context) or not. If not, then you don't have access to glBegin/glEnd, or any of the other compatibility functionality.

Second, if you're using a vertex shader (which is what it seems like, as you use glUniform1i), then your vertex shader needs to use the appropriate input to receive and process the vertex data. gl_Vertex, in your case.