0xC000041D:用户回调期间遇到未处理的异常

问题描述 投票:0回答:1

当我运行 OpenGL 代码时,遇到错误“0xC000041D:用户回调期间遇到未处理的异常”。调试器指示错误发生在此处:

下面给出了发生错误的函数以及调用函数。

您能帮我找出此错误的原因吗?

double maxDistance(Point_2D* bez, int deg)
{
int i;
double maxheight;
double height[30];

// Computing baseline vector and its magnitude
Point_2D baselineVector;
baselineVector.x = bez[deg].x - bez[0].x;
baselineVector.y = bez[deg].y - bez[0].y;
double baselineMag = sqrt((baselineVector.x*baselineVector.x) + (baselineVector.y*baselineVector.y));

double crossprod[3];

double crossprodMag;

// Computing height of a intermediate control points from baseline
Point_2D cpVector; // Vector from first control point to intermediate control point
for (i = 1; i < deg; i++)
{
    cpVector.x = bez[i].x - bez[0].x;
    cpVector.y = bez[i].y - bez[0].y;

    // Computing cross product of baseline vector and control point vector
    //z coordinates of baseline and control point vectors are 0
    crossprod[0] = ((baselineVector.y * 0) - (0 * cpVector.y));
    crossprod[1] = -((baselineVector.x * 0) - (0 * cpVector.x));
    crossprod[2] = ((baselineVector.x * cpVector.y) - (baselineVector.y * cpVector.x));
    crossprodMag = sqrt((crossprod[0] * crossprod[0]) + (crossprod[1] * crossprod[1]) + (crossprod[2] * crossprod[2]));
    height[i] = crossprodMag / baselineMag;
}

// Finding maximum height of a control point from baseline
maxheight = height[0];
for (i = 0; i < deg; i++)
{
    if (maxheight < height[i])
        maxheight = height[i];
}


return maxheight;
}
void plotBezier(Point_2D* bez, int deg)
{
Point_2D* leftBez= (Point_2D*)malloc((deg + 1)*sizeof(Point_2D));
Point_2D* rightBez=(Point_2D*)malloc((deg + 1)*sizeof(Point_2D));;
double height = maxDistance(bez, deg);
if (height < flat_thresh)
{
    drawLine(bez[0], bez[deg]);
    return;
}
else
{
    midSubdivideBezier(bez, deg, leftBez, rightBez);
    plotBezier(leftBez, deg);
    plotBezier(rightBez, deg);
}
free(leftBez);
free(rightBez);
 }



//============================================================
void adaptiveRender()
 {
Point_2D*  bez =(Point_2D*) malloc(30 * sizeof(Point_2D)); // assume the degree is not greater than 29.
int      i;

for (i = bcr.degree; i< bcr.deBoor_count; i++) // Determining segments between the kth knot and the (n+1)th knot
{
    if (!(fabs(bcr.knots[i] - bcr.knots[i + 1]) < 0.00001)) // No segment when adjacent knots are equal
    {
        extractBezier(bez, i);        // Extract the i-th Bezier curve
        plotBezier(bez, bcr.degree);   // Adaptively plot a Bezier curve 
    }
}
free(bez);
}
c opengl exception visual-studio-2015 unhandled
1个回答
0
投票

我遇到了这个确切的问题,但仅限于配备 intel+nvidia 双显卡的笔记本电脑。对我来说,当我使用

添加 .def 文件时,它就开始发生
HEAPSIZE  1024  
STACKSIZE 4096

这些参数对于独立的 nvidia GPU 驱动程序来说似乎没问题,但对于 intel 驱动程序可能会出现一些问题。从 .def 文件中删除这些指令修复了堆栈溢出问题。希望这对下一个人有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.