Jump to content

  • Log In with Google      Sign In   
  • Create Account

ankhd

Member Since 05 Nov 2006
Offline Last Active Yesterday, 05:45 PM

Topics I've Started

Is This normal behavior for a ID3D10ShaderResourceView bound to a rendertarget

27 November 2014 - 05:55 PM

Hi.

I have 2 image boxes I created for a UI system they both have there mesh material and a over ride material.

this over ride material gets set when setmaterial 1 button and set material 2 buttons are pressed.

I have a render target set for rendering meshes and that targts ID3D10ShaderResourceView gets copyed to the image boxes material.

Now picture this there is 2 image boxes on the screen 1 on the left and one on the right with a button under each.

The only time the render target is invoked is when one of the 2 button are pressed(its not a real time render)

after rendering depending if it was button 1 or 2 I set there materials ID3D10ShaderResourceView to the render targets ID3D10ShaderResourceView

thats ok the mesh is there and it works. but if I press button 2 and have a different mesh both the image boxes display the same view.

It's like when I set the ID3D10ShaderResourceView its a pointer to the current render target.

heres the code that I use to copy and create the view I also delete the view.

 

 

This code in a function when it ends it no longer has focus

///////////////////////////////////////////////////////////////////////////////////////
//we need to create a resource and copy the rt to it 
				// Create the shader-resource view
				D3D10_SHADER_RESOURCE_VIEW_DESC srDesc;
				srDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
				srDesc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;
				srDesc.Texture2D.MostDetailedMip = 0;
				srDesc.Texture2D.MipLevels = 1;
				

				ID3D10ShaderResourceView *pShaderResView = NULL;
				ID3D10Resource *pResource = NULL;

				RenderTargetMesh.colorMap()->GetResource(&pResource);
				HRESULT hr = c3DDevice::m_pd3dDevice->CreateShaderResourceView( pResource, &srDesc, &pShaderResView );
				if(FAILED(hr))
				{
					OutPutDebugText("RenderLibraryToMapDefinedObjects(Failed T Create ResourceView",//TCHAR *errormsg,//the message to display
					"cRTSAssetUIManager::RenderLibraryToMapDefinedObjects()",//TCHAR *locmsg,//the location the message was called Eg. what function
					true);// bool Usewindowmsgbox = false);
				}


				SAFE_RELEASE(pResource);
				//now copy it over
				//c3DDevice::m_pd3dDevice->CopyResource(RenderTargetMesh.colorMap(), &imagebox->mat[0].m_pTextureRV)

				//now set the new one DialogBox_Objects->ImageBox[0].
				imagebox->mat[0].m_pTextureRV = pShaderResView;
				//imagebox->mat[0].m_pTextureRV->AddRef();
				//SAFE_RELEASE(pShaderResView);

////////////////////////////////////////////////////////

But if I do it like this it works It involes creating a texture but



	ID3D10Texture2D* colMap = 0;
	ID3D10ShaderResourceView *newresource = NULL;

	D3D10_TEXTURE2D_DESC texDesc;
	
	texDesc.Width     = mWidth;
	texDesc.Height    = mHeight;
	texDesc.MipLevels = 1;//0 will set them to autao generate mip maps
	texDesc.ArraySize = 1;
	texDesc.Format    = mColorMapFormat;
	texDesc.SampleDesc.Count   = 1;  
	texDesc.SampleDesc.Quality = 0;  
	texDesc.Usage          = D3D10_USAGE_DEFAULT;
	texDesc.BindFlags      = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
	texDesc.CPUAccessFlags = 0; 
	texDesc.MiscFlags      = D3D10_RESOURCE_MISC_GENERATE_MIPS;

	if(FAILED(md3dDevice->CreateTexture2D(&texDesc, 0, &colMap)))
	{
		OutPutDebugText("CreateTexture2D FAILED TO CREATE",//the message to display
						"DrawableTex2D->CopyRenderTarget()",//the location the message was called Eg. what function
						 true);//bool Usewindowmsgbox = false);//true if you also want to display it in a messagebox
		return NULL;//error
	}//end error


	//now we want to copy the rendertarget to this new colourmap 
	ID3D10Resource *pResource = NULL;

	colorMap()->GetResource(&pResource);

	md3dDevice->CopyResource(colMap, pResource);

	if(FAILED(md3dDevice->CreateShaderResourceView(colMap, 0, &newresource)))
	{
		OutPutDebugText("CreateShaderResourceView FAILED TO CREATE",//the message to display
						"DrawableTex2D->CopyRenderTarget()",//the location the message was called Eg. what function
						 true);//bool Usewindowmsgbox = false);//true if you also want to display it in a messagebox
		return NULL;//error
	}//end error

	// View saves a reference to the texture so we can release our reference.
	SAFE_RELEASE(colMap);
	SAFE_RELEASE(pResource);





