T
[theSparrow]
Gast
so ich verstehs einfach nicht und komm nicht dahinter:
Ich programmier grad Opengl und da hab ich folgendes:
Folgende Strukturen:
dann wird das so initialisiert:
und dann gibt es folgendes problem:
wenn ich dann die dreiecke usw. zeichnen will und auf die struktur zugreife wie folgt,
funktioniert es:
aber so:
stürtzt das Programm ab!!!
Warum?
Ich kanns drehen und wenden wie ichs will es geht nicht?
Ich weiß echt nicht mehr weiter... wenn ich sofort statische arrays nim, funkt es normal, aber da ich die anzahl der arrays eigentlich aus einer datei lese sollten sie dynamisch sein aber es workt hintn und vorne nicht.
Was muss ich anders machen?
danke schonmal
mfg
Ich programmier grad Opengl und da hab ich folgendes:
Folgende Strukturen:
Code:
struct KOPOS
{
float fx,fy,fz;
float ftx,fty;
};
struct TRIANGLE
{
KOPOS kopos[3];
int iTex;
float alpha;
float r,g,b;
};
struct CIRCLE
{
KOPOS kopos;
float rad;
int iTex;
float alpha;
float r,g,b;
};
struct CYLINDER
{
KOPOS kopos;
float inrad;
float outrad;
float length;
int iTex;
float alpha;
float r,g,b;
};
struct SECTOR
{
long lnumTriangle;
long lnumCircle;
long lnumCylinder;
long lnumObjects;
TRIANGLE *triangle;
CIRCLE *circle;
CYLINDER *cylinder;
};
dann wird das so initialisiert:
Code:
int lnumTriangle=2;
int lnumCircle=2;
int lnumCylinder=2;
sSector0.triangle= new TRIANGLE[lnumTriangle];
sSector0.circle= new CIRCLE[lnumCircle];
sSector0.cylinder= new CYLINDER[lnumCylinder];
und dann gibt es folgendes problem:
wenn ich dann die dreiecke usw. zeichnen will und auf die struktur zugreife wie folgt,
funktioniert es:
Code:
[...]
int i=0;
for(i=0; i<sSector0.lnumTriangle; ++i)
{
float get=sSector0.triangle[i].r;
[...]
aber so:
Code:
[...]
int i=0;
float get=sSector0.triangle[i].r;
for(i=0; i<sSector0.lnumTriangle; ++i)
{
[...]
Warum?
Ich kanns drehen und wenden wie ichs will es geht nicht?
Ich weiß echt nicht mehr weiter... wenn ich sofort statische arrays nim, funkt es normal, aber da ich die anzahl der arrays eigentlich aus einer datei lese sollten sie dynamisch sein aber es workt hintn und vorne nicht.
Was muss ich anders machen?
danke schonmal
mfg