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

时间:2015-10-23 18:49:22

标签: c opengl exception visual-studio-2015 unhandled

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

Debugger Screen

发生错误的函数和调用函数如下所示。

请你帮我确定一下这个错误的原因。

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);
}

0 个答案:

没有答案