Click here to Skip to main content
14,828,794 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:

I am working through a book about character animation with direct3d

There is a CD-ROM that came with the book and the examples on the cd will compile and run ok in debug mode but when I compile a release build, I get a runtime error to do with a vector:
iterator insert(const_iterator _Where, const _Ty& _Val)
        {   // insert _Val at _Where
        size_type _Off = size() == 0 ? 0 : _Where - begin();
        _Insert_n(_Where, (size_type)1, _Val);
        return (begin() + _Off);

Any idea how I can compile and run in release mode?

I'm thinking that I need to link in some library to get it to work but as I say it compiles fine with the current d3d9.lib and d3dx9.lib.
Ok, I tried a unicode build instead and I get an access violation with the wofstream

can you help me get to the bottom of what's going on?

I've upgraded to visual c++ professional and still getting a problem with vector push_back. Here's the code that's playing up:

// Copy materials and load textures.
    for(int i=0; i<(int)NumMaterials; i++)
        D3DXMATERIAL mtrl;
        memcpy(&mtrl, &pMaterials[i], sizeof(D3DXMATERIAL));


The problem is with materials.push_back

seems like i'm passing a bad value
Updated 11-Mar-13 12:30pm

In order to build a working application you need more than that. You need header files, and other definitions. What you have published here is a partial piece of source code. You will need to use Visual Studio to create a new project, which will create for you an almost empty application, which will be the skeleton for your work. Then you need to add your routine and make sure your routine is called. The simple way is to add a button that when pressed, your routine is called. Then you change the configuration from DEBUG to RELEASE, and press Build. You will then get the application.
I've finally found a solution. After using some break points I determined where the problem was occurring (the use of a vector to hold materials).

I've implemented a custom vector now using a template class and low and behold my program works in release mode and debug.

I still don't know why the vector didn't work as expected but now I can append items to the custom vector.

thanks for your reply

The code I posted here is where the runtime error is occurring. I believe the problem lies with something to do with visual studio; I read somewhere that certain release builds work in other versions of visual C++. I've got headers and a working application, but it will only run in debug mode. I'm trying to find out why the release won't run but it will compile ok.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900