HMMMM I get a Unhandled exception :( after doing tutorial 5.

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
Hloki
Posts: 5
Joined: September 29th, 2017, 10:19 am

HMMMM I get a Unhandled exception :( after doing tutorial 5.

Post by Hloki » September 29th, 2017, 10:23 am

I have no idea how to fix this and really do not know why it came about.

Line 51 in Color.h is where it is showing the Unhandled exception :(

Thanks in advance for any input on this situation.






'Engine.exe' (Win32): Loaded 'C:\Users\Devin\Desktop\Chili Framework 2016\Release\Engine.exe'. Symbols loaded.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\kernel32.dll'
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\win32u.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32full.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp_win.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ucrtbase.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\d3d11.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dxgi.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcryptprimitives.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\uxtheme.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\combase.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\oleaut32.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dwmapi.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel.appcore.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\TextInputFramework.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\CoreUIComponents.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\SHCore.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\CoreMessaging.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntmarta.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\CoreMessaging.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\CoreMessaging.dll'
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\WinTypes.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\usermgrcli.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ResourcePolicyClient.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\ResourcePolicyClient.dll'
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\aticfx32.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\version.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmm.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmmbase.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmmbase.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\winmmbase.dll'
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmmbase.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\winmmbase.dll'
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\atiuxpag.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\atiuxpag.dll'
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\atiuxpag.dll'. Cannot find or open the PDB file.
'Engine.exe' (Win32): Loaded 'C:\Windows\SysWOW64\atidxx32.dll'. Cannot find or open the PDB file.
Exception thrown: write access violation.
this->gfx.**pSysBuffer** was 0x97C2902.

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: HMMMM I get a Unhandled exception :( after doing tutoria

Post by Yumtard » September 29th, 2017, 5:17 pm

hard to tell what you're doing wrong without any code.
maybe youre trying to draw outside the screen or something.

post the code and I'll look at it

Hloki
Posts: 5
Joined: September 29th, 2017, 10:19 am

Re: HMMMM I get a Unhandled exception :( after doing tutoria

Post by Hloki » September 29th, 2017, 6:47 pm

THIS IS GAME.CPP

#include "MainWindow.h"
#include "Game.h"

Game::Game( MainWindow& wnd )
:
wnd( wnd ),
gfx( wnd )
{
}

void Game::Go()
{
gfx.BeginFrame();
UpdateModel();
ComposeFrame();
gfx.EndFrame();
}

void Game::UpdateModel()
{
if (wnd.kbd.KeyIsPressed(VK_RIGHT))
{
if (inhibitRight)
{
}
else
{
vx = vx + 1;
inhibitRight = true;
}
}
else
{
inhibitRight = false;
}
if (wnd.kbd.KeyIsPressed(VK_LEFT))
{
if (inhibitLeft)
{
}
else
{
vx = vx - 1;
inhibitLeft = true;
}
}
else
{
inhibitLeft = false;
}
if (wnd.kbd.KeyIsPressed(VK_DOWN))
{
if (inhibitDown)
{
}
else
{
vy = vy + 1;
inhibitDown = true;
}
}
else
{
inhibitDown = false;
}
if (wnd.kbd.KeyIsPressed(VK_UP))
{
if (inhibitUp)
{
}
else
{
vy = vy - 1;
inhibitUp = true;
}
}
else
{
inhibitUp = false;
}
if (wnd.kbd.KeyIsPressed(VK_SPACE))
{
vx = 0;
vy = 0;
}
if (x + 5 >= gfx.ScreenWidth)
{
x = gfx.ScreenWidth - 6;
vx = 0;
}
if (x - 5 < 0)
{
x = 5;
vx = 0;
}
if (y + 5 >= gfx.ScreenHeight)
{
y = gfx.ScreenHeight - 6;
vy = 0;
}
if (y = 5 < 0)
{
y = 5;
vy = 0;
}
x = x + vx;
y = y + vy;
shapeIsChanged = false;
if (!(x < 200 || x > 300))
{
shapeIsChanged = true;
}

if (wnd.kbd.KeyIsPressed(VK_CONTROL))
{
gb = 0;
}
shapeIsChanged = wnd.kbd.KeyIsPressed(VK_SHIFT);
}

void Game::ComposeFrame()
{
if (shapeIsChanged)
{
gfx.PutPixel(-5 + x, -5 + y, 255, gb, gb);
gfx.PutPixel(-5 + x, -4 + y, 255, gb, gb);
gfx.PutPixel(-5 + x, -3 + y, 255, gb, gb);
gfx.PutPixel(-4 + x, -5 + y, 255, gb, gb);
gfx.PutPixel(-3 + x, -5 + y, 255, gb, gb);
gfx.PutPixel(-5 + x, 5 + y, 255, gb, gb);
gfx.PutPixel(-5 + x, 4 + y, 255, gb, gb);
gfx.PutPixel(-5 + x, 3 + y, 255, gb, gb);
gfx.PutPixel(-4 + x, 5 + y, 255, gb, gb);
gfx.PutPixel(-3 + x, 5 + y, 255, gb, gb);
gfx.PutPixel(5 + x, -5 + y, 255, gb, gb);
gfx.PutPixel(5 + x, -4 + y, 255, gb, gb);
gfx.PutPixel(5 + x, -3 + y, 255, gb, gb);
gfx.PutPixel(4 + x, -5 + y, 255, gb, gb);
gfx.PutPixel(-3 + x, -5 + y, 255, gb, gb);
gfx.PutPixel(5 + x, 5 + y, 255, gb, gb);
gfx.PutPixel(5 + x, 4 + y, 255, gb, gb);
gfx.PutPixel(5 + x, 3 + y, 255, gb, gb);
gfx.PutPixel(4 + x, 5 + y, 255, gb, gb);
gfx.PutPixel(3 + x, 4 + y, 255, gb, gb);
}
else
{
gfx.PutPixel(-5 + x, y, 255, gb, gb);
gfx.PutPixel(-4 + x, y, 255, gb, gb);
gfx.PutPixel(-3 + x, y, 255, gb, gb);
gfx.PutPixel(3 + x, y, 255, gb, gb);
gfx.PutPixel(4 + x, y, 255, gb, gb);
gfx.PutPixel(5 + x, y, 255, gb, gb);
gfx.PutPixel(x, -5 + y, 255, gb, gb);
gfx.PutPixel(x, -4 + y, 255, gb, gb);
gfx.PutPixel(x, -3 + y, 255, gb, gb);
gfx.PutPixel(x, 3 + y, 255, gb, gb);
gfx.PutPixel(x, 4 + y, 255, gb, gb);
gfx.PutPixel(x, 5 + y, 255, gb, gb);
}
}

THIS IS GAME.H


#pragma once

#include "Keyboard.h"
#include "Mouse.h"
#include "Graphics.h"

class Game
{
public:
Game( class MainWindow& wnd );
Game( const Game& ) = delete;
Game& operator=( const Game& ) = delete;
void Go();
private:
void ComposeFrame();
void UpdateModel();
/********************************/
/* User Functions */
/********************************/
private:
MainWindow& wnd;
Graphics gfx;
/********************************/
/* User Variables */
int x = 400;
int y = 300;
int vx = 0;
int vy = 0;
int gb = 255;
bool shapeIsChanged = false;
bool inhibitUp = false;
bool inhibitDown = false;
bool inhibitLeft = false;
bool inhibitRight = false;
/********************************/
};
THIS IS COLOR.H

class Color
{
public:
unsigned int dword;
public:
constexpr Color() : dword() {}
constexpr Color( const Color& col )
:
dword( col.dword )
{}
constexpr Color( unsigned int dw )
:
dword( dw )
{}
constexpr Color( unsigned char x,unsigned char r,unsigned char g,unsigned char b )
:
dword( (x << 24u) | (r << 16u) | (g << 8u) | b )
{}
constexpr Color( unsigned char r,unsigned char g,unsigned char b )
:
dword( (r << 16u) | (g << 8u) | b )
{}
constexpr Color( Color col,unsigned char x )
:
Color( (x << 24u) | col.dword )
{}
Color& operator =( Color color )
{
dword = color.dword; (X HERE IS WHERE IT SHOWS THE UNHANDLED
EXCPETION)"Exception thrown: write access violation.
this->gfx.**pSysBuffer** was 0x9759902
.
return *this;
}
constexpr unsigned char GetX() const
{
return dword >> 24u;
}
constexpr unsigned char GetA() const
{
return GetX();
}
constexpr unsigned char GetR() const
{
return (dword >> 16u) & 0xFFu;
}
constexpr unsigned char GetG() const
{
return (dword >> 8u) & 0xFFu;
}
constexpr unsigned char GetB() const
{
return dword & 0xFFu;
}
void SetX( unsigned char x )
{
dword = (dword & 0xFFFFFFu) | (x << 24u);
}
void SetA( unsigned char a )
{
SetX( a );
}
void SetR( unsigned char r )
{
dword = (dword & 0xFF00FFFFu) | (r << 16u);
}
void SetG( unsigned char g )
{
dword = (dword & 0xFFFF00FFu) | (g << 8u);
}
void SetB( unsigned char b )
{
dword = (dword & 0xFFFFFF00u) | b;
}
};

namespace Colors
{
static constexpr Color MakeRGB( unsigned char r,unsigned char g,unsigned char b )
{
return (r << 16) | (g << 8) | b;
}
static constexpr Color White = MakeRGB( 255u,255u,255u );
static constexpr Color Black = MakeRGB( 0u,0u,0u );
static constexpr Color Gray = MakeRGB( 0x80u,0x80u,0x80u );
static constexpr Color LightGray = MakeRGB( 0xD3u,0xD3u,0xD3u );
static constexpr Color Red = MakeRGB( 255u,0u,0u );
static constexpr Color Green = MakeRGB( 0u,255u,0u );
static constexpr Color Blue = MakeRGB( 0u,0u,255u );
static constexpr Color Yellow = MakeRGB( 255u,255u,0u );
static constexpr Color Cyan = MakeRGB( 0u,255u,255u );
static constexpr Color Magenta = MakeRGB( 255u,0u,255u );
}

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: HMMMM I get a Unhandled exception :( after doing tutoria

Post by Yumtard » September 29th, 2017, 7:37 pm

if (y = 5 < 0)
{
y = 5;
vy = 0;
}

Here's your problem bro

see this line. = is assignment operator. == is comparison. But I'm assuming you meant to type
if (y -5 < 0)
if (y = 5 < 0)

like I thought, the exception was about you drawing off screen since this line set y to 0

Hloki
Posts: 5
Joined: September 29th, 2017, 10:19 am

Re: HMMMM I get a Unhandled exception :( after doing tutoria

Post by Hloki » September 29th, 2017, 7:58 pm

WOW lol One little f*** up in my writing and it does that lol. WHY SO SENSITIVE C++!!

EDIT: Not really a little F*** up lol more like I tried telling it that hey y=5 but is less than 0 ohhhh by the way Y = 5 lol
Last edited by Hloki on September 29th, 2017, 7:59 pm, edited 1 time in total.

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: HMMMM I get a Unhandled exception :( after doing tutoria

Post by Yumtard » September 29th, 2017, 7:58 pm

^ Get used to it :D

Hloki
Posts: 5
Joined: September 29th, 2017, 10:19 am

Re: HMMMM I get a Unhandled exception :( after doing tutoria

Post by Hloki » September 29th, 2017, 8:51 pm

if (y + 5 >= gfx.ScreenHeight)
{
y = gfx.ScreenHeight - 6;
vy = 0;
}
if (y - 5 < 0)
{
y = 5;
}


game crashes when I go up to the top of the screen. I have fixed my code it runs now but when i hit the top of my y axis or the bottom of my y axis. Its not creating a border there for some reason. I have the same code as Chili does in the video. His works fine but for some reason mine doesn't :(

EDIT: The Code works fine for the x axis but not the y axis.

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: HMMMM I get a Unhandled exception :( after doing tutoria

Post by Yumtard » September 29th, 2017, 11:06 pm

You could fix this by taking this code:

Code: Select all

x = x + vx;
y = y + vy;
and move it from the bottom of UpdateModel() to the top of UpdateModel()

Think about it.

Say y is 6 pixels less than screenheight.

Code: Select all

if ((y + 5) >= gfx.ScreenHeight)
	{
		y = gfx.ScreenHeight - 6;
		vy = 0;
	}

then this code wont be executed since y + 5 is 1 pixel less then screen height.
After this, you add vy to y.
Say vy is 2. Then y will now be just 4 pixels less than screenheight and the reticle will be 1 pixel off screen.


if instead you'd have put the y += vy; code before the if statement.
Now this would happen:
- y is 6 pixels less than screenheight.
- you add vy so now y is 4 pixels less than screenheight
- you check if y+5 is bigger than screenheight which it is so you adjust y and set vy to 0 and then draw the reticle

Hloki
Posts: 5
Joined: September 29th, 2017, 10:19 am

Re: HMMMM I get a Unhandled exception :( after doing tutoria

Post by Hloki » September 29th, 2017, 11:32 pm

OOOH okay :) this clarifies it pretty well :D thank you man :D I've been having a fit over here lol Didn't even think to try that out... TBH it did look out of place. I was calling the functions after the error. It needed to be called before everything was put in so it knew what to do :) Man... I am glad I have you to help me lol :)

Post Reply