Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Get a txt from file and put it in a matrix

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2009
    Posts
    1

    Get a txt from file and put it in a matrix

    Hello! i want to draw objects using openGL (c++) from a matrix, i do this with no problem if i declare the matrix, and call like this:
    Code :
    #define SIZE_L   10
    #define SIZE_C   15
    char map[SIZE_L][SIZE_C+1] = {
    "##$############",
    "####$##########",
    "######%########",
    };
    call the map
    Code :
    void draw()
    {
    	glPushMatrix();
    		glTranslatef(-SIZE_L , 0.01, -SIZE_C);
    		for(int i=0; i<SIZE_L; i++)
    			for(int j=0; j<SIZE_C+1; j++)
    			{
                        if(map[i][j]=='#')
                        drawObject1();	
                      (...)
    	glPopMatrix();
    }

    now i want to draw objects from a matrix but the matrix is in a txt file (for example map.txt). how can i call this file and what do i need (if possible give me a example)?

    Thank you guys !!

    http://www.opengl.org/discussion_boa...fault/grin.gif

  2. #2
    Member Regular Contributor
    Join Date
    Feb 2002
    Posts
    377

    Re: Get a txt from file and put it in a matrix

    'How to get your problem solved'(tm):

    1. You use Google or a C++ forum to find out how to load a text file.

    2. You use your current program just with the content from the file.

    3. You come back here if you have any OpenGL related questions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •