<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[c++ dynamisches array?!? big problem...]]></title><description><![CDATA[<p>so ich verstehs einfach nicht und komm nicht dahinter:<br />
Ich programmier grad Opengl und da hab ich folgendes:</p>
<p>Folgende Strukturen:</p>
<pre><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;

};
</code></pre>
<p>dann wird das so initialisiert:</p>
<pre><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];
</code></pre>
<p>und dann gibt es folgendes problem:<br />
wenn ich dann die dreiecke usw. zeichnen will und auf die struktur zugreife wie folgt,<br />
funktioniert es:</p>
<pre><code>[...]
int i=0;

	for(i=0; i&lt;sSector0.lnumTriangle; ++i)
	{
		float get=sSector0.triangle[i].r;
[...]
</code></pre>
<p>aber so:</p>
<pre><code>[...]
int i=0;
float get=sSector0.triangle[i].r;

	for(i=0; i&lt;sSector0.lnumTriangle; ++i)
	{

[...]
</code></pre>
<p>stürtzt das Programm ab!!!<br />
Warum?<br />
Ich kanns drehen und wenden wie ichs will es geht nicht?<br />
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.<br />
Was muss ich anders machen?</p>
<p>danke schonmal<br />
mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/188779/c-dynamisches-array-big-problem</link><generator>RSS for Node</generator><lastBuildDate>Fri, 03 Jul 2026 04:29:40 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/188779.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 03 Aug 2007 17:53:35 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to c++ dynamisches array?!? big problem... on Fri, 03 Aug 2007 17:53:35 GMT]]></title><description><![CDATA[<p>so ich verstehs einfach nicht und komm nicht dahinter:<br />
Ich programmier grad Opengl und da hab ich folgendes:</p>
<p>Folgende Strukturen:</p>
<pre><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;

};
</code></pre>
<p>dann wird das so initialisiert:</p>
<pre><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];
</code></pre>
<p>und dann gibt es folgendes problem:<br />
wenn ich dann die dreiecke usw. zeichnen will und auf die struktur zugreife wie folgt,<br />
funktioniert es:</p>
<pre><code>[...]
int i=0;

	for(i=0; i&lt;sSector0.lnumTriangle; ++i)
	{
		float get=sSector0.triangle[i].r;
[...]
</code></pre>
<p>aber so:</p>
<pre><code>[...]
int i=0;
float get=sSector0.triangle[i].r;

	for(i=0; i&lt;sSector0.lnumTriangle; ++i)
	{

[...]
</code></pre>
<p>stürtzt das Programm ab!!!<br />
Warum?<br />
Ich kanns drehen und wenden wie ichs will es geht nicht?<br />
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.<br />
Was muss ich anders machen?</p>
<p>danke schonmal<br />
mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1338347</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1338347</guid><dc:creator><![CDATA[progsepp]]></dc:creator><pubDate>Fri, 03 Aug 2007 17:53:35 GMT</pubDate></item><item><title><![CDATA[Reply to c++ dynamisches array?!? big problem... on Fri, 03 Aug 2007 20:18:28 GMT]]></title><description><![CDATA[<p>Hm Dein Code sieht ziemlich zerissen aus...kann nicht genau sagen, obs daran liegt. Sieht soweit funktiontsfähig aus. Was sagt Dir denn der Debugger, wo es *genau* kracht? Achja, noch ein Tipp: Du solltest sinnigerweise std::vector verwenden, da sind ja Access-Violation's bzw. Speicherleaks vorprogrammiert <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /> .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1338402</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1338402</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Fri, 03 Aug 2007 20:18:28 GMT</pubDate></item><item><title><![CDATA[Reply to c++ dynamisches array?!? big problem... on Fri, 03 Aug 2007 20:27:30 GMT]]></title><description><![CDATA[<p>progsepp schrieb:</p>
<blockquote>
<p>wenn ich dann die dreiecke usw. zeichnen will und auf die struktur zugreife wie folgt,<br />
funktioniert es:</p>
<pre><code>[...]
int i=0;

	
	for(i=0; i&lt;sSector0.lnumTriangle; ++i)
	{
		float get=sSector0.triangle[i].r;
[...]
</code></pre>
<p>aber so:</p>
<pre><code>[...]
int i=0;
float get=sSector0.triangle[i].r;
	
	for(i=0; i&lt;sSector0.lnumTriangle; ++i)
	{
		
[...]
</code></pre>
<p>stürtzt das Programm ab!!!</p>
</blockquote>
<p>der erste code verwendet das 'i' aus der schleife, der zweite ein anderes 'i', das möglicherweise so gross ist, dass du über die arraygrenze hinaus zugreifst.<br />
<img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1338412</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1338412</guid><dc:creator><![CDATA[Undertaker]]></dc:creator><pubDate>Fri, 03 Aug 2007 20:27:30 GMT</pubDate></item><item><title><![CDATA[Reply to c++ dynamisches array?!? big problem... on Fri, 03 Aug 2007 20:33:09 GMT]]></title><description><![CDATA[<p>Das andere 'i' wird direkt darüber definiert und ist 0 <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f4a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--light_bulb"
      title=":bulb:"
      alt="💡"
    /> (sieht zum mindestens in Seinem Code so aus).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1338417</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1338417</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Fri, 03 Aug 2007 20:33:09 GMT</pubDate></item><item><title><![CDATA[Reply to c++ dynamisches array?!? big problem... on Sat, 04 Aug 2007 06:52:18 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/12048">@CodeFinder</a>:<br />
Ja beim debuggen bekomm ich immer AccessViolation errors... genau an der Stelle wos sonst immer abstürzt...<br />
was meinst du mit std::vector? wos soll ich das verwenden?</p>
<p>Danke,<br />
mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1338513</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1338513</guid><dc:creator><![CDATA[progsepp]]></dc:creator><pubDate>Sat, 04 Aug 2007 06:52:18 GMT</pubDate></item><item><title><![CDATA[Reply to c++ dynamisches array?!? big problem... on Sat, 04 Aug 2007 08:49:57 GMT]]></title><description><![CDATA[<p>progsepp schrieb:</p>
<blockquote>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/12048">@CodeFinder</a>:<br />
Ja beim debuggen bekomm ich immer AccessViolation errors... genau an der Stelle wos sonst immer abstürzt...</p>
</blockquote>
<p>Und an welcher Stelle <strong>genau</strong> ist das? (hast du mal überprüft, ob lnumTriangle nicht gleich 0 ist?)</p>
<blockquote>
<p>was meinst du mit std::vector? wos soll ich das verwenden?</p>
</blockquote>
<p>Anstelle deiner blanken Arrays:</p>
<pre><code class="language-cpp">struct SECTOR
{
    vector&lt;TRIANGLE&gt; triangle;
    vector&lt;CIRCLE&gt; circle;
    vector&lt;CYLINDER&gt; cylinder;

/*  long lnumTriangle;
    long lnumCircle;
    long lnumCylinder;
    long lnumObjects;

    TRIANGLE *triangle;
    CIRCLE *circle;
    CYLINDER *cylinder;
*/  
};

int lnumTriangle=2;
int lnumCircle=2;
int lnumCylinder=2;
sSector0.triangle.resize(lnumTriangle);
sSector0.circle.resize(lnumCircle);
sSector0.cylinder.resize(lnumCylinder)];
</code></pre>
<p>(btw, beim Durchsehen deines Codes ist mir noch etwas aufgefallen - du hast die Zähler-Werte 'lnum...' deines SECTOR nicht initialisiert)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1338535</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1338535</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Sat, 04 Aug 2007 08:49:57 GMT</pubDate></item><item><title><![CDATA[Reply to c++ dynamisches array?!? big problem... on Sat, 04 Aug 2007 09:31:04 GMT]]></title><description><![CDATA[<p>genau bei der forschleife sind die access violations... also wenn ich auf triangle... zugreife.</p>
<p>wenn ich den code abändere:</p>
<p>struct SECTOR<br />
{<br />
long lnumTriangle;<br />
long lnumCircle;<br />
long lnumCylinder;<br />
long lnumObjects;</p>
<p>vector&lt;TRIANGLE&gt; triangle;<br />
vector&lt;CIRCLE&gt; circle;<br />
vector&lt;CYLINDER&gt; cylinder;</p>
<p>/<em>TRIANGLE triangle[10];<br />
CIRCLE circle[10];<br />
CYLINDER cylinder[10];</em>/</p>
<p>};</p>
<p>sSector0.triangle.resize(inumTriangle);<br />
sSector0.circle.resize(inumCircle);<br />
sSector0.cylinder.resize(inumCylinder);</p>
<p>bekomm ich 85 fehler; von wegen triangle sei kein object von sector usw...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1338544</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1338544</guid><dc:creator><![CDATA[progsepp]]></dc:creator><pubDate>Sat, 04 Aug 2007 09:31:04 GMT</pubDate></item><item><title><![CDATA[Reply to c++ dynamisches array?!? big problem... on Sat, 04 Aug 2007 09:37:30 GMT]]></title><description><![CDATA[<p>Welches ist denn der erste Fehler der dabei auftritt?</p>
<p>Ich würde spontan tippen auf &quot;nicht deklarierter Bezeichner vector&quot; - wenn ich richtig liege: du mußt &lt;vector&gt; includen und an den Namensraum std:: denken:</p>
<pre><code class="language-cpp">#include &lt;vector&gt;
using std::vector;
...//der Rest wie gehabt
</code></pre>
<p>(btw, die lnum... Member brauchst du nicht wirklich - die Anzahl deiner Dreiecke etc kannst du besser über <code>sSector0.triangles.size()</code> ermitteln (das macht weniger Aufwand als wenn du ständig von Hand nachzählen müsstest)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1338546</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1338546</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Sat, 04 Aug 2007 09:37:30 GMT</pubDate></item><item><title><![CDATA[Reply to c++ dynamisches array?!? big problem... on Sat, 04 Aug 2007 09:42:42 GMT]]></title><description><![CDATA[<p>so jetzt hat er compiliert...<br />
allerdings wenn ich wieder auf die variablen zugreifen will, zag violation error.</p>
<p>ich hab aber auch probiert auf die in der Sector struktur deklarierten lnum... zuzugreifen, das funktioniert, nur ebm auf die dynamischen will er einfach nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1338554</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1338554</guid><dc:creator><![CDATA[progseep]]></dc:creator><pubDate>Sat, 04 Aug 2007 09:42:42 GMT</pubDate></item><item><title><![CDATA[Reply to c++ dynamisches array?!? big problem... on Sat, 04 Aug 2007 11:31:31 GMT]]></title><description><![CDATA[<p>Achte mal auf die Reihenfolge, in der du durch das Programm läufst - hast du die Größe der vector&lt;&gt;en gesetzt, BEVOR du versucht hast, etwas in ihnen zu lesen?</p>
<p>(ein default-konstruierter vector&lt;&gt; ist leer - also ist es in dem Zustand verboten, irgendwas aus seinen Innereien herauszulesen)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1338604</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1338604</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Sat, 04 Aug 2007 11:31:31 GMT</pubDate></item><item><title><![CDATA[Reply to c++ dynamisches array?!? big problem... on Sun, 05 Aug 2007 12:58:39 GMT]]></title><description><![CDATA[<p>ja hab ich alles gemacht... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":-("
      alt="😞"
    /> ich verstehs einfach nicht...<br />
danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1338980</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1338980</guid><dc:creator><![CDATA[progsepp]]></dc:creator><pubDate>Sun, 05 Aug 2007 12:58:39 GMT</pubDate></item><item><title><![CDATA[Reply to c++ dynamisches array?!? big problem... on Mon, 06 Aug 2007 06:59:17 GMT]]></title><description><![CDATA[<p>Mit den paar Fragmenten versteh' ich's auch nicht. Zeig doch mal ein zusammenhängedes Programm, in dem dein Problem auftritt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1339340</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1339340</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 06 Aug 2007 06:59:17 GMT</pubDate></item><item><title><![CDATA[Reply to c++ dynamisches array?!? big problem... on Mon, 06 Aug 2007 19:15:28 GMT]]></title><description><![CDATA[<p>also wie gehabt die deklaration:</p>
<pre><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;

};

SECTOR sSector0;
</code></pre>
<p>dann die zuweisung:</p>
<pre><code>char* fgetsN(FILE* fFile)
{
	char* cbuffer=(char*)malloc(256);
	while(!feof(fFile))
	{
		fgets(cbuffer,255,fFile);
		if((cbuffer[0]!='\n')&amp;&amp;(cbuffer[0]!='/')&amp;&amp;(cbuffer[0]!=' '))
			return (char*)cbuffer;
	}

	return (char*)&quot;_eof_&quot;;

}

GLvoid GL_Load_Objects()
{
	FILE* fObjects;
	fObjects = fopen(&quot;data\\model.txt&quot;, &quot;r&quot;);
	char* buffer=(char*)malloc(256);
	char cObject[256];
	char cBitmapPathBuf[256];

	while(!feof(fObjects))
	{

		 buffer=fgetsN(fObjects);

		 sscanf(buffer,&quot;NUMTRIANGLE %d\n&quot;,&amp;inumTriangle);
		 sSector0.lnumTriangle=inumTriangle;

		 buffer=fgetsN(fObjects);
		 sscanf(buffer,&quot;NUMCIRCLE %d\n&quot;,&amp;inumCircle);
		 sSector0.lnumCircle=inumCircle;

		 buffer=fgetsN(fObjects);
		 sscanf(buffer,&quot;NUMCYLINDER %d\n&quot;,&amp;inumCylinder);
		 sSector0.lnumCylinder=inumCylinder;

		break;

	}

	sSector0.triangle= new TRIANGLE[inumTriangle];
	sSector0.circle= new CIRCLE[inumCircle];
	sSector0.cylinder= new CYLINDER[inumCylinder];

	int numtriangle=0;
	int numcircle=0;
	int numcylinder=0;

	sSector0.lnumObjects=sSector0.lnumTriangle+sSector0.lnumCircle+sSector0.lnumCylinder;

	while(!feof(fObjects))
	{

		 buffer=fgetsN(fObjects);

		 sscanf(buffer,&quot;BITNUM %i&quot;,&amp;bitnum);

		 for(int i=0; i&lt;bitnum; i++)
		 {
			buffer=fgetsN(fObjects);
			sscanf(buffer,&quot;BITTEX %s\n&quot;,&amp;cBitmapPathBuf);
			strcpy(cBitmapPath[i],cBitmapPathBuf);

		 }

		break;

	}

	float fx,fy,fz;
	float ftx,fty;
	float r,g,b;
	float alpha;
	int itex;
	float rad,inrad,outrad,length;

	while(true)
	{
		buffer=fgetsN(fObjects);

		if(!strcmp(buffer,&quot;_eof_&quot;))
			break;

		strcpy(cObject,&quot;&quot;);
		sscanf(buffer,&quot;OBJECT %s\n&quot;,&amp;cObject);

		if(!strcmp(cObject,&quot;TRIANGLE&quot;))
		{
			buffer=fgetsN(fObjects);
			sscanf(buffer,&quot;TEX %i\n&quot;,&amp;itex);
			sSector0.triangle[numtriangle].iTex=itex;

			buffer=fgetsN(fObjects);
			sscanf(buffer,&quot;ALPHA %f\n&quot;,&amp;alpha);
			sSector0.triangle[numtriangle].alpha=alpha;

			buffer=fgetsN(fObjects);
			sscanf(buffer,&quot;RGB %f %f %f\n&quot;,&amp;r,&amp;g,&amp;b);

			sSector0.triangle[numtriangle].r=r;
			sSector0.triangle[numtriangle].g=g;
			sSector0.triangle[numtriangle].b=b;

			for(int i=0; i&lt;3; i++)
			{
				buffer=fgetsN(fObjects);
				sscanf(buffer, &quot;%f %f %f %f %f&quot;, &amp;fx, &amp;fy, &amp;fz, &amp;ftx, &amp;fty);
				sSector0.triangle[numtriangle].kopos[i].fx=fx;
				sSector0.triangle[numtriangle].kopos[i].fy=fy;
				sSector0.triangle[numtriangle].kopos[i].fz=fz;

				sSector0.triangle[numtriangle].kopos[i].ftx=ftx;
				sSector0.triangle[numtriangle].kopos[i].fty=fty;
			}

			numtriangle++;

		}
		else if(!strcmp(cObject,&quot;CIRCLE&quot;))
		{
			buffer=fgetsN(fObjects);
			sscanf(buffer,&quot;TEX %i\n&quot;,&amp;itex);
			sSector0.circle[numcircle].iTex=itex;

			buffer=fgetsN(fObjects);
			sscanf(buffer,&quot;ALPHA %f\n&quot;,&amp;alpha);
			sSector0.circle[numcircle].alpha=alpha;

			buffer=fgetsN(fObjects);
			sscanf(buffer,&quot;RGB %f %f %f\n&quot;,&amp;r,&amp;g,&amp;b);

			sSector0.circle[numcircle].r=r;
			sSector0.circle[numcircle].g=g;
			sSector0.circle[numcircle].b=b;

			buffer=fgetsN(fObjects);
			sscanf(buffer,&quot;RAD %f\n&quot;,&amp;rad);
			sSector0.circle[numcircle].rad=rad;

			buffer=fgetsN(fObjects);
			sscanf(buffer, &quot;%f %f %f %f %f&quot;, &amp;fx, &amp;fy, &amp;fz, &amp;ftx, &amp;fty);
			sSector0.circle[numcircle].kopos.fx=fx;
			sSector0.circle[numcircle].kopos.fy=fy;
			sSector0.circle[numcircle].kopos.fz=fz;

			sSector0.circle[numcircle].kopos.ftx=ftx;
			sSector0.circle[numcircle].kopos.fty=fty;

			numcircle++;	

		}
		else if(!strcmp(cObject,&quot;CYLINDER&quot;))
		{
			buffer=fgetsN(fObjects);
			sscanf(buffer,&quot;TEX %i\n&quot;,&amp;itex);
			sSector0.cylinder[numcylinder].iTex=itex;

			buffer=fgetsN(fObjects);
			sscanf(buffer,&quot;ALPHA %f\n&quot;,&amp;alpha);
			sSector0.cylinder[numcylinder].alpha=alpha;

			buffer=fgetsN(fObjects);
			sscanf(buffer,&quot;RGB %f %f %f\n&quot;,&amp;r,&amp;g,&amp;b);

			sSector0.cylinder[numcylinder].r=r;
			sSector0.cylinder[numcylinder].g=g;
			sSector0.cylinder[numcylinder].b=b;

			buffer=fgetsN(fObjects);
			sscanf(buffer,&quot;INRAD %f\n&quot;,&amp;inrad);
			sSector0.cylinder[numcylinder].inrad=inrad;

			buffer=fgetsN(fObjects);
			sscanf(buffer,&quot;OUTRAD %f\n&quot;,&amp;outrad);
			sSector0.cylinder[numcylinder].outrad=outrad;

			buffer=fgetsN(fObjects);
			sscanf(buffer,&quot;LENGTH %f\n&quot;,&amp;length);
			sSector0.cylinder[numcylinder].length=length;

			buffer=fgetsN(fObjects);
			sscanf(buffer, &quot;%f %f %f %f %f&quot;, &amp;fx, &amp;fy, &amp;fz, &amp;ftx, &amp;fty);
			sSector0.cylinder[numcylinder].kopos.fx;
			sSector0.cylinder[numcylinder].kopos.fy;
			sSector0.cylinder[numcylinder].kopos.fz;

			sSector0.cylinder[numcylinder].kopos.ftx;
			sSector0.cylinder[numcylinder].kopos.fty;

			numcylinder++;	
		}
		else
			break;

	}

	fclose(fObjects);

}
</code></pre>
<p>dann die verwendung:</p>
<pre><code>GLvoid GL_Load_Lists()
{
	GL_Delete_Lists();
	GL_Reset();

	lListPos=glGenLists(sSector0.lnumObjects);
	lListRunner=lListPos;

	int i=0;
	GLfloat fpx,fpy,fpz,ftpx,ftpy,frad,finrad,foutrad,flength; 
	for(i=0; i&lt;sSector0.lnumTriangle; i++)
	{
		glNewList(lListRunner,GL_COMPILE);
		glColor4f(sSector0.triangle[i].r,sSector0.triangle[i].g,sSector0.triangle[i].b,sSector0.triangle[i].alpha);
		if(sSector0.triangle[i].iTex&gt;0)
		{
			glEnable(GL_TEXTURE_2D);
			glBindTexture(GL_TEXTURE_2D, texture[sSector0.triangle[i].iTex]);
		}
		else
			glDisable(GL_TEXTURE_2D);

		glBegin(GL_TRIANGLES);
		glNormal3f( 0.0f, 0.0f, 1.0f);
		for (int j=0; j&lt;3; j++)
		{

				fpx = sSector0.triangle[i].kopos[j].fx;
				fpy = sSector0.triangle[i].kopos[j].fy;
				fpz = sSector0.triangle[i].kopos[j].fz;
				ftpx = sSector0.triangle[i].kopos[j].ftx;
				ftpy = sSector0.triangle[i].kopos[j].fty;
				glTexCoord2f(ftpx,ftpy); glVertex3f(fpx,fpy,fpz);

		}
		glEnd();
		glEndList();
		lListRunner++;
	}

	for(i=0; i&lt;sSector0.lnumCircle; i++)
	{
		glNewList(lListRunner,GL_COMPILE);
		glColor4f(sSector0.circle[i].r,sSector0.circle[i].g,sSector0.circle[i].b,sSector0.circle[i].alpha);
		if(sSector0.circle[i].iTex&gt;0)
		{
			glEnable(GL_TEXTURE_2D);
			glBindTexture(GL_TEXTURE_2D, texture[sSector0.circle[i].iTex]);
		}
		else
			glDisable(GL_TEXTURE_2D);

		fpx = sSector0.circle[i].kopos.fx;
		fpy = sSector0.circle[i].kopos.fy;
		fpz = sSector0.circle[i].kopos.fz;
		ftpx = sSector0.circle[i].kopos.ftx;
		ftpy = sSector0.circle[i].kopos.fty;
		frad = sSector0.circle[i].rad;

		glTexCoord2f(ftpx,ftpy);
		glTranslatef(fpx,fpy,fpz);
		gluSphere(gluobjects,frad,32,32);

		glEndList();
		lListRunner++;
	}

	for(i=0; i&lt;sSector0.lnumCylinder; i++)
	{
		glNewList(lListRunner,GL_COMPILE);
		glColor4f(sSector0.cylinder[i].r,sSector0.cylinder[i].g,sSector0.cylinder[i].b,sSector0.cylinder[i].alpha);
		if(sSector0.cylinder[i].iTex&gt;0)
		{
			glEnable(GL_TEXTURE_2D);
			glBindTexture(GL_TEXTURE_2D, texture[sSector0.cylinder[i].iTex]);
		}
		else
			glDisable(GL_TEXTURE_2D);

		fpx = sSector0.cylinder[i].kopos.fx;
		fpy = sSector0.cylinder[i].kopos.fy;
		fpz = sSector0.cylinder[i].kopos.fz;
		ftpx = sSector0.cylinder[i].kopos.ftx;
		ftpy = sSector0.cylinder[i].kopos.fty;
		finrad = sSector0.cylinder[i].inrad;
		foutrad = sSector0.cylinder[i].outrad;
		flength = sSector0.cylinder[i].length;

		glTexCoord2f(ftpx,ftpy);
		glTranslatef(fpx,fpy,fpz);
		gluCylinder(gluobjects,finrad,foutrad,flength,32,32);	

		glEndList();
		lListRunner++;
	}

	lListRunner=lListPos;
}
</code></pre>
<p>und schließlich die zeichenroutine:</p>
<pre><code>GLvoid GL_Render_Scene()
{

	GL_Cls();
	GL_Reset();

	gluobjects=gluNewQuadric();
	gluQuadricNormals(gluobjects, GLU_SMOOTH);
	gluQuadricTexture(gluobjects, GL_TRUE);

	glPolygonMode(GL_BACK, GL_POLY_MODE);                     
	glPolygonMode(GL_FRONT, GL_POLY_MODE);

	glRotatef(ydrehwinkel,0,1,0);
	glRotatef(xdrehwinkel,1,0,0);

	GL_Set3DPos(xweg/iRunFactor-2.0f,yweg/iRunFactor+0.0f,zweg/iRunFactor-12.0f);     

	int i=0;

    // wenn dieser teil ausklammert ist, läuft es, wenn nicht, stürtzt es ab...
       glColor4f(sSector0.triangle[i].r,
                      sSector0.triangle[i].g,
                      sSector0.triangle[i].b,
                      sSector0.triangle[i].alpha);

   //
	for(i=lListPos; i&lt;=sSector0.lnumObjects; i++)
	{
		glCallList(i);
	}

}
</code></pre>
<p>sonst wird nirgend darauf zugegriffen, wenn die variablen statisch deklariert sind, läufts auch perfekt...</p>
<p>danke,mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1339780</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1339780</guid><dc:creator><![CDATA[progsepp]]></dc:creator><pubDate>Mon, 06 Aug 2007 19:15:28 GMT</pubDate></item><item><title><![CDATA[Reply to c++ dynamisches array?!? big problem... on Tue, 07 Aug 2007 08:34:06 GMT]]></title><description><![CDATA[<p>Und wo ist das Hauptprogram, das alle Aktionen in die richtige Reihenfolge bringt?</p>
<p>PS: globale Variablen sind Böse <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1339943</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1339943</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 07 Aug 2007 08:34:06 GMT</pubDate></item><item><title><![CDATA[Reply to c++ dynamisches array?!? big problem... on Wed, 08 Aug 2007 17:27:07 GMT]]></title><description><![CDATA[<p>das ist der code:</p>
<pre><code>int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{

	MSG		msg;

	if (!GL_CreateWindow(&quot;OpenGLWindow&quot;,false,640,480,16,0,30,0))
		return 0;

	CreateThread(NULL, 0, Action_Thread, NULL, 0, NULL);

	while(true) 
	{
		if(PeekMessage(&amp;msg,NULL,0,0,PM_REMOVE)) 
		{
			if(msg.message==WM_QUIT||msg.message==WM_CLOSE||msg.message==WM_DESTROY)
				break;
			else
			{
				TranslateMessage(&amp;msg);
				DispatchMessage(&amp;msg); 
			}
		}
		else 
		{
			if(GetForegroundWindow()==hWnd) 
			{
				if (bkeys[VK_ESCAPE]) 
					break;
				else if(bkeys[VK_F5])
				{
					GL_Load_Objects();
					GL_Load_Lists();
					bkeys[VK_F5]=false;
				}
				else
				{
					GL_Render_Scene();
					GL_SwapBuffers(); 
					Sleep(iDelay);
				}

			}

			if(bkeys[VK_F1]) 
			{
				bkeys[VK_F1]=FALSE; 
    			GL_DestroyWindow(szAppName); 
				bFullScr=!bFullScr; 

				if (!GL_CreateWindow(szAppName,bFullScr,640,480,16,0,40,0))    
					return 0; 

			}

		}
	}

	GL_DestroyWindow(szAppName);
	return (msg.wParam);
}
</code></pre>
<p>Unter GL_CreateWindow wird die initglfunktion aufgerufen hier im detail:</p>
<pre><code>int GL_InitGraphics(GLvoid)
{ 

	GL_Load_Objects();
	GL_Load_Textures();
	GL_Load_Lists();

	return TRUE;
}
</code></pre>
<p>mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1341001</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1341001</guid><dc:creator><![CDATA[progsepp]]></dc:creator><pubDate>Wed, 08 Aug 2007 17:27:07 GMT</pubDate></item><item><title><![CDATA[Reply to c++ dynamisches array?!? big problem... on Wed, 08 Aug 2007 17:29:09 GMT]]></title><description><![CDATA[<p>PS: dass ich bei F5 nochmals die funktionen loadobject und loadlist aufrufe habe ich erst neulich eingebaut, seitdem ich mit statischen variblen arbeite, habe ich allerdings vorher auch nie eingebaut gehabt, also diesen teil eventuell weckdenken <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1341002</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1341002</guid><dc:creator><![CDATA[progsepp]]></dc:creator><pubDate>Wed, 08 Aug 2007 17:29:09 GMT</pubDate></item></channel></rss>