The once a week post rule thing

15 November 2014 - 04:14 PM

What's with the once a week post rule thing. The forum is boring when no one posts

Boost::Serialize const obj and non const obj

14 November 2014 - 09:47 PM

Hi.

 

The examples show writting to the archive with const object data and when you remove the const the compiler build displays all this here.

1>------ Build started: Project: SerializeFile2, Configuration: Debug Win32 ------
1>  main.cpp
1>  Linking to lib file: libboost_serialization-vc100-mt-gd-1_56.lib
1>  Linking to lib file: libboost_serialization-vc100-mt-gd-1_56.lib
1>c:\boost_1_56_0\boost\mpl\print.hpp(52): warning C4308: negative integral constant converted to unsigned type
1>          c:\boost_1_56_0\boost\serialization\static_warning.hpp(93) : see reference to class template instantiation 'boost::mpl::print<T>' being compiled
1>          with
1>          [
1>              T=boost::serialization::BOOST_SERIALIZATION_STATIC_WARNING_LINE<98>
1>          ]
1>          c:\boost_1_56_0\boost\archive\detail\check.hpp(98) : see reference to class template instantiation 'boost::serialization::static_warning_test<B,L>' being compiled
1>          with
1>          [
1>              B=false,
1>              L=98
1>          ]
1>          c:\boost_1_56_0\boost\archive\detail\oserializer.hpp(313) : see reference to function template instantiation 'void boost::archive::detail::check_object_tracking<T>(void)' being compiled
1>          with
1>          [
1>              T=gps_position
1>          ]
1>          c:\boost_1_56_0\boost\archive\detail\oserializer.hpp(525) : see reference to function template instantiation 'void boost::archive::detail::save_non_pointer_type<Archive>::invoke<T>(Archive &,T &)' being compiled
1>          with
1>          [
1>              Archive=boost::archive::text_oarchive,
1>              T=gps_position
1>          ]
1>          c:\boost_1_56_0\boost\archive\detail\common_oarchive.hpp(69) : see reference to function template instantiation 'void boost::archive::save<Archive,T>(Archive &,T &)' being compiled
1>          with
1>          [
1>              Archive=boost::archive::text_oarchive,
1>              T=gps_position
1>          ]
1>          c:\boost_1_56_0\boost\archive\basic_text_oarchive.hpp(86) : see reference to function template instantiation 'void boost::archive::detail::common_oarchive<Archive>::save_override<T>(T &,int)' being compiled
1>          with
1>          [
1>              Archive=boost::archive::text_oarchive,
1>              T=gps_position
1>          ]
1>          c:\boost_1_56_0\boost\archive\detail\interface_oarchive.hpp(63) : see reference to function template instantiation 'void boost::archive::basic_text_oarchive<Archive>::save_override<T>(T &,int)' being compiled
1>          with
1>          [
1>              Archive=boost::archive::text_oarchive,
1>              T=gps_position
1>          ]
1>          c:\my3dgames\serializefile2\serializefile2\main.cpp(70) : see reference to function template instantiation 'Archive &boost::archive::detail::interface_oarchive<Archive>::operator <<<gps_position>(T &)' being compiled
1>          with
1>          [
1>              Archive=boost::archive::text_oarchive,
1>              T=gps_position
1>          ]
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

