0
\$\begingroup\$

I am currently working on the concept of a game, but I'm running into some problems.

For the game, I'd like to be able to directly change pixels on screen. However, all approaches that I tried so far resulted in my programs being rather slow, even without game mechanics attached to it.

Since a lot of games are also running on 60 fps with changing every pixel, you would expect it not to be hard to achieve such frame rates, if you could find the right way of changing pixels. The speed that I am aiming for is also at least 60 fps (if possible even on low-end hardware)

What is (or what library has) the fastest way to achieve this? It doesn't really matter what language the library is for, as long as I can get those high speeds.

\$\endgroup\$
  • 1
    \$\begingroup\$ What exactly have you tried? Are you using e.g. Windows GDI, OpenGL shaders, canvas rendering in browser...? You need to include that detail in your question. \$\endgroup\$ – Engineer Oct 20 '16 at 6:41
  • \$\begingroup\$ Lot's of things, especially in java, since that is the language I'm most familiair with. I've tried Things like using bufferedimage from the Java2D library (I even tried to abuse Libgdx's pixmaps). But java is very slow and I've been considering switchend to a faster language like c++ for now, but I'm not sure what libraries that has... \$\endgroup\$ – dragonfly Oct 20 '16 at 6:47
  • \$\begingroup\$ Please add to the question - what platform are you aiming, what type of hardware. \$\endgroup\$ – Kromster Oct 20 '16 at 7:16
  • \$\begingroup\$ @kromster I'd like imy program to work on most windows pc's, even without a GTX 1080 \$\endgroup\$ – dragonfly Oct 20 '16 at 7:42
2
\$\begingroup\$

Two general approaches come to mind:

  • You could use a legacy, software-based pixel pusher like SDL or Fastgraph, that allows you to easily push pixels on CPU without GPU concerns. This is likely not to be as fast as GPU, but if your goal is simply to make a game and avoid technicalities, this may work better for you. You'll need C / C++ for these options, however... not an easy road.

  • You could write individual texels / pixels to a viewport-sized texture in OpenGL, and render that to a screen-filling quad. Turn off bilinear filtering to ensure you get sharp pixels at 1:1 ratio. Since you mentioned you are using Java / LibGDX, you could then stick with them.

|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ As for the first approach, not using a present GPU seems like a wast of computing power. The second approach then seems more efficient. \$\endgroup\$ – dragonfly Oct 20 '16 at 7:44
  • \$\begingroup\$ I would definitely suggest staying with Java even if you have to climb some hills to get what you want in terms of performance. \$\endgroup\$ – Engineer Oct 20 '16 at 7:45
  • \$\begingroup\$ I'm already somewhat familiar with c++, so I may expend on that anyways, so having to switch to c++ is not really a concern to me. \$\endgroup\$ – dragonfly Oct 20 '16 at 7:47
  • \$\begingroup\$ I will after I've tried it today. Thanks in advance \$\endgroup\$ – dragonfly Oct 20 '16 at 8:08
  • \$\begingroup\$ If other people have things to add, they can then still comment/answer for a while \$\endgroup\$ – dragonfly Oct 20 '16 at 8:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.