Sign in to follow this  

PTK C++ game engine, how to draw one surface / image onto another and get new image

This topic is 3110 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I'm new to this forum and this site in general and I can't seem to find the info I'm looking for. It is possible that this topic was never raised. I'm not able to find in the PTK documentation the info about how to draw one graphic onto another and, as a result, get permanent change of the original image. I'm just testing the PTK lib to see if it suits my needs. Before when I used SDL, it enabled me to draw one surface onto another and as a result get a new surface. This is very important for the debris in the game. If I need to store location of debris graphic and redraw it every time it is supposed to appear on the screen, it would slow down whole game. But if the game level surface is altered permanently there is no need to store anything, the debris graphic is always visible on the game surface. There will be a lot of debris in the game. I was wondering if anyone with PTK experience can help me out, the PTK itself is very easy to use, make many things easy and until now I was very thrilled with it, but this lack of info is frustrating. I also mailed the question to the authors of the PTK, still no reply. Regards

Share this post


Link to post
Share on other sites
Hi,

I am no expert but if you want to draw one sprite on another, you need to have some transparency no ? otherwise you just get the last drawn.

If you have the position of what you want to draw why just not redraw it with your modifications ?

++

Share this post


Link to post
Share on other sites
Because it would slow down whole game ... I don't want to keep the positions of debris, several thousands of positions. Instead, I want to draw on level surface and forget about it.

Share this post


Link to post
Share on other sites
In PTK, currently, it is not possible to render from one KGraphic object to another. The beta version of PTK that you can get access to after you purchase does have this feature, but the beta version is not complete and has several issues, since it's moving to a DX9 backend instead of DX7.

Share this post


Link to post
Share on other sites
Hi,

Ok I got your point now, but why don't you render in a buffer first and then render to it before rendering to the screen ?

I should really stop talking because I don't know your engine but if it is based on openGL there must be a way to hack it somehow.

Share this post


Link to post
Share on other sites
If you look in the headers KWindowGL and KGraphicGL, you'll see that all the members of those classes are public - you can get the opengl context, the texture, the raw image data, etc... and work with that. Or, you can use makePictureFromArray to create an image from a pointer to data that you've loaded (or created) yourself.

Share this post


Link to post
Share on other sites
Oh, thanks, but do you use glDrawPixels in the implementation, not the header files, or you use OpenGL textures in OpenGL implementation, not DirectX of PTK?

Share this post


Link to post
Share on other sites
Couldn't tell you, honestly, as I've never had the need to do it. I'm sure you'd have to write separate methods for OpenGL and DirectX renderers... I just know that all the data is exposed, so you really can do whatever you want. Remember, too, if you purchase PTK, you get access to the code, so you really can do whatever you want.

Share this post


Link to post
Share on other sites
I understand what you're saying and thank you, but the author of the lib said that I could test before the decision. I'm not sure if the download file PTK20.zip is the full version, but I can't seem to find what you're saying and furthermore, I can't find collision detection and other features that I need.

Please, if you purchased it, could you look at the code and tell me what there is and how its working. This is something that I can't see from the header files, only cpp, which are not available. I'm interested to know if the implementation using OpenGL is using textures and not slow glDrawPixels. Also, I need fast collision detection algorithm present for sprites, easy sprite management, etc. I can't find any of those in documentation or header files.

Thanks.

Share this post


Link to post
Share on other sites
Hah, I thought I had responded to that textures/pixels questions earlier, but I think I had started writing on my iPod, and then decided to type the answer at the computer instead, and forgot to add that part. PTK uses textures internally. You can see ALL the data in the headers if you look, for example, at KGraphicGL.h.

I think you're not understanding what PTK is. It's a 2d drawing engine that uses opengl/d3d for drawing, and has sound and input libraries and a few other bits and pieces to help deal with cross platform support for OS X and Windows. It's NOT a comprehensive game engine. It doesn't manage your sprites, it doesn't do collision detection. It doesn't keep track of your world or your levels. It works great for my needs, but it doesn't sound like it fits yours.

Share this post


Link to post
Share on other sites

This topic is 3110 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this