[Bf-committers] BGE: Can we have a centralized call KX_KetsjiEngine::OnResize() (please :)

Dalai Felinto dfelinto at gmail.com
Thu Feb 5 01:47:23 CET 2009

Hi Benoit.

When I launch BGE I'm storing the current viewport and use it's width
and height values to calculate the render size. So far so good.
What I need now it's to check if the viewport didn't change, and if it
did, I update it before the render routine.

It wouldn't be hard (at all) to implement it locally in the dome code.
However I would like to avoid having duplicated code to handle this. I
remembered when I was playing with the 2dfilter code/texcoord, that we
have a function that performs exactly that. Back then I was missing a
central 'method' where resizing functions could be placed.

It's not extremely necessary, it's not a boost in performance, but it
doesn't hurt, and it may make the code clear avoiding duplicate
functions doing exactly the same thing (it's my personal opinion).

For example originally I reported this bug:
Because I thought need_tex_update should be set true only when the
canvas is resized (I still think, but I'm waiting Hamed to finish his
thesis before I bog him more about the 2dfilter system).

So we have a way to initialize class such as the videoTexture (and the
Dome/fisheye) in the KetsjiEmbed.cpp, a way to handle its end in the
~KX_KetsjiEngine, and I would like to have a way to call their
internal onResize() methods (in my case updating the m_viewport and
the m_imagesize) when the BGE is resized.

> Can you elaborate a bit on what would KX_KetsjiEngine::OnResize() do and
> how it would be called?

   shadow_buffers->resize_the _glImage(); //just an example


2009/2/4 Benoit Bolsee <benoit.bolsee at online.be>:
> On Tue, 3 Feb 2009 21:07:39 -0500 Dalai Felinto <dfelinto at gmail.com>
> wrote:
>> A lot of times I see the need of checking for viewport size
>> changes during BGE code. For example in
>> RAS_2DFilterManager.cpp and in the *wip* Fisheye code. But
>> I'm pretty sure it happens in all functions that rely on the
>> size of the viewport for render purposes.
>> I know that checking viewport size changes and getting
>> power-of-2 texture sizes related to that are fast. However I
>> think it would be better (easier to code/maintain) if we
>> could centralize it all in a KX_KetsjiEngine::OnResize() (or
>> any other name).
> Can you elaborate a bit on what would KX_KetsjiEngine::OnResize() do and
> how it would be called?
> If you just want a handy function to compute the largest power-of-2
> texture size that fits the viewport, there is a fast algorithm in
> VideoTexture (look for calcSize()).
> I would of course have no problem to port that code to a centralized
> function.
>> Does anyone agree/have a problem with that? There is any
>> reason (historical, maybe?) to not have it? Do we already
>> have something like that (i couldn't find it)?
>> Cheers,
>> Dalai
>> http://blenderecia.orgfree.com
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers

More information about the Bf-committers mailing list