Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

glPolygonMode(GL_BACK,GL_LINE) isn't working

Tags:

opengl

glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);

glPolygonMode(GL_BACK,GL_LINE);

In the above code sample, glPolygonMode throws invalid enum error? How to resolve this issue?

like image 609
suresh Avatar asked Nov 18 '12 07:11

suresh


1 Answers

GL_INVALID_ENUMis generated if either face or mode (respectively the first and second parameter) of your question is not an accepted value. Your first parameter must be GL_FRONT_AND_BACK for front- and back-facing polygons as GL_FRONT and GL_BACK has been deprecated for this method.

EDIT

Since you seems to be asking an other question in your comment. If you want to draw an ink around a filled polygon you should render your geometry two times; render once filled and once wireframe. Slightly shift the wireframe to avoid depth fighting. the two geometries might overlap otherwise

// first draw your polygon filled (this is assuming your glPolygonMode is set to GL_FILL - this is the default mode normally)
// draw your polygons

// offset the wireframe 
glEnable(GL_POLYGON_OFFSET_LINE);
glPolygonOffset(-1,-1);

// draw the wireframe
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
// draw the same polygons again

// restore default polygon mode
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

glDisable(GL_POLYGON_OFFSET_LINE);
like image 57
tiguero Avatar answered Oct 18 '22 09:10

tiguero