Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / "Manually" drawing all the way / Avoiding Sync()

Author
Message
CaesiumPP
9
Years of Service
User Offline
Joined: 14th Mar 2015
Location:
Posted: 14th Mar 2015 14:54
Hey guys,

I recently bought AGK2 for use in C++ instead of SFML/SDL.

For different reasons (especially because this way it's easier to work with game states IMO) I prefer to draw everything manually rather than change the visibility of sprites.
Therefore I stripped down the Sync()/i] function into its parts. For sprite drawing this works. But as I read in the documentation of the Sync() function, the text labels drawn with [i]Print() don't get drawn without Sync().
Is there a way to avoid automatic sprite drawing without any losses like with Print().

Thanks in advance.
Greetings
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 14th Mar 2015 20:09
u can combine
SetSpritePosition / SetSpritePositionByOffset
SetSpriteImage ( iSpriteIndex, iImageIndex, bUpdateShape )
DrawSprite

so there is only one sprite but u draw self where and what.

instead of sync() is
Update()
Render()
Swap()
i guess all u need, this update and render can also split into other calls.

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
CaesiumPP
9
Years of Service
User Offline
Joined: 14th Mar 2015
Location:
Posted: 14th Mar 2015 22:05
Hey Markus,

thanks for trying to help, but I guess you misunderstood what I meant.

For example:

If I create a sprite it's automatically drawn when Sync() is called in the main loop.
The obvious reason for this is that Sync() draws every existing sprite currently being set to visible. To be more specific: Sync() calls - among others - Render2DFront(), which is responsible for drawing all "visible" sprites, text etc. automatically.

In case I want to draw a sprite "manually" I have to strip down Sync() into its parts.

Here is an example to visualize what I'm talking about:



This way it only draws the sprites I "manually" draw to the backbuffer - as far as they are visible ofc.

Problem is: It does not draw stuff like Print() Labels anymore. Therefore I'd have to add Render2DFront() into the render sequence, which would make my DrawSprite() completely useless as it would draw all sprites automatically anyway through calling Render2DFront() (like mentioned above).

Is there some way to draw all of my stuff manually and still don't have to work with drawing-losses like the text drawn with Print()? Like splitting up Render2DFront() even further for example. Also I don't know if there's other stuff which is not being drawn if I do this manually. Maybe it's only the Print-Labels.. maybe it's other stuff too, I haven't tried to be honest.

Thanks for any help.
Greetings
Greenwich
9
Years of Service
User Offline
Joined: 10th Dec 2014
Location:
Posted: 15th Mar 2015 00:39
Are you using Print() in a way that can't be converted to CreateText() statements?

It's mean time. *averages*
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 15th Mar 2015 01:00
i think drawsprite paint in backbuffer (if visible flag is set) and
if u do not want the using sprite brush appear automatic just hide it before the render call.

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
CaesiumPP
9
Years of Service
User Offline
Joined: 14th Mar 2015
Location:
Posted: 15th Mar 2015 01:33
@Greenwich
I guess not. Still I'm not quite sure Print() would be the only function affected.

@Markus
Thanks mate! That did it.
Tried it like this and it may look a little bit confusing and overcomplicated at first, but IMO it's still easier to manage this way.

Here is an example of how it works now...

Login to post a reply

Server time is: 2024-11-25 18:41:45
Your offset time is: 2024-11-25 18:41:45