i'm trying to put d3d_model_vertex data into a dll hoping that the dll could write a txt file and load it into game maker with d3d_model_load faster than gml can be interpreted. it isn't faster though. i can't call modelUpdate every step because it lags the game to death. must be because of all that writing file stuff.
i guess i'm going to have to keep learning MORE c++ and use gmapi. but i kinda want to get better at my c++ skills. what's the easiest way to call d3d_model_vertex from the dll?
at some point i want to store my point arrays in a model and store models in an array. how could my code below be done better?
#include <iostream> #include <fstream> #define export extern "C" __declspec(dllexport)
using namespace std;
int total=0; int totalDeletedIds=0; int arrayDeletedIds[32000];
double arrayPointx[32000]; double arrayPointy[32000]; double arrayPointz[32000]; double arrayPointNx[32000]; double arrayPointNy[32000]; double arrayPointNz[32000];
export double modelPointAdd(double x,double y,double z,double nx,double ny,double nz) { if(totalDeletedIds==0) { arrayPointx[total]=x; arrayPointy[total]=y; arrayPointz[total]=z; arrayPointNx[total]=nx; arrayPointNy[total]=ny; arrayPointNz[total]=nz; total+=1; return total-1; } else { totalDeletedIds-=1; return arrayDeletedIds[totalDeletedIds]; } }
export double modelPointRemove(double id) { arrayDeletedIds[total]=(int)id; total+=1; return total; }
export double modelPointSetz(double id,double z) { arrayPointz[(int)id]=z; return 1; }
export double modelUpdate() { ofstream myFile("temp.d3d");
if(myFile.is_open()) { myFile<<"100\n"; myFile<<total+2<<"\n"; myFile<<"0 4 0 0 0 0 0 0 0 0 0\n";
for(int i=0;i<total;i+=1) { myFile<<"8 "; myFile<<arrayPointx[i]<<" "; myFile<<arrayPointy[i]<<" "; myFile<<arrayPointz[i]<<" "; myFile<<arrayPointNx[i]<<" "; myFile<<arrayPointNy[i]<<" "; myFile<<arrayPointNz[i]<<" 0 0 0 0\n"; }
myFile<<"1 0 0 0 0 0 0 0 0 0 0"; myFile.close(); return 1; }
return 0; }
|