Rendering pixel data from array in lwjgl

Hello people!

I’m making a 2d tilebased game that i have just ported to lwjgl. I’m now trying to implement a map & minimap into the game.

How i did it before i ported(pure java software rendering):
Each tile had an assigned rgb value which was then stored in an array and rendered out pixel by pixel(when the map or minimap was showing).

My question is:
How do i achieve an effect like this in lwjgl(+slickutil)?
I thought of rendering every single rgb value of the map as a coloured rectangle, but I imagine that would not be very effective.

Any help will be greatly appreciated!

Textures. You have an array of rgb values, also called an image. So you can wrap up the image in an OpenGL texture and render that. You can update individual pixels in the texture with glTexSubImage2D(): http://www.opengl.org/sdk/docs/man2/xhtml/glTexSubImage2D.xml.

Depending on how much this minimap is being updated, you might get more performance out of using glDrawPixels(): http://www.opengl.org/sdk/docs/man2/xhtml/glDrawPixels.xml to render those pixels directly. But I would always go with the texture option just for ease of use and simplicity.

Thank you for the answer. This might be kind of a stupid question, but how would this be done?

You have a ByteBuffer that contains the RGBA/R8G8B8A8 pixels of your image, and upload that (whenever it changes, and only when it changes) with glTexSubImage2D(…) to the GPU.