PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

PixelShader error

I get an illegal operation if I try to use the PixelShader as shown in a previous post.

Exception 0xc0000005
address: 00018dd4

Code:


struct InfraredShader : public PixelShader
{
Pixel operator()( Pixel src, Pixel dest ) const
{
return (src & RED_MASK);
}
};

InfraredShader ir_shader;
DisplayDevice* display = GetDisplay();
display->SetPixelShader( &ir;_shader );

Am I supposed to put values in place of src & dest ? Can't figure it out.

( I'm just finishing an animation demo for my next chapter, parallax scrolling clouds & trees plus a cave man walking & pteradactyl flying over and I wanted to play with the pixel shader )
Conan, I just tested the InfraredShader and it works perfectly... The problem with my previous explanation was to declare an InfraredShader object on the stack... When GameInit() leaves, the pointer is not valid anymore!

What I did is declare a member object:

class MyGame
{
...
private:
InfraredShader m_shader;
};

Then in GameInit(): GetDisplay()->SetPixelShader( &m_shader );

Try it and let me know!