Alright, I'm moving along with this, but I've still got a few problems:
First off, I'll once again make a note that there are only two functions in the header file I'm using. I've used the simpler one to test the cstdio library on. Once more, that function goes by the name "watertable()." The good news is that I've written the correct format to file. The bad news is that the data is meaningless.
Here's the declarations in the "mesh.h" header file:
#pragma once
#include <iostream>
#include <cstdio>
using namespace std;
Disregard <iostream> - I've not yet re-written "quadgen()" and it thus still uses "cout" for output. I'm not sure if <cstdio> needs "namespace std," but it's easy enough to find out if it does or does not...
Here's the current "watertable()" function:
void watertable(FILE *output, int yn, unsigned int x, unsigned int z, double wateralt)
{
if ( yn == 1 )
{
const int ROWS = 4;
const int COLS = 5;
double quad[ ROWS ][ COLS ] = { x, wateralt, 0, 1, 0,
x, wateralt, z, 1, 1,
0, wateralt, z, 0, 1,
0, wateralt, 0, 0, 0 };
fputs( "A\n", output );
fputs( "700\n", output );
fputs( "OBJ\n", output );
fputs( "texture\n", output );
fputs( "quad\n", output );
fprintf( output, "%1i\t%1.3f\t%1i\t%1i\t%1i\n", quad[ 0 ][ 0 ], quad[ 0 ][ 1 ], quad[ 0 ][ 2 ], quad[ 0 ][ 3 ], quad[ 0 ][ 4 ] );
fprintf( output, "%1i\t%1.3f\t%1i\t%1i\t%1i\n", quad[ 1 ][ 0 ], quad[ 1 ][ 1 ], quad[ 1 ][ 2 ], quad[ 1 ][ 3 ], quad[ 1 ][ 4 ] );
fprintf( output, "%1i\t%1.3f\t%1i\t%1i\t%1i\n", quad[ 2 ][ 0 ], quad[ 2 ][ 1 ], quad[ 2 ][ 2 ], quad[ 2 ][ 3 ], quad[ 2 ][ 4 ] );
fprintf( output, "%1i\t%1.3f\t%1i\t%1i\t%1i\n", quad[ 3 ][ 0 ], quad[ 3 ][ 1 ], quad[ 3 ][ 2 ], quad[ 3 ][ 3 ], quad[ 3 ][ 4 ] );
fputs( "end", output );
}
return;
}
Now, here's the usage of the code in the main program:
FileW = fopen( "eaufile.obj", "w" );
if ( FileW != NULL )
{
watertable( FileW, resp, x, z, wateralt );
fclose( FileW );
}
Note that "FILE *FileW;" is declared at the initialization of the program.
Here's the problem - Entering 10 for 'x,' 10 for 'z,' and, oh, say 2 for 'wateralt,' I should get a 10x10 surface two meters in uniform elevation, and the output should look like this:
A
700
OBJ
texture
quad
10 2.000 0 1 0
10 2.000 10 1 1
0 2.000 10 0 1
0 2.000 0 0 0
end
However, the output instead looks like this:
A
700
OBJ
texture
quad
0 0.000 1072693248 0 0
0 0.000 1072693248 0 1076101120
0 0.000 1072693248 0 1076101120
0 0.000 1072693248 0 0
end
I suspect it might be something with reading the matrix entries, maybe? However, that makes very little sense. Would it b better to write the matrix entries as pointers to the individual matrix data locations?