Skip to main content
Richard Rosenman
Inspiring
May 14, 2022
Answered

Drawing on a new Effect World not working

  • May 14, 2022
  • 1 reply
  • 452 views

Hi gang;

 

I would like to create a new effect world, draw to it, and then transform it with transform_world.

 

Something isn't working correctly so I will outline my process in case I should be approaching it differently. I have simplified this code for posting here so hopefully I didn't mistype anything but I think you'll get the idea of what I'm trying to do.

 

First, I create a small 10x10 effect world:

ERR(suites.WorldSuite1()->new_world(in_data->effect_ref,
							10L,
							10L,
							flags,
							&my_world));

 

Then I call my drawing function which scans through every pixel and simply outputs an alpha of 255 and a color blue (this is just for testing).

 

ERR(drawPixel32(px, py, 10, &my_world));

 

Here is my drawing function, *myPixel is the standard drawing function in the manual which I will also list below:

 

static PF_Err
drawPixel32(int x, int y, int size, PF_EffectWorld *output)
{
	PF_Err err = PF_Err_NONE;
	int u, v;

	for (u=0; u < size; u++)
	for (v=0; v < size; v++)
	{

	PF_Pixel *myPixel = sampleIntegral32(*output,x+u,y+v);
	myPixel->red = 0;
	myPixel->green = 0;
	myPixel->blue =	255;
	myPixel->alpha = 255;

	} // uv

	return err;
}

 

 

PF_Pixel *sampleIntegral32(PF_EffectWorld &def, int x, int y){
return (PF_Pixel*)((char*)def.data +
(y * def.rowbytes) +
(x * sizeof(PF_Pixel)));
}

 

 

 

 

And I follow this by displaying &my_world using transform_world. But it doesn't display any of my drawing function. I know this is not an issue with transform_world because if I fill &my_world with PF_FILL, it shows up. 

 

If I want to draw pixel by pixel to an effect world, what is wrong with my approach?

 

Thanks,

-Richard

This topic has been closed for replies.
Correct answer shachar carmi

without diving into your code (which seems ok at a glance), have you tried drawing using drawPixel32 directly into the output?

just trying some basic elimination here.

1 reply

shachar carmiCommunity ExpertCorrect answer
Community Expert
May 14, 2022

without diving into your code (which seems ok at a glance), have you tried drawing using drawPixel32 directly into the output?

just trying some basic elimination here.

Richard Rosenman
Inspiring
May 15, 2022

Hi Sachar;

 


@shachar carmi wrote:

without diving into your code (which seems ok at a glance), have you tried drawing using drawPixel32 directly into the output?

just trying some basic elimination here.


 

Thank you, as always, for your helpful reply.

 

Your confirmation that I was indeed following the correct process prompted me to hunt through the rest of my code for logic mistakes and I found it. I also changed the output from &my_world to output as you suggested and indeed it was working correctly so that confirmed it.

 

Thank you again for your help.

 

Regards,

Rich