Draw on texture in realtime

What is the current best option to draw on a JME texture in realtime? I have found some tools like AWTLoader plugin and ImagePainter, but all articles on them are a bit dated. So what is the todays recommended way?

Also, if it is ImagePainter, then where do I get the standalone jar? I do not use the SDK so the plugin form of it won’t work for me… I know that maybe I could install the SDK, download the plugin with it, search for the jar somewhere and try using it… but maybe there is a better option?

Update: when I say “draw” I do not mean changing individual pixels, which I know how to do. I mean something like a more high-level drawing stuff, where I can draw rectangles and circles and lines and that kind of things…

One more update: found the ImagePainter jar

ImagePainter

Ok, I am successfully using ImagePainter in my project now, however, there is a surprise! ImagePainter is not as versatile as I thought, for example, it does not draw circles or ovals… I expected at least functionality of MSPaint, which is rather ascetic, but still, it is not available… What is the best way to go about it? Should I just extend the class and enrich it or is there an existing solution to that?

@noncom said: Ok, I am successfully using ImagePainter in my project now, however, there is a surprise! ImagePainter is not as versatile as I thought, for example, it does not draw circles or ovals.. I expected at least functionality of MSPaint, which is rather ascetic, but still, it is not available.. What is the best way to go about it? Should I just extend the class and enrich it or is there an existing solution to that?

You can always create whatever routines you want that use ImagePainter to poke pixels wherever you want using whatever algorithm you want. Or even just go to ImageRaster directly.

Alternately, if you want the functionality of Java2D then you can use Java2D and constantly copy the image over. It will be less performant, though (obviously)… and it won’t run on things like Android.

@pspeed said: You can always create whatever routines you want that use ImagePainter to poke pixels wherever you want using whatever algorithm you want. Or even just go to ImageRaster directly.

Haha, man, yeah :D… I was just hoping for some ready thing…

@pspeed said: Alternately, if you want the functionality of Java2D then you can use Java2D and constantly copy the image over. It will be less performant, though (obviously)... and it won't run on things like Android.

Oh, I’ve been there… yes performance is not too good… 1920x1080 texture overwhelms my PC.

Maybe I have to explore shaders then… what about a shader-based painter with the basic functinality of MSPaint, which draws things according to instructions feed into it… Although it will definitely take time to implement, I see this as a only real solution…

sorry for mentioning you twice, btw :oops:

@noncom said: Haha, man, yeah :D.. I was just hoping for some ready thing..

Oh, I’ve been there… yes performance is not too good… 1920x1080 texture overwhelms my PC.

Maybe I have to explore shaders then… what about a shader-based painter with the basic functinality of MSPaint, which draws things according to instructions feed into it… Although it will definitely take time to implement, I see this as a only real solution…

I don’t understand how you would feed the instructions in other than to draw the geometry using meshes… which seems like not what you want and you are still left with all the same problems anyway.

Really, writing these routines to hit ImageRaster is not hard. Certainly easier than trying to shoehorn a 2D drawing API on top of a 3D rendering pipeline. Rendering a circle as points is really easy.

What is it that you are ultimately trying to achieve? Updating a full screen texture every frame in this way is not going to be particularly speedy no matter what you do.

A dumb routine to draw a circle with ImageRaster/ImagePainter is rather simple to implement. If you want to render a good looking circle you will have to implement some kind of antialiasing yourself though…

Yes… well, I wanted to be able to draw simple things nothing fancy. I thought that I can send the drawing program to the shader, where a little VM could read it and draw accordingly.

ImageRaster is all ok, except for the speed. It satisfies most of my current needs and I am likely to simply implement the primitive routines to it, via extending ImagePainter, however, in the long run I would like to know if I have better options.

I do not want to render as geometries since I need a simple destructive 2D rendering. By “destructive” I mean that pixels simply get overwritten. Without any worries on objects or stuff.

Actually, if I could, I’d use Processing for that, since it suits the best. However, making it play together with JME does not look simple… Normen mentioned a work on this by someone, but IIRC it is long dead. I do not think that there would be serious speed problems if not abused, rather I think that OpenGL stuff about context and such would be against such a blend…

I am trying to get some easy way on a Processing-like drawing abilities for textures in JME. I know that JME is a 3D engine and all the stuff… technically, yes, everything is correct - do 2D in 2D tools and do 3D in 3D tools, but really, this limitation is artificial, comes from technical limitations and should not be considered ultimate or even ideological. My usecase is generative graphics which can use both 3D and 2D techniques.