Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm using vertex array to draw 2d geometry, but I can't achieve smoothness.

This is the code I'm using:

glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

glColorPointer(4, GL_UNSIGNED_BYTE, 0, shared_colors);
glVertexPointer(3, GL_FLOAT, 0, shared_vertex);

glDrawArrays(GL_LINES, 0, shared_counter);

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisable(GL_BLEND);

Some advice?

share|improve this question
    
I think that GL_BLEND is used with transparency. Isn't it? –  zacharmarz Sep 3 '11 at 14:39
    
@zacharmarz I think it is also neccessary for GL_LINE_SMOOTH to work properly (which I think is what the OP wants, although "smoothness" is a bit vague a term). –  Christian Rau Sep 3 '11 at 17:06
add comment

2 Answers

Simply use glShadeModel(GL_SMOOTH) when you want to smooth out the colors between your primtitive's vertices. The initial value is GL_SMOOTH, so if you haven't changed it, you'll probably don't need to set it.

If you want smooth lines, use glEnable(GL_LINE_SMOOTH).

share|improve this answer
add comment

Quite some time since i had the pleasure to play with opengl, but one thing comes to mind: Is it not necessary to specify the normals if you want your smooth shading?

share|improve this answer
    
Not if you don't use lighting –  Christian Rau Sep 3 '11 at 17:05
    
Answers are for answers, not further questions. –  Byte56 Nov 14 '12 at 16:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.