Results 1 to 4 of 4

Thread: Code not wirking on windows =S

  1. #1
    Junior Member Newbie
    Join Date
    May 2015
    Posts
    3

    Exclamation Code not wirking on windows =S

    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:
    Mac.jpgwindows.jpg

    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:
    Code :
    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!

  2. #2
    Junior Member Newbie
    Join Date
    May 2015
    Posts
    3
    I just checked, it seems to be happening only with big objs (more than 10k polygons)
    WTH?! No one has ever seems something like this b4?!

  3. #3
    Senior Member Regular Contributor
    Join Date
    Dec 2010
    Location
    Oakville, ON, CA
    Posts
    165
    Strange problem. Memory fragmentation, buffer overflow?
    If the drawing code the same, check if the window has depth buffer and it is cleared each frame and the SwapBuffers() called. Maybe?..

  4. #4
    Junior Member Newbie
    Join Date
    May 2015
    Posts
    3
    Problem solved =P

    The problem was actually in the method that I was using to read the .obj file.
    Not sure what happened in there, but it was reading the line breaks "\n" differently from mac to windows...
    That way it was messing up with my internal obj structure and only the first group of objects in the .obj was being loaded (the lower teethes).

Similar Threads

  1. Converting code from Linux to Windows
    By pvncheck in forum OpenGL: Windows
    Replies: 5
    Last Post: 05-17-2011, 08:13 AM
  2. C code working in Linux but not in Windows
    By Bernie_82 in forum OpenGL: Windows
    Replies: 15
    Last Post: 04-19-2004, 01:15 AM
  3. GLUT with Code Warrior for windows please help
    By Pancho in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 12-06-2003, 10:49 AM
  4. converting glut code to plain windows ogl code
    By TheLastMohican in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-10-2003, 09:50 AM
  5. closing glut windows from within code
    By neilw in forum OpenGL: General
    Replies: 2
    Last Post: 10-25-2002, 10:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean