Jump to content
  • Advertisement
Sign in to follow this  
ThoriumLabs

C++/Java - Libraries/Methods for rendering pixels without hardware acceleration

This topic is 1511 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

Hey guys! My name is Thomas from Thorium Labs, and I have a question for you all.

 

I'm planning on making a game based on pixel art. I want to simulate it with real-size pixels. I'm trying to create an engine that will allow me to update the pixels quickly and efficiently. If a boss comes along, I update the pixels. If the scene changes, I update the pixels.

 

Do any of you people know efficient methods (or libraries) for making a "pixel canvas" like this in Java or C++?

 

Thanks,

Thomas

Share this post


Link to post
Share on other sites
Advertisement

I'm trying to create an engine that will allow me to update the pixels quickly and efficiently.

That's the reason GPU APIs exist.

 


Do any of you people know efficient methods (or libraries) for making a "pixel canvas" like this in Java or C++?

Yup. Don't update pixel per pixel. It won't work, you'll become extremely CPU bound in a reasonable resolution.

 

If you still want to stay away from regular GPU APIs, you could use Swing/Java2D, and draw BufferedImages. BufferedImages allow you to edit pixels if you want.

 

Again, updating pixel per pixel will be extremely slow. So I dunno how far you can get with that. Java2D provides methods to write images quickly, which will be much more efficient than just grabbing the matrix of data and updating stuff on your own.

 

EDIT: Then again, I'd just grab LibGDX if I were you.

Edited by TheChubu

Share this post


Link to post
Share on other sites

As TheChubu says, manual pixel updating is almost certainly not what you want. You can achieve the same effects with modern-day GPUs and creating modeling and shaders.

 

On the flipside, I've done this kind of thing for fun - cause I was writing my own triangle rasterizer. It ran horribly slow compared to just using the GPU, but that wasn't the point. In my case, I basically just had a block of memory representing the "screen" (at about 320x200 resolution) and set the colors manually. Then upload the whole thing to the GPU as a texture for a quad that covered the entire screen.

 

I could also see someone doing something like rendering each "pixel" as a quad with a single color texture. Though even in that case you're probably better off looking into voxel-style techniques where your objects are groups of quads or boxes instead of trying to have a static group of quads/boxes representing the screen and changing their color.

Share this post


Link to post
Share on other sites

Could I update bufferedimage at 60 frames per second? Right now I'm using a bunch of quads at full HD, and it's blistering slow, I can only imagine the speeds on consoles. I could scale them up to retain manageablility. At full resolution on a full HD monitor (1920 x 1080), that's 2073600 quads, or "pixels" at one time. That's crazy great and all, but could I load that many quads and update them individually? Is is a better idea to use libraries on C++ for this?

 

Also, would I be better off using LWJGL and using sprites as buildings and characters, moving them on a pixel grid? Is that possible?

 

Thanks,

Thomas

Share this post


Link to post
Share on other sites

Could I update bufferedimage at 60 frames per second?
Pixel by pixel? No. I doubt it. I specifically mentioned the drawImage method because it draws an entire image (ie, a sprite) at once. Which is what you would want to do to achieve playable framerate.

 


Could I update bufferedimage at 60 frames per second? Right now I'm using a bunch of quads at full HD, and it's blistering slow, I can only imagine the speeds on consoles
Yeah, you can only imagine the speeds on consoles because there is no Java in consoles. Don't use fullscreen quads to draw each sprite. Quad should be as tiny as possible, ie, it should tightly bound the sprite you're drawing.

 

Also, would I be better off using LWJGL and using sprites as buildings and characters, moving them on a pixel grid? Is that possible?
Yes, definitively. Again, see what libGDX can offer. Its a framework, not an engine, and it uses OpenGL as the backend, you can target various platforms with it too (desktop, Android, iOS).

 

Have you done a 2D game the "regular" way before? Try first what you can do with sprites. Then you can decide if you actually need what you're suggesting.

 

I could also see someone doing something like rendering each "pixel" as a quad with a single color texture.
Terribly slow too. Unless you can somehow batch it very, very efficiently (and even then I doubt it would run faster), you're looking at possibly hundred of thousands of draw calls per frame.

Share this post


Link to post
Share on other sites

Wow! Thanks! Around this point, I think I'll just try and make sprites dynamic. I really want that control over it, but I may be able to pull this out without the user telling a difference.

Share this post


Link to post
Share on other sites

I could also see someone doing something like rendering each "pixel" as a quad with a single color texture.

Terribly slow too. Unless you can somehow batch it very, very efficiently (and even then I doubt it would run faster), you're looking at possibly hundred of thousands of draw calls per frame.


This is why I don't do graphics tongue.png

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!