PDA

View Full Version : Get a txt from file and put it in a matrix



Langkow
01-21-2009, 10:57 AM
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:


#define SIZE_L 10
#define SIZE_C 15
char map[SIZE_L][SIZE_C+1] = {
"##$############",
"####$##########",
"######%########",
};


call the map


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_boards/images/icons/default/grin.gif

satan
01-21-2009, 01:19 PM
'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.