Access violation in C++

Posts 1–6 of 6 · Page 1 of 1
Access violation in C++
I have been trying to resolve the access violation in the program for bounding volume hierarchy. I get an access violation error while running it. I have used SDL and lib3d packages.
I'm using visual studio 2010 on windows 7

>Error: Unhandled exception at 0x00fa2e80 in bvh.exe: 0xC0000005: Access violation reading location 0x00000004.

Call Stack :> `bvh.exe!Triangle::Triangle(const Vertex * vertexA, const Vertex * vertexB, const Vertex * vertexC, unsigned int r, unsigned int g, unsigned int b, bool twosided, bool triNormalProvided, Float3 triNormal)` Line 393 + 0x150 bytes C++

here is the link to my code [C++] BVH_SAH - Pastebin.comⓘ
can anyone help with it.

Thank you
I would help , but the code is too difficult to read as is.

And at which function/line does the access violation occur?
@freedompeace

its from the file loader function which (load()) and when this function tries to call the Triangle function
Triangle::Triangle(
const Vertex *vertexA,
const Vertex *vertexB,
const Vertex *vertexC,
unsigned r, unsigned g, unsigned b,
bool twosided , bool triNormalProvided,
Float3 triNormal)
:
_vertexA(vertexA), _vertexB(vertexB), _vertexC(vertexC),

centroid((vertexA->X + vertexB->X + vertexC->X)/3.0f,
(vertexA->Y + vertexB->Y + vertexC->Y)/3.0f,
(vertexA->Z + vertexB->Z + vertexC->Z)/3.0f),

_colorf((float)r,(float)g,(float)b), // For use in all other cases
_color(SDL_MapRGB(Screen::_surface->format, r,g,b)), // For use with DrawPixel
_twoSided(twosided),
_bottom(FLT_MAX,FLT_MAX, FLT_MAX), // Will be updated after centering in Loader
_top(-FLT_MAX, -FLT_MAX,-FLT_MAX) // Will be updated after centering in Loader
{
if (!triNormalProvided)
{
n = Float3((vertexA->n.X + vertexB->n.X + vertexC->n.X)/3.0f,
(vertexA->n.Y + vertexB->n.Y + vertexC->n.Y)/3.0f,
(vertexA->n.Z + vertexB->n.Z + vertexC->n.Z)/3.0f);
n.Normalize();
}
else {n = triNormal;}
}
run as administrator?
PD: us c++ 2008
Quote Originally Posted by s0n1k. View Post
run as administrator?
PD: us c++ 2008
I've never experienced better help in my whole life.
@OP Probably something to do when you use the asynchronous blitting flag. 0x00000004 is defined as SDL_ASYNCBLIT in SDL_video.h
Posts 1–6 of 6 · Page 1 of 1

Post a Reply

Tags for this Thread

Talk with us