Results 1 to 3 of 3

Thread: Drawing obj file

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2009
    Posts
    7

    Drawing obj file

    OBJ file: download the file
    "0.1 0.2 0.3" after the 1st "v" is the xyz position for the first vertex, and the numbers "0.8 0.8 0.8" after the 1st "vc" is its RGB color. Similarly, three integers after the 1st "f" are vertex indices for the first face.
    when I use
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);
    glVertexPointer(3,GL_FLOAT,0,vertex);
    glColorPointer(3,GL_FLOAT,0,color);
    glDrawElements(GL_TRIANGLES,3*NUMTRIANGLES,GL_UNSI GNED_SHORT,index);
    in VC6,it collapsed,
    how can I draw this obj file?Thanks

  2. #2
    Senior Member Regular Contributor
    Join Date
    Aug 2009
    Posts
    126

    Re: Drawing obj file

    how do you load the OBJ ?
    Maybe you should use a Debugger or show more code

    You also could search for an OBJ loader...


    ^^


  3. #3
    Junior Member Newbie
    Join Date
    Oct 2009
    Posts
    7

    Re: Drawing obj file

    I draw it like this,but it do not work


    #include <math.h>
    #include <stdlib.h>
    #ifdef __APPLE__
    #include <GLUT/glut.h>
    #else
    #include <GL/glut.h>
    #endif
    #include <windows.h>
    #include <stdio.h>
    #include <data.h>
    #define false 0
    #define true 1
    int i;
    void myReshape(int w, int h)
    {
    glViewport(0, 0, w, h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-0.5,0.5,-0.5,0.5,-0.5,0.5);
    glMatrixMode(GL_MODELVIEW);
    }


    void colorcube(void)
    {
    static GLfloat position [] = {0.0,0.0,1.0,1.0};
    static GLfloat color [] = {0.5,0.25,0.0,1.0};
    glLightfv(GL_LIGHT0,GL_POSITION,position);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
    glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFF USE,color);
    glDrawElements(GL_TRIANGLES ,3*NUMTRIANGLES,GL_UNSIGNED_BYTE,index);
    }
    void display(void)
    {
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    colorcube();
    glutSwapBuffers();
    }


    void main(int argc, char **argv)
    {
    glutInit(&amp;argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
    glutInitWindowSize(500, 500);
    glutCreateWindow("Mesh Grid");
    glutReshapeFunc(myReshape);
    glutDisplayFunc(display);

    glEnable(GL_DEPTH_TEST);
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_INDEX_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);
    glVertexPointer(3,GL_FLOAT,0,vertex);
    glIndexPointer(GL_FLOAT,0,index);
    glColorPointer(3,GL_FLOAT,0,color);
    glutMainLoop();
    }


    data of (vertex color index ) in the objfile

Similar Threads

  1. obj file drawing Bezier with deCasteljau without Bernstein
    By yellowbutton in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 06-07-2013, 02:16 AM
  2. Drawing Faces from 3DS file
    By Reaperc89 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 10-24-2011, 05:33 PM
  3. Drawing with a txt file
    By Hellcowboy in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-11-2011, 08:39 PM
  4. Drawing to EMF file
    By AntonHX in forum OpenGL: Advanced Coding
    Replies: 16
    Last Post: 12-15-2009, 04:44 AM
  5. Drawing A Bitmap From File
    By Bobalandi in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 03-03-2008, 11:52 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