Windows error 0x000000BF, 191

Detailed Error Information


MessageCannot run %1 in Win32 mode.
Declared inwinerror.h

This appears to be a raw Win32 error. More information may be available in error 0x800700BF.


This is a Blue Screen of Death stop code. More information is available in the Knowledge Base article Bug Check 0xBF: MUTEX_ALREADY_OWNED.

HRESULT analysis[3]

This is probably not the correct interpretation of this error. The Win32 error above is more likely to indicate the actual problem.

This code indicates success, rather than an error. This may not be the correct interpretation of this code, or possibly the program is handling errors incorrectly.

Reserved (R)false
Reserved (X)false
FacilityCode0 (0x000)
DescriptionThe default facility code.[3][1]
Error Code191 (0x00bf)

Possible solutions


Error in color fading function


What you should to now is first you should spend maybe 5 minutes to write down some really basic tests with the cases where you know what you expect. You don't even need to use any test framework, because to get rolling you could just use assert:

// basicTests.c
#include <assert.h>

int getFadedColor_basicTests()
    assert(GetFadedColor(0x00000000, 0xff33cccc, 0.3f) == 0x4c0f3d3d  && "30% from black to light blue should be greenish");
    assert(GetFadedColor(0xff33cccc, 0x00000000, 0.3f) == something   && "30% from one color to another should be...");

    // if you're not sure what the exact value should be, you should write a helper function
    // that returns true/false for if each of the four components of the actual color
    // are in a sensible expected range

int main()
    return 0;

Once you're happy with how much coverage you get with tests, be it just 3 asserts total, or maybe 50 asserts if you feel like it, you should start reformatting the one-liner, breaking the line, adding meaningful indentation and comments. Start refactoring, extract out common expressions, add comments on what they do or should do, all while running the tests in between changes and adding tests as you devise new ones.


Isn't it just supposed to linearly extrapolate each of the components separately?

int fade(int from_, int to_, float factor)
    unsigned char *from = (unsigned char*)&from_;
    unsigned char *to = (unsigned char*)&to_;
    int result_;
    unsigned char *result = (unsigned char*)&result_;

    for (int i = 0 ; i < 4; ++i)
        result[i] = factor * ((int)to[i] - (int)from[i]) + from[i];

    return result_;
answered on Stack Overflow May 29, 2013 by Adrian Panasiuk • edited May 29, 2013 by Adrian Panasiuk

Projection matrix causing inaccuracy in clip-space depth calculation?


Your depth buffer always has the same value written into it because you have your projection matrix wrong. The value that actually gets written is the w-value so you need to juggle your matrix around a bit.

The DirectX documentation gives a good explanation of the perspective transform.

Basically your matrix should be as follows

W, 0, 0, 0
0, H, 0, 0
0, 0, Q, 1
0, 0, P, 0


W = 1.0f / tanf( fovHoriz / 2 );
H = 1.0f / tanf( fovVert  / 2 );
Q = zFar / (zFar - zNear);
P = -Q * zNear;
answered on Stack Overflow May 20, 2013 by Goz • edited May 23, 2017 by Community


Leave a comment

(plain text only)


  1. winerror.h from Windows SDK 10.0.14393.0

User contributions licensed under CC BY-SA 3.0