0
votes

I am newbie in Computer Graphics. I was tasked to draw shape without shaders. But as I understand from internet SMOTHING and using LIGHTS should be used to draw beautiful shape. But I could not use them since I could not render my normals. In short, I have 3D vertices, indices, normals. I am using Vertex buffer Object to render vertices and indices. So my code is:

        glGenBuffers(3, vertexObjectBuffer);

        glBindBuffer(GL_ARRAY_BUFFER,  vertexObjectBuffer[0]);
        glBufferData(GL_ARRAY_BUFFER, sizeof(float) * numVertex * 3 , vertex, GL_STATIC_DRAW);
        glEnableVertexAttribArray(0);
        glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
        //glGenBuffers(1, &vertexObjectBuffer[1]);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vertexObjectBuffer[1]);
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(float) * numIndicies * 3 , indices, GL_STATIC_DRAW);

The question is how to send normals if I use Vertex buffer Object but without shaders?

1

1 Answers

2
votes

If you are using OpenGL ES 2.x onwards you have to use shaders; no shader = no rendering. All inputs are defined by your shader, so to pass in a normal just set up a new vertex attribute which contains the normal data and pass it in via another call to glVertexAttribPointer(). It sounds like you are just starting out, so just get basic shaders working first though ;)

If you are using OpenGL ES 1.1 you don't need shaders, but have to use the fixed function rendering pipeline. You can set per-vertex normals via glNormal3[x|f]() if you are specifying single verts (really don't) or glNormalPointer() if you are passing in a vertex buffer object.

In all honesty learn shaders; they are not really all that complicated, and learning that will teach you want you need for every modern graphics API so it's a very useful skill to learn.