So I'm on Lesson 4 of Chillis' amazing tutorials but for some reason a error message keeps appearing for the following code;
int x;
int y;
x = -400;
y = -400;
gfx.PutPixel( x, y, 255, 255, 255 );
gfx.PutPixel(-5 + x, y , 255, 255, 255 );
gfx.PutPixel(-4 + x, y , 255, 255, 255 );
gfx.PutPixel(-3 + x, y , 255, 255, 255 );
gfx.PutPixel( 3 + x, y , 255, 255, 255 );
gfx.PutPixel( 4 + x, y , 255, 255, 255 );
gfx.PutPixel( 5 + x, y , 255, 255, 255 );
gfx.PutPixel( x,-5 + y , 255, 255, 255 );
gfx.PutPixel( x,-4 + y , 255, 255, 255 );
gfx.PutPixel( x,-3 + y , 255, 255, 255 );
gfx.PutPixel( x, 3 + y , 255, 255, 255 );
gfx.PutPixel( x, 4 + y , 255, 255, 255 );
gfx.PutPixel( x, 5 + y , 255, 255, 255 );
I've just started C++, any help for a Newbie please?
-Thankyou
Help for a newbie?
-
- Posts: 9
- Joined: July 29th, 2012, 3:09 pm
Re: Help for a newbie?
x and y should be 400, and not negative 400.
good luck
- Backspace
good luck
- Backspace
Re: Help for a newbie?
Broken is right, to add a little explanation, this happens because you are accessing memory outside the buffer, that doesn't exist.
The screen memory you have ranges from 0 to 480 000 (if your screen resolution is 800x600) so anything outside that will cause an error. In this case you are going out on the negative side. The pixels you are "allowed" to use are x: 0-799, y: 0-599.
If you run the program through "release" you may not get the error if you leave through the sides (since leaving only little from the sides, will have a chance to still be inside the memory boundary), but leaving from the top or bottom or going too far on the sides will definitely be outside the boundary.
The screen memory you have ranges from 0 to 480 000 (if your screen resolution is 800x600) so anything outside that will cause an error. In this case you are going out on the negative side. The pixels you are "allowed" to use are x: 0-799, y: 0-599.
If you run the program through "release" you may not get the error if you leave through the sides (since leaving only little from the sides, will have a chance to still be inside the memory boundary), but leaving from the top or bottom or going too far on the sides will definitely be outside the boundary.
ʕ •ᴥ•ʔ
Re: Help for a newbie?
Thanks guys but there was still an error
The output is;
1>C:\Users\C\Documents\C++\Chili DirectX Framework\Chili DirectX Framework\Chili DirectX Framework.vcxproj : error MSB4014: at Microsoft.Build.Execution.BuildManager.IssueRequestToScheduler(BuildSubmission submission, Boolean allowMainThreadBuild, BuildRequestBlocker blocker)
The output is;
1>C:\Users\C\Documents\C++\Chili DirectX Framework\Chili DirectX Framework\Chili DirectX Framework.vcxproj : error MSB4014: at Microsoft.Build.Execution.BuildManager.IssueRequestToScheduler(BuildSubmission submission, Boolean allowMainThreadBuild, BuildRequestBlocker blocker)
-
- Posts: 9
- Joined: July 29th, 2012, 3:09 pm
Re: Help for a newbie?
According to my research on the subject, there is a hotfix patch that you can download from Microsoft at-->
http://social.msdn.microsoft.com/Forums ... 8874c75397
Also, there is a note at -->
http://connect.microsoft.com/VisualStud ... -c-project
that seems to indicate that an antivirus could be the culprit. They mention Avast by name, but I actually have Avast installed, and I don't have any problems (yet).
<-- Backspace
http://social.msdn.microsoft.com/Forums ... 8874c75397
Also, there is a note at -->
http://connect.microsoft.com/VisualStud ... -c-project
that seems to indicate that an antivirus could be the culprit. They mention Avast by name, but I actually have Avast installed, and I don't have any problems (yet).
<-- Backspace
Re: Help for a newbie?
Thankyou but i copied my code and reinstalled the framework so i think i managed to delete something