Skip to main content
gamedev.net
🔒 Locked 🎲 GameMaker

Problem Editing Texture

Started by Antonym Feb 26, 2009 at 3:35 PM 1 replies 800+ views
Original Post
Antonym
Antonym
I am trying to edit a texture by drawing it, then getting its surface, set it to be the render target and then drawing a small yellow circle, however when I run the program the screen just flashes yellow..

void Direct3D::draw_sprite(SpriteInstance *sprt_instance)
{
	set_view();

	D3DXMATRIX matrix;
	D3DXVECTOR2 center; 
	center.x = sprt_instance->sprt->width/2;
	center.y = sprt_instance->sprt->height/2;

	D3DXVECTOR2 pos = scale(sprt_instance->pos);

	RECT frame;

	frame.left = sprt_instance->col * sprt_instance->sprt->width;
	frame.right = frame.left + sprt_instance->sprt->width;
	frame.top = 0;
	frame.bottom = frame.top + sprt_instance->sprt->height;

	D3DXMatrixTransformation2D(&matrix,
							   NULL, //scaling Center
							   NULL, //scaling Rotation
							   NULL, //scaling
							   &center, //rotation Center 
							   sprt_instance->rot, //rotation (radians)
							   &pos); //translation(position)

	d3d_sprite->SetTransform(&matrix);
	//Texture to be drawn
    d3d_sprite->Draw(sprt_instance->sprt->tex, &frame, NULL, NULL, 0xFFFFFFFF);

        //Editing texture
	IDirect3DSurface9 *surface;
	sprt_instance->sprt->tex->GetSurfaceLevel(0, &surface);
	d3d_device->SetRenderTarget(0, surface);

	//Yellow Circle
	d3d_sprite->Draw(tex, &frame, NULL, NULL, 0xFFFFFFF);
}




FeverGames
FeverGames
this happend to me once. It happens when you present the device without the backbuffer beeing set back propperly.

After setting a rendertarget and drawing to it you have to set back the previous one.

Like:

// backup the old targetSurface temp = deevice.GetRenderTarget(0);// set the target to render todevice.SetRenderTarget(0, surfaceToRenderTo);// draw partrender stuff();// set the old backup backdevice.SetRenderTarget(0, temp);


but then in c++ :)
Antonym
Antonym
The screen no longer flashes yellow but no yellow circle is drawn on the texture, am I missing something?

void Direct3D::draw_sprite(SpriteInstance *sprt_instance){	//set_view();	D3DXMATRIX matrix;	D3DXVECTOR2 center; 	center.x = sprt_instance->sprt->width/2;	center.y = sprt_instance->sprt->height/2;	D3DXVECTOR2 pos = scale(sprt_instance->pos);	RECT frame;	frame.left = sprt_instance->col * sprt_instance->sprt->width;	frame.right = frame.left + sprt_instance->sprt->width;	frame.top = 0;	frame.bottom = frame.top + sprt_instance->sprt->height;	D3DXMatrixTransformation2D(&matrix,							   NULL, //scaling Center							   NULL, //scaling Rotation							   NULL, //scaling							   &center, //rotation Center 							   sprt_instance->rot, //rotation (radians)							   &pos); //translation(position)	d3d_sprite->SetTransform(&matrix);	//Draw texture    d3d_sprite->Draw(sprt_instance->sprt->tex, &frame, NULL, NULL, 0xFFFFFFFF);	IDirect3DSurface9 *surfaceTemp;	d3d_device->GetRenderTarget(0, &surfaceTemp);	IDirect3DSurface9 *surface;	sprt_instance->sprt->tex->GetSurfaceLevel(0, &surface);	d3d_device->SetRenderTarget(0, surface);	//Draw yellow circle on texture	d3d_sprite->Draw(tex, &frame, NULL, NULL, 0xFFFFFFF);	d3d_device->SetRenderTarget(0, surfaceTemp);}

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.