<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Initialization source file </title>
		<link>http://www.allegro.cc/forums/view/618786</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 17 Feb 2023 21:58:22 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>All, </p><p>I&#39;m creating a framework for my first A5 program. If I put all my allegro setup / inits in a separate source file, are the pointers global or will they need to be passed in order to be used. </p><p>Some items are just activated and working.<br />al_init(); / al_install_keyboard(); / al_init_image_addon(); etc.</p><p>However, some are pointers.  In order to use timer or queue outside of the init source file, will I need to pass the pointer to all functions needing it. </p><p>ALLEGRO_TIMER* timer = al_create_timer(1.0 / 30.0);<br />ALLEGRO_EVENT_QUEUE* queue = al_create_event_queue();</p><p>Meaning, if I create queue in alleg_init.cpp will I have to pass it to main.cpp or will it just be available. </p><p>I&#39;m a ways off from having anything compilable so I can&#39;t test my question out on my own yet.   Was trying to get a head of the curve. Thanks
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (AceBlkwell)</author>
		<pubDate>Thu, 16 Feb 2023 03:22:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You can DECLARE your pointers for other files to see using extern.</p><div class="source-code snippet"><div class="inner"><pre><span class="c">// myheader.h</span>
<span class="c">// declare in your header file</span>
<span class="k1">extern</span> <a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a><span class="k3">*</span> bitmap<span class="k2">;</span>
</pre></div></div><p>

</p><div class="source-code snippet"><div class="inner"><pre><span class="c">// source1.h</span>
<span class="c">// define only once</span>
<span class="p">#include "myheader.h"</span>
<a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a><span class="k3">*</span> bitmap<span class="k2">;</span>
</pre></div></div><p>

</p><div class="source-code snippet"><div class="inner"><pre><span class="c">// source2.h</span>
<span class="p">#include "myheader.h"</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (DanielH)</author>
		<pubDate>Thu, 16 Feb 2023 03:56:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks Daniel.  I thought about a header file last night.  I had forgotten about extern.  I haven&#39;t used it a lot in the past.  Either way would be easier than trying to pass a pointer back and forth. </p><p>I watch part of your framework video.  Not bad. I&#39;m not a VC guy but the concept is still the same.  As I work through my framework, I may check it out again to see how you handled certain difficulties.    Thanks again.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (AceBlkwell)</author>
		<pubDate>Thu, 16 Feb 2023 20:25:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You don&#39;t actually <b>need</b> a header file. You can always just put the extern declaration in your other source files. As long as you only define it once.</p><div class="source-code snippet"><div class="inner"><pre><span class="c">// source1.cpp</span>
<a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a><span class="k3">*</span> bitmap <span class="k3">=</span> nullptr<span class="k2">;</span>
</pre></div></div><p>

</p><div class="source-code snippet"><div class="inner"><pre><span class="c">//source2.cpp</span>
<span class="k1">extern</span> <a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a><span class="k3">*</span> bitmap<span class="k2">;</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (DanielH)</author>
		<pubDate>Thu, 16 Feb 2023 21:48:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks Daniel.  I have decided to start a lot smaller.  Based on tutorials and other code, I was trying to create a framework for all setups and initiations needed for an entire game.  At this point I don’t have enough experience with A5 to develop an initiation “black box”.  I’m going take my previous approach, which works for me.  I’m going to start writing code to learn a specific aspect of the library and expand from there.  Once I have that, I’ll then start working on grouping like actions together.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (AceBlkwell)</author>
		<pubDate>Fri, 17 Feb 2023 21:58:22 +0000</pubDate>
	</item>
</rss>
