<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>using transform</title>
		<link>http://www.allegro.cc/forums/view/618428</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 03 Jun 2021 11:09:58 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>can someone point me to correct method of initialising transformations. I created a pointer to ALLEGRO_TRANSFORM and invoked al_identity_tranform on it.<br />&quot;/build/allegro5-F6iykb/allegro5-5.2.6.0/src/transformations.c:147: al_identity_transform: Assertion `trans&#39; failed.<br />Aborted (core dumped)&quot;</p><p>This is the error
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (J43G3R)</author>
		<pubDate>Thu, 03 Jun 2021 00:59:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You&#39;re passing a pointer? Does it actually point to an ALLEGRO_TRANSFORM?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (DanielH)</author>
		<pubDate>Thu, 03 Jun 2021 01:24:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Generally you pass in a transform like this:</p><div class="source-code snippet"><div class="inner"><pre><span class="c">// This is allocated on the stack</span>
<a href="http://www.allegro.cc/manual/ALLEGRO_TRANSFORM"><span class="a">ALLEGRO_TRANSFORM</span></a> transform<span class="k2">;</span>

<span class="c">// Pass a pointer to a stack-allocated pointer</span>
<a href="http://www.allegro.cc/manual/al_identity_transform"><span class="a">al_identity_transform</span></a><span class="k2">(</span><span class="k3">&amp;</span>transform<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

Sounds like you might be doing something like this:</p><div class="source-code snippet"><div class="inner"><pre><span class="c">// This is a pointer to NULL</span>
<a href="http://www.allegro.cc/manual/ALLEGRO_TRANSFORM"><span class="a">ALLEGRO_TRANSFORM</span></a><span class="k3">*</span> transform <span class="k3">=</span> NULL<span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_identity_transform"><span class="a">al_identity_transform</span></a><span class="k2">(</span>transform<span class="k2">)</span><span class="k2">;</span> <span class="c">// bad</span>
</pre></div></div><p>

Basically, <span class="source-code"><a href="http://www.allegro.cc/manual/al_identity_transform"><span class="a">al_identity_transform</span></a></span> expects the memory for the transform you provide to be allocated. So it needs to pointer to an object on the stack (or in the heap, if the transform is a field in a <span class="source-code"><span class="k1">class</span></span> or <span class="source-code"><span class="k1">struct</span></span>).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Erin Maus)</author>
		<pubDate>Thu, 03 Jun 2021 01:41:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>A class or struct field is not implicitly on the heap at all. <img src="http://www.allegro.cc/forums/smileys/rolleyes.gif" alt="::)" /><img src="http://www.allegro.cc/forums/smileys/lipsrsealed.gif" alt=":-X" /> Where it is allocated depends on how you define an instance of it. I know (hope) Erin knows that, but the OP may not.</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span><span class="c">// C++, contrived</span>
<span class="number">  2</span><span class="k1">struct</span> Transform <span class="k2">{</span>
<span class="number">  3</span>    <a href="http://www.allegro.cc/manual/ALLEGRO_TRANSFORM"><span class="a">ALLEGRO_TRANSFORM</span></a> transform<span class="k2">;</span>
<span class="number">  4</span><span class="k2">}</span><span class="k2">;</span>
<span class="number">  5</span>
<span class="number">  6</span>Transform t1<span class="k2">;</span> <span class="c">// t1 is defined at global scope, and so is t1.transform.</span>
<span class="number">  7</span>Transform <span class="k3">*</span> t2 <span class="k3">=</span> NULL<span class="k2">;</span> <span class="c">// No Transform has been allocated; only a 4 or 8 byte integer (pointer) is allocated in global scope.</span>
<span class="number">  8</span>
<span class="number">  9</span><span class="k1">void</span> main<span class="k2">(</span><span class="k1">int</span> argc, <span class="k1">char</span> <span class="k3">*</span><span class="k3">*</span> argv<span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 10</span>    Transform t3<span class="k2">;</span> <span class="c">// Allocated on the stack. </span>
<span class="number"> 11</span>    Transform <span class="k3">*</span> t4 <span class="k3">=</span> <span class="k1">new</span> Transform<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span> <span class="c">// malloc-family in C, operator new() in C++ allocate on the heap; t4 is an integer (pointer) on the stack, but it points to a Transform object allocated on the heap; t4-&gt;transform is also on the heap.</span>
<span class="number"> 12</span>
<span class="number"> 13</span>    t2 <span class="k3">=</span> <span class="k3">&amp;</span>t3<span class="k2">;</span> <span class="c">// Now the global pointer points at a Transform object on the stack, and so t2-&gt;transform is also on the stack.</span>
<span class="number"> 14</span>    t2 <span class="k3">=</span> t4<span class="k2">;</span> <span class="c">// Now the global pointer points at a Transform object on the heap, and so t2-&gt;transform is also on the heap;</span>
<span class="number"> 15</span>    t2 <span class="k3">=</span> NULL<span class="k2">;</span>
<span class="number"> 16</span>
<span class="number"> 17</span>    <span class="c">// Every operator new() needs a corresponding operator delete() (at runtime as the program is running, not just in code)</span>
<span class="number"> 18</span>    <span class="k1">delete</span> t4<span class="k2">;</span>
<span class="number"> 19</span>    t4 <span class="k3">=</span> NULL<span class="k2">;</span>
<span class="number"> 20</span><span class="k2">}</span>
</div></div><p>

I wrote this on my phone so hopefully I didn&#39;t miss any typos. If the OP or anyone doesn&#39;t understand this ask questions! That&#39;s what we&#39;re here for!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Thu, 03 Jun 2021 06:23:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Problem Solved! Thankyou everyone who replied , and yes I was making the mistake of declaring a pointer without actually allocating memory for the ALLEGRO_TRANSFORM struct
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (J43G3R)</author>
		<pubDate>Thu, 03 Jun 2021 10:40:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Glad you and Erin got it solved. <img src="http://www.allegro.cc/forums/smileys/cheesy.gif" alt=":D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Thu, 03 Jun 2021 11:09:58 +0000</pubDate>
	</item>
</rss>
