<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>C Board - Game Programming</title>
		<link>http://cboard.cprogramming.com</link>
		<description>Questions specific to game programming, sound and graphics libraries, algorithms and techniques</description>
		<language>en</language>
		<lastBuildDate>Sat, 21 Nov 2009 02:31:47 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://cboard.cprogramming.com/images/misc/rss.jpg</url>
			<title>C Board - Game Programming</title>
			<link>http://cboard.cprogramming.com</link>
		</image>
		<item>
			<title>OpenAL sources limit</title>
			<link>http://cboard.cprogramming.com/game-programming/121801-openal-sources-limit.html</link>
			<pubDate>Fri, 20 Nov 2009 17:56:30 GMT</pubDate>
			<description>Hello! 
My computer game uses OpenAL. I have recently encountered a problem: I can not generate as many sources as I want. It gives me this error: 
 
Code: 
--------- 
There are not enough non-memory resources to create all the requested sources, or the array pointer is not valid. 
--------- 
I...</description>
			<content:encoded><![CDATA[<div>Hello!<br />
My computer game uses OpenAL. I have recently encountered a problem: I can not generate as many sources as I want. It gives me this error:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">There are not enough non-memory resources to create all the requested sources, or the array pointer is not valid.</code><hr />
</div>I don't actually understand what they mean by &quot;non-memory resources&quot;. What does the count of possible sources depend on? How can I detect the possible count of sources? Some computers seem to allow much more sources.</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/game-programming/">Game Programming</category>
			<dc:creator>moment</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/game-programming/121801-openal-sources-limit.html</guid>
		</item>
		<item>
			<title>events, frame rates, and the pipeline</title>
			<link>http://cboard.cprogramming.com/game-programming/121750-events-frame-rates-pipeline.html</link>
			<pubDate>Thu, 19 Nov 2009 00:35:42 GMT</pubDate>
			<description><![CDATA[Okay, I don't play video games, so I have a crap video card -- actually I don't have a video card at all, I use the onboard via chrome from my mobo.  But I really want to write a video game (a 3D FPS version of breakout) as a winter project. 
 
I've always been slightly puzzled by gamers obsession...]]></description>
			<content:encoded><![CDATA[<div>Okay, I don't play video games, so I have a crap video card -- actually I don't have a video card at all, I use the onboard via chrome from my mobo.  But I really want to write a video game (a 3D FPS version of breakout) as a winter project.<br />
<br />
I've always been slightly puzzled by gamers obsession with frame rates.  Like film is I think &lt;30 fps, so why bother with more?  Yes that's a genuine question, cause I presume there is a genuine reason, I'm not calling anyone a fool.<br />
<br />
This afternoon I was wondering if it relates to events, and &quot;the pipeline&quot;.  Lemme describe my programming issue to explain why I'm thinking that.<br />
<br />
For a 3D FPS breakout, you are the paddle, so the paddle moves in x and y but not z, which makes the mouse perfect.  But today I was experimenting with openGL in <b>both SDL and glut</b> and I noticed something: the data I got from mouse events was instantaneous --  I used it to modify global variables and printf them, those changes appear instantaneously -- but <i>the response in the graphics display</i> noticeably lags, I would say at least 1/2 second.  This does not make sense to me, since I am getting 25-45 fps*.  <b>I presumed that there is no temporal offset</b>, but that is not necessarily so -- that is, you could get 100 fps, but at a 1 second delay.  It is a &quot;pipeline&quot;, so I suppose there must be some delay from the time data is fed into one end (when the &quot;render frame/scene&quot; function is called) to when the graphics lib, etc, have done their job and the frame actually appears on the scene, because it is obvious from the console debugging data (printf) that the frame currently executing is at least 10-15 frames ahead of what appears in the application window. <br />
<br />
Is that right? Is that normal? Is that a consequence of a crappy video card and software acceleration? Or am I out to lunch here? Suddenly, it might make sense to want 60 fps, if the delay is <i>a number of frames</i>, and especially if that number was also reduced.  If the offset were 5 frames at 60 fps, that's 1/12th of a second, more or less instant.  But with what I am looking at right now the action is gonna be really lame.<br />
<br />
*presumably this will start to diminish when the graphics gets heavier, but by then I will probably be motivated to buy a card</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/game-programming/">Game Programming</category>
			<dc:creator>MK27</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/game-programming/121750-events-frame-rates-pipeline.html</guid>
		</item>
		<item>
			<title>SDL -- openGL -- video mode attributes</title>
			<link>http://cboard.cprogramming.com/game-programming/121715-sdl-opengl-video-mode-attributes.html</link>
			<pubDate>Wed, 18 Nov 2009 00:19:50 GMT</pubDate>
			<description>Okay, so I was having this problem earlier, qv. 
 
http://cboard.cprogramming.com/c-programming/121712-significance-exit.html 
 
and now I am kind of curious about some things.  SDL requires you to set the video mode. 
 
SDL_SetVideoMode(WIDTH, HEIGHT, BPP, flags); 
 
(And yes, I am error checking...</description>
			<content:encoded><![CDATA[<div>Okay, so I was having this problem earlier, qv.<br />
<br />
<a href="!121712!http://cboard.cprogramming.com/c-programming/121712-significance-exit.html" target="_blank">http://cboard.cprogramming.com/c-pro...ance-exit.html</a><br />
<br />
and now I am kind of curious about some things.  SDL requires you to set the video mode.<br />
<br />
SDL_SetVideoMode(WIDTH, HEIGHT, BPP, flags);<br />
<br />
(And yes, I am error checking this.) When I used OGL with glut, there was no setting of video modes -- you just pick a window size, any window size, and away you go.  So with my first couple of experiments using SDL (without GL), I just set WIDTH and HEIGHT to anything, or maybe the exact dimensions of my monitor if I was using SDL_FULLSCREEN.  No problems.<br />
<br />
But with GL, if I set the video mode above 640x480, I run a significant chance of crashing the windowing system <b>right after the program exits</b>.  Otherwise it seems to work (but I haven't done much yet).  Working with example 2.8 from the SDL Guide, BPP in a GL setting is determined this way:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">const SDL_VideoInfo *info = SDL_GetVideoInfo();<br />
int BPP= info-&gt;vfmt-&gt;BitsPerPixel;</code><hr />
</div>which it's 32, and then there's also this which is necessary:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">&nbsp; &nbsp; &nbsp; &nbsp; SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );<br />
&nbsp; &nbsp; &nbsp; &nbsp; SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );<br />
&nbsp; &nbsp; &nbsp; &nbsp; SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );<br />
&nbsp; &nbsp; &nbsp; &nbsp; SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );</code><hr />
</div>I have searched the API docs and googled around a bit, and there is no explanation at all of what all this means.  There is one note to the effect that you want the r,g, and b size to be &quot;at least 5&quot;.  So is this 5+5+5+16=31? Or is this unrelated to BPP?  Or, if it means 15 or 16, does this actually <i>mismatch</i> with the depth set using SetVideoMode (32)? <br />
<br />
I'm kind of familiar with GL's interface and <acronym title="As far as I know">AFAIK</acronym> this is not part of it -- this is for SDL's interface to GL, I guess.  Which makes it kind of crappy they can't be bothered to explain this better (or at all), since the docs seem decent otherwise, so far.<br />
<br />
The reason I'm asking is presumably the seg fault (which occurs in libglx.so, part of X windows) is because of this.  I do not have a  very good video card -- it's an onboard via chrome -- but with glut, the video mode or whatever always matched the window size.  Now it seems I am stuck with a 640x480 window (or fullscreen in 640x480 mode) which sucks.<br />
<br />
I guess this won't make much difference to the design of the app itself, etc, since video modes are system dependent.  But does anyone have any insight here, like<ol style="list-style-type: decimal"><li>what is a valid video mode?</li>
<li>how can I get better than 640x480?</li>
</ol></div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/game-programming/">Game Programming</category>
			<dc:creator>MK27</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/game-programming/121715-sdl-opengl-video-mode-attributes.html</guid>
		</item>
		<item>
			<title>UDK and Unity</title>
			<link>http://cboard.cprogramming.com/game-programming/121319-udk-unity.html</link>
			<pubDate>Thu, 05 Nov 2009 18:41:18 GMT</pubDate>
			<description>In the past week two (http://unity3d.com/company/news/unity2.6-press.html) game engines (http://www.udk.com/) have been released which are free for non-commercial developers.   
 
Some of you might have seen this story on Slashdot.  I thought this would be a good place to mention it and get a small...</description>
			<content:encoded><![CDATA[<div>In the past week <a href="http://unity3d.com/company/news/unity2.6-press.html" target="_blank">two</a> <a href="http://www.udk.com/" target="_blank">game engines</a> have been released which are free for non-commercial developers.  <br />
<br />
Some of you might have seen this story on Slashdot.  I thought this would be a good place to mention it and get a small discussion going.  I have already downloaded UDK, and I plan on playing around with it this evening just to see what it's like.  Anyone else planning on doing anything with these engines?</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/game-programming/">Game Programming</category>
			<dc:creator>DavidP</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/game-programming/121319-udk-unity.html</guid>
		</item>
		<item>
			<title>Object oriented game design</title>
			<link>http://cboard.cprogramming.com/game-programming/121173-object-oriented-game-design.html</link>
			<pubDate>Sat, 31 Oct 2009 22:03:09 GMT</pubDate>
			<description><![CDATA[I'm doing a simple 2D engine in SDL, and I'm having a hard time figuring out how to design the class hierarchy. 
 
I want an interface that is completely seperated from the underlying engine, so that I may change from SDL to OpenGL in the future for the video rendering for example. 
 
My first...]]></description>
			<content:encoded><![CDATA[<div>I'm doing a simple 2D engine in SDL, and I'm having a hard time figuring out how to design the class hierarchy.<br />
<br />
I want an interface that is completely seperated from the underlying engine, so that I may change from SDL to OpenGL in the future for the video rendering for example.<br />
<br />
My first stumbling point was when I was designing an Event class that handles keypresses and similar input. If the users quits the program, the code should call a global quit function that all classes should use, but I can't figure out how to design this part without using global variables (which I want to avoid). The quit function can't be static since it will have to cleanup non-static data. I also want to try to avoid multiple inheritance since everyone say to avoid it if possible.</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/game-programming/">Game Programming</category>
			<dc:creator>Memloop</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/game-programming/121173-object-oriented-game-design.html</guid>
		</item>
		<item>
			<title>Windows 7: Program unable to find glut/glfw dll?</title>
			<link>http://cboard.cprogramming.com/game-programming/121102-windows-7-program-unable-find-glut-glfw-dll.html</link>
			<pubDate>Thu, 29 Oct 2009 14:29:05 GMT</pubDate>
			<description><![CDATA[I've been trying to compile my glut programs in Windows 7 Professional (64bit) using MinGW in Code::Blocks. All of the .a, .dll and .h files are in the right places, but when I try to run the program it says that glut32.dll is missing from your computer. It's definately in my System32 folder. 
 
So...]]></description>
			<content:encoded><![CDATA[<div>I've been trying to compile my glut programs in Windows 7 Professional (64bit) using MinGW in Code::Blocks. All of the .a, .dll and .h files are in the right places, but when I try to run the program it says that glut32.dll is missing from your computer. It's definately in my System32 folder.<br />
<br />
So decided to try it with GLFW instead and I get the same error, that it GLFW.DLL is missing from your computer.<br />
<br />
It works when I put it in the folder with the .exe, but for some reason it won't work when in the system32 folder.<br />
<br />
Are there any known issues concerning this, or is it just me?<br />
<br />
Thanks for any help =).</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/game-programming/">Game Programming</category>
			<dc:creator>Jake.c</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/game-programming/121102-windows-7-program-unable-find-glut-glfw-dll.html</guid>
		</item>
		<item>
			<title>No acess to the video memory????</title>
			<link>http://cboard.cprogramming.com/game-programming/121024-no-acess-video-memory.html</link>
			<pubDate>Tue, 27 Oct 2009 09:44:50 GMT</pubDate>
			<description><![CDATA[Good morning Srs. 
 
 
 
I have check by a vesa card 
then i have fill a srtuct  ModeInfo 
    vbeGetModeInfo(0x101,&ModeInfo) 
and vbeSetMode(0x101); 
now i set some bytes in video memory lyke  
_fmemset(far*ptr,val,len)]]></description>
			<content:encoded><![CDATA[<div>Good morning Srs.<br />
<br />
<br />
<br />
I have check by a vesa card<br />
then i have fill a srtuct  ModeInfo<br />
    vbeGetModeInfo(0x101,&amp;ModeInfo)<br />
and vbeSetMode(0x101);<br />
now i set some bytes in video memory lyke <br />
_fmemset(far*ptr,val,len)<br />
<br />
but i just see the screen all black<br />
<br />
and i dont figure out why<br />
<br />
can some one give me a idea??<br />
<br />
why i dont have acess to the video memory?<br />
all the tests return sucess and that mode is suported by the card<br />
and i have VESA ver 3.0<br />
<br />
thanks good day to you<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">void main(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; short oldmode=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vbeInfo info;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vbeModeInfo modeInfo;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(vbeGetInfo(&amp;info)){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(memcmp(info.vesa,&quot;VESA&quot;,4)==0){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  vbePrintInfo(&amp;info);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  getch();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(vbeGetModeInfo(0x101,&amp;modeInfo)){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vbeGetMode(&amp;oldmode);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vbeSetMode(0x101);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _fmemset((unsigned char far*)MK_FP(0xa000,0),0x15,20);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else printf(&quot;Not Vesa\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else printf(&quot;Error\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; getch();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(oldmode)vbeSetMode(oldmode);<br />
}</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/game-programming/">Game Programming</category>
			<dc:creator>joseCarlos</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/game-programming/121024-no-acess-video-memory.html</guid>
		</item>
		<item>
			<title>Confusion on Camera controls</title>
			<link>http://cboard.cprogramming.com/game-programming/120899-confusion-camera-controls.html</link>
			<pubDate>Fri, 23 Oct 2009 02:49:17 GMT</pubDate>
			<description><![CDATA[So, I was working with 3D cameras and worlds, and I realized...I don't really understand what the matrices represent.   
 
There is a ViewMatrix, a perspective matrix, an upmatrix, and a world matrix. 
 
I thought that the ViewMatrix created the clipped world matrix, the perspective matrix scewed...]]></description>
			<content:encoded><![CDATA[<div>So, I was working with 3D cameras and worlds, and I realized...I don't really understand what the matrices represent.  <br />
<br />
There is a ViewMatrix, a perspective matrix, an upmatrix, and a world matrix.<br />
<br />
I thought that the ViewMatrix created the clipped world matrix, the perspective matrix scewed and transformed the world matrix to create an illusion of depth and perspective, and then a world matrix that contained the coordinates for everything...but that still leaves the up matrix, and I have NO idea what that would be.  <br />
<br />
I understand the math for creating perspective from matrices, but I don't know what the up matrix would be the equivalent to.  What is this?  How can I use this properly?<br />
<br />
<br />
So far, I have created a camera like so...:<br />
<br />
Camera.h:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">#include &quot;camera.h&quot;<br />
static float aspect = 800.0f / 600.0f;<br />
Camera::Camera(CameraType type)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; _Type = type;<br />
&nbsp; &nbsp; &nbsp; &nbsp; _Position = _Rotation = PointF(0.0f, 0.0f, 0.0f);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; //D3DXVECTOR3 cameraPosition( 0.0f, 10.0f, 0.0f );<br />
&nbsp; &nbsp; //D3DXVECTOR3 cameraTarget( 0.0f, 1.0f, 10.0f );<br />
&nbsp; &nbsp; //D3DXVECTOR3 cameraUp( 0.0f, 1.0f, 0.0f );<br />
&nbsp; &nbsp; //D3DXMatrixLookAtLH( &amp;ViewMatrix, &amp;cameraPosition, &amp;cameraTarget, &amp;cameraUp );<br />
&nbsp; &nbsp; //GraphicDevice::GetService()-&gt;Device()-&gt;SetTransform( D3DTS_VIEW, &amp;ViewMatrix );<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; ////D3DXMatrixPerspectiveFovLH(&amp;ProjectionMatrix, PI/4, 1.0f, 1.0f, 5000.0f);<br />
&nbsp; &nbsp; &nbsp; &nbsp; ////GraphicDevice::GetService()-&gt;Device()-&gt;SetTransform(D3DTS_PROJECTION, &amp;ProjectionMatrix);<br />
<br />
&nbsp;//&nbsp;  // Set the projection matrix<br />
&nbsp; &nbsp; //D3DXMatrixPerspectiveFovLH( &amp;ProjectionMatrix, D3DX_PI / 2, aspect, 1.0f, 1000.0f );<br />
&nbsp; &nbsp; //GraphicDevice::GetService()-&gt;Device()-&gt;SetTransform( D3DTS_PROJECTION, &amp;ProjectionMatrix );<br />
<br />
<br />
}<br />
Camera::~Camera(void)<br />
{<br />
}<br />
void Camera::Update(void)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; //D3DXVECTOR3 cameraPosition(_Position.X(), _Position.Y(), _Position.Z());<br />
&nbsp; &nbsp; &nbsp; &nbsp; //D3DXVECTOR3 cameraTarget(_Position.X()+cos(_Rotation.Z()), _Position.Y(), _Position.Z()+sin(_Rotation.X()));<br />
&nbsp; &nbsp; &nbsp; &nbsp; //D3DXVECTOR3 cameraUp(0.0f, 1.0f, 0.0f);<br />
<br />
&nbsp;//&nbsp;  D3DXMatrixLookAtLH( &amp;ViewMatrix, &amp;cameraPosition, &amp;cameraTarget, &amp;cameraUp );<br />
&nbsp; &nbsp; &nbsp; &nbsp; //<br />
&nbsp;//&nbsp;  D3DXMatrixPerspectiveFovLH( &amp;ProjectionMatrix, D3DX_PI / 2, aspect, 1.0f, 5000.0f );<br />
&nbsp;//&nbsp;  HRESULT a = GraphicDevice::GetService()-&gt;Device()-&gt;SetTransform( D3DTS_PROJECTION, &amp;ProjectionMatrix );<br />
&nbsp; &nbsp; &nbsp; &nbsp; //int i = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; D3DXVECTOR3 Position(_Position.X(), _Position.Y(), _Position.Z()), <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Target(_Position.X(), _Position.Y(), _Position.Z()),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UpVector(0.0f, 1.0f, 0.0f);<br />
&nbsp; &nbsp; &nbsp; &nbsp; D3DXMatrixLookAtLH(&amp;ViewMatrix, &amp;Position, &amp;Target, &amp;UpVector);<br />
&nbsp; &nbsp; &nbsp; &nbsp; D3DXMatrixPerspectiveFovLH(&amp;ProjectionMatrix, D3DX_PI / 2, aspect, 1.0f, 5000.0f);<br />
&nbsp; &nbsp; &nbsp; &nbsp; GraphicDevice::GetService()-&gt;Device()-&gt;SetTransform(D3DTS_PROJECTION, &amp;ProjectionMatrix);<br />
}<br />
void Camera::Rotate(TransformType type, PointF rotation)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; switch(type)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; case TransformTypes::Absolute:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _Rotation = rotation;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; case TransformTypes::Relative:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _Rotation += rotation;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
void Camera::Move(TransformType type, PointF A)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; switch(type)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; case TransformTypes::Absolute:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _Position = A;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; case TransformTypes::Relative:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _Position.Z(_Position.Z() + cos(A.Z()) + sin(A.Z()));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _Position.X(_Position.Z() + cos(A.Z()) - sin(A.Z()));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</code><hr />
</div>Camera.cpp<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left"><br />
#include &quot;camera.h&quot;<br />
static float aspect = 800.0f / 600.0f;<br />
Camera::Camera(CameraType type)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; _Type = type;<br />
&nbsp; &nbsp; &nbsp; &nbsp; _Position = _Rotation = PointF(0.0f, 0.0f, 0.0f);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; //D3DXVECTOR3 cameraPosition( 0.0f, 10.0f, 0.0f );<br />
&nbsp; &nbsp; //D3DXVECTOR3 cameraTarget( 0.0f, 1.0f, 10.0f );<br />
&nbsp; &nbsp; //D3DXVECTOR3 cameraUp( 0.0f, 1.0f, 0.0f );<br />
&nbsp; &nbsp; //D3DXMatrixLookAtLH( &amp;ViewMatrix, &amp;cameraPosition, &amp;cameraTarget, &amp;cameraUp );<br />
&nbsp; &nbsp; //GraphicDevice::GetService()-&gt;Device()-&gt;SetTransform( D3DTS_VIEW, &amp;ViewMatrix );<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; ////D3DXMatrixPerspectiveFovLH(&amp;ProjectionMatrix, PI/4, 1.0f, 1.0f, 5000.0f);<br />
&nbsp; &nbsp; &nbsp; &nbsp; ////GraphicDevice::GetService()-&gt;Device()-&gt;SetTransform(D3DTS_PROJECTION, &amp;ProjectionMatrix);<br />
<br />
&nbsp;//&nbsp;  // Set the projection matrix<br />
&nbsp; &nbsp; //D3DXMatrixPerspectiveFovLH( &amp;ProjectionMatrix, D3DX_PI / 2, aspect, 1.0f, 1000.0f );<br />
&nbsp; &nbsp; //GraphicDevice::GetService()-&gt;Device()-&gt;SetTransform( D3DTS_PROJECTION, &amp;ProjectionMatrix );<br />
<br />
<br />
}<br />
Camera::~Camera(void)<br />
{<br />
}<br />
void Camera::Update(void)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; D3DXVECTOR3 cameraPosition(_Position.X(), _Position.Y(), _Position.Z());<br />
&nbsp; &nbsp; &nbsp; &nbsp; D3DXVECTOR3 cameraTarget(_Position.X()+cos(_Rotation.Z()), _Position.Y(), _Position.Z()+sin(_Rotation.X()));<br />
&nbsp; &nbsp; &nbsp; &nbsp; D3DXVECTOR3 cameraUp(0.0f, 1.0f, 0.0f);<br />
<br />
&nbsp; &nbsp; D3DXMatrixLookAtLH( &amp;ViewMatrix, &amp;cameraPosition, &amp;cameraTarget, &amp;cameraUp );<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; D3DXMatrixPerspectiveFovLH( &amp;ProjectionMatrix, D3DX_PI / 2, aspect, 1.0f, 5000.0f );<br />
&nbsp; &nbsp; HRESULT a = GraphicDevice::GetService()-&gt;Device()-&gt;SetTransform( D3DTS_PROJECTION, &amp;ProjectionMatrix );<br />
&nbsp; &nbsp; &nbsp; &nbsp; //int i = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; //D3DXVECTOR3 Position(_Position.X(), _Position.Y(), _Position.Z()), <br />
&nbsp; &nbsp; &nbsp; &nbsp; //&nbsp; &nbsp; &nbsp; &nbsp; Target(_Position.X(), _Position.Y(), _Position.Z()),<br />
&nbsp; &nbsp; &nbsp; &nbsp; //&nbsp; &nbsp; &nbsp; &nbsp; UpVector(0.0f, 1.0f, 0.0f);<br />
&nbsp; &nbsp; &nbsp; &nbsp; //D3DXMatrixLookAtLH(&amp;ViewMatrix, &amp;Position, &amp;Target, &amp;UpVector);<br />
&nbsp; &nbsp; &nbsp; &nbsp; //D3DXMatrixPerspectiveFovLH(&amp;ProjectionMatrix, D3DX_PI / 2, aspect, 1.0f, 5000.0f);<br />
&nbsp; &nbsp; &nbsp; &nbsp; //GraphicDevice::GetService()-&gt;Device()-&gt;SetTransform(D3DTS_PROJECTION, &amp;ProjectionMatrix);<br />
}<br />
void Camera::Rotate(TransformType type, PointF rotation)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; switch(type)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; case TransformTypes::Absolute:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _Rotation = rotation;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; case TransformTypes::Relative:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _Rotation += rotation;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
void Camera::Move(TransformType type, PointF A)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; switch(type)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; case TransformTypes::Absolute:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _Position = A;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; case TransformTypes::Relative:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _Position.Z(_Position.Z() + cos(A.Z()) + sin(A.Z()));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _Position.X(_Position.Z() + cos(A.Z()) - sin(A.Z()));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</code><hr />
</div><br />
<br />
<br />
Then I try to move it like so:<br />
<br />
<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left"><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(KeyboardDevice::GetService()-&gt;Pressed(Keys::ArrowUp)) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; camera.Move(TransformTypes::Relative, PointF(0.0f, 0.0f, 0.1f));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(KeyboardDevice::GetService()-&gt;Pressed(Keys::ArrowDown)) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; camera.Move(TransformTypes::Relative, PointF(0.0f, 0.0f, -0.1f));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</code><hr />
</div><br />
So....Why doesn't this alter the perspective matrix, so that it appears that I am moving?<br />
Does anyone know?</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/game-programming/">Game Programming</category>
			<dc:creator>arcaine01</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/game-programming/120899-confusion-camera-controls.html</guid>
		</item>
	</channel>
</rss>
