Jump to content
  • Advertisement
Sign in to follow this  
yeahdixon

OpenGL Dynamic Texture Generation Locking issue

This topic is 4465 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I am trying to create a texture from an existing image from a computer vision library that has its own internal image format. In OpenGL I used glTexSubImage2D and stuffed it with the right format of image data and I got a nice texture to play with. I want to replicate the same functionality in Direct3d. My guess is that you can use CreateTexture , then Lock it then write to that texture? - I seem to have seen some people doing this. I got the create texture to run , but the lock fails (INVALID CALL) here is the code :

	if(FAILED(pDDev->CreateTexture(this->framewidth,this->frameheight,1,0 , D3DFMT_X8R8G8B8, D3DPOOL_MANAGED,&pVideoTex,NULL)))
	{	
		
	MessageBox(NULL, "Error Creating Texture","failed Create Texture!",MB_OK); // Error Message
	return 0;
	}

	D3DLOCKED_RECT LockedRect;
	hr=(pVideoTex)->LockRect(1,&LockedRect,NULL,0);
	if (FAILED(hr))
	{
		MessageBox(NULL,DXGetErrorString9(hr),DXGetErrorDescription9(hr),MB_OK);
	return FALSE;
	}
	(pVideoTex)->UnlockRect(1);
Any help would be appreciated

Share this post


Link to post
Share on other sites
Advertisement
The first parameter to Lock is 0 based, so in your case, since you don't have any MIP maps, should be 0, not 1.

Also, be sure to use the pitch value returned from the Lock method, especially if the texture isn't necessarily square.

Hope this helps.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!