what do you do with non const objects.

 

the serialization seems to work when the const is removed but is it safe to do this.??

 

If I add a new member to the class and want other input after object creation like this.

gps_Position g(35, 59, 24.567f, name);//im testing string as well

//new member thats why it cant be a const 
g.SetPin(true);

//then save data to achive.

Is that ok to do.

 

Or what is the correct way to go about this sort of thing.


Problem with first boost::serialization app not a good start.

13 November 2014 - 12:26 AM

Hello all.

 

Just playing with boost for the first time.

 

And VC10 is warning about this here.

 Creating library C:\My3dGames\BoostFileSerialize\Debug\BoostFileSerialize.lib and object C:\My3dGames\BoostFileSerialize\Debug\BoostFileSerialize.exp
1>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
1>  BoostFileSerialize.vcxproj -> C:\My3dGames\BoostFileSerialize\Debug\BoostFileSerialize.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Do I need to be concerned about that warning.?????

 

and the basic example for serialize fails with the following error.

First-chance exception at 0x779bdd6d in BoostFileSerialize.exe: 0xC0000005: Access violation writing location 0x00000014.
Unhandled exception at 0x779bdd6d in BoostFileSerialize.exe: 0xC0000005: Access violation writing location 0x00000014.

the line of code that create this error is this.


 boost::archive::text_oarchive oa(ofs);

and VC breaks in fstream

virtual void __CLR_OR_THIS_CALL _Lock()
		{	// lock file instead of stream buffer
		if (_Myfile)
			_CSTD _lock_file(_Myfile);
		}

what have I done wrong, there's nothing to the program.

 

here is the code.

#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <fstream>

// include headers that implement a archive in simple text format
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>



/////////////////////////////////////////////////////////////
// gps coordinate
//
// illustrates serialization for a simple type
//
class gps_position
{
private:
    friend class boost::serialization::access;
    // When the class Archive corresponds to an output archive, the
    // & operator is defined similar to <<.  Likewise, when the class Archive
    // is a type of input archive the & operator is defined similar to >>.
    template<class Archive>
    void serialize(Archive & ar, const unsigned int version)
    {
        ar & degrees;
        ar & minutes;
        ar & seconds;
    }
    int degrees;
    int minutes;
    float seconds;
public:
    gps_position(){};
    gps_position(int d, int m, float s) :
        degrees(d), minutes(m), seconds(s)
    {}
};



int main()
{
  //  using namespace boost::lambda;
 //   typedef std::istream_iterator<int> in;

	 // create and open a character archive for output
    std::ofstream ofs("filename");

    // create class instance
    const gps_position g(35, 59, 24.567f);

    // save data to archive
    {
        boost::archive::text_oarchive oa(ofs);
        // write class instance to archive
        oa << g;
    	// archive and stream closed when destructors are called
    }

    // ... some time later restore the class instance to its orginal state
    gps_position newg;
    {
        // create and open an archive for input
        std::ifstream ifs("filename");
        boost::archive::text_iarchive ia(ifs);
        // read class state from archive
        ia >> newg;
        // archive and stream closed when destructors are called
    }



    //std::for_each(
    //    in(std::cin), in(), std::cout << (_1 * 3) << " " );
}


So Would you dress like a deer in hunting season

30 October 2014 - 06:12 PM

So why dress like zombies on Zombie hunting night.

 

Imagine if you were at the pub and walking home and a bunch of zombies started walking around would you blame the guy for picking up a stick and start smashing heads. could be a heap of people on bath salts (zombie drug). So you either smash them or have your face eaten off.


PARTNERS