[Kde-games-devel] Co-ordinates in QGraphicsView
Ian Wadham
iandw.au at gmail.com
Sun Jul 1 04:24:41 UTC 2012
On 01/07/2012, at 11:39 AM, Roney Gomes wrote:
> On Sat, Jun 30, 2012 at 10:06 PM, Ian Wadham <iandw.au at gmail.com> wrote:
>> So I find out what size the QGraphicsView is in pixels (e.g. 400x400) and I
>> divide by 10 to get the grid-square size and ask KGameRenderer to provide
>> me a pixmap item (actually KGameRenderedItem) of the right size (i.e. 40x40),
>> but now the pixmap gets scaled up when it is painted on the view and it is
>> horribly pixellated.
>
> I think it's here where you're failing. You don't have to ask for a
> new pixmap in terms of the view's dimensions, but in terms of the
> scene's dimensions instead.
If I recall correctly, I tried rendering to size (1, 1) and all I got was a
muddy-colored pixel which was then dutifully scaled up to size
(40x40) of nothing but mud. I also tried forcing the scale to be 1.0,
but that failed too. I seem to remember the size was right but the
picture quality was very poor.
> It doesn't matter whether the view is 400x400 large, the only things
> that matter, from the point of view of a top level QGraphicsItem, are
> the scene's dimensions. So, to make things easier in the games I've
> been working, I always make the scene's rectangle coincide with the
> view's geometry.
>
> Have you tried this approach?
Yes, and I see most other games do that, but I am not happy with it. That is why
I am asking. Maybe the other games work in pixel-based co-ordinates by
coincidence, because they pre-date Qt 4 and KDE 4. Maybe there is a better
way that you could use if you were writing a new KDE Game.
I'd like it to work more like OpenGL, where you can use any co-ordinates you like,
from inter-stellar down to sub-atomic and only the *projection* decides the final
picture (analogous to a scene-to-view transformation, but in 3D).
Cheers, Ian W.
More information about the kde-games-devel
mailing list