Hello!
I’m quite new to OpenGL, but I’m not to programming.
I’ve write some OBJ reader for one of my classes in the college, and happens that I’ve done so in a Mac OS, but my teacher wants it running in Windows.
So, I’ve created a new project in Visual Studio and set it up in order to use GLUT properly.
Everything compiles without me needing to change anything (besides the “#include glut” line in one of my header files).
So, in the Mac OS X my reader worked just fine, no major problem with it, but in Windows it just wont draw some polygons (and I can’t figure out why!)
Here are some screen shots of the software working in Mac OS and Windows:
[ATTACH=CONFIG]1032[/ATTACH][ATTACH=CONFIG]1033[/ATTACH]
As you can see, in the Windows OS it only draw the lower teethes of the “trex.obj” that I’m reading and the basic gizmos (text and stuff, nothing complex)
Here is the code that does the drawing:
void ObjRenderer::Draw(Point p_where)
{
Object* __object = _object;
for(int grupo = 0; grupo < __object->groups.size(); grupo++)
{
Group* __group = &__object->groups[grupo];
for(int face = 0; face < __group->faces.size(); face++)
{
Face* __face = &__group->faces[face];
auto __drawPointsAction = [&]()
{
for (int vertex = 0; vertex < __face->vertexes.size(); vertex++)
{
Vertex* __toDraw = &__face->vertexes[vertex];
Vector3 __point = _parent->points[__toDraw->point];
//Vector3 __normal = _parent->normals[__toDraw->normal];
float __x, __y, __z;
__x = p_where.x + (__point.x * scale);
__y = p_where.y + (__point.y * scale);
__z = p_where.z + (__point.z * scale);
glVertex3f(__x, __y, __z);
//glNormal3f(__normal.x, __normal.y, __normal.z);
}
};
if(this->_drawType == -1)
{
glBegin(GL_POLYGON);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glColor3f(this->_drawColor->r, this->_drawColor->g, this->_drawColor->b);
__drawPointsAction();
glEnd();
glBegin(GL_LINE_LOOP);
glColor3f(this->_drawColor->r * 0.7f, this->_drawColor->g * 0.7f, this->_drawColor->b * 0.7f);
__drawPointsAction();
glEnd();
}
else
{
glColor3f(this->_drawColor->r, this->_drawColor->g, this->_drawColor->b);
glBegin(this->_drawType);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
__drawPointsAction();
glEnd();
}
glBegin(GL_LINE);
}
}
glColor3f(1, 1, 1);
}
I have NO IDEA why this is happening, it is quite making me hate c++
I’ve asked for help in this matter in the facebook group of my class, but no one could help me there =S
I really hope some of you guys have any idea on how to fix this!
THX A LOT FOR YOUR TIME!