Newbie question on scaling images

First of all, I’d like to apologize in advance if I say something absurd or ask about things that may seem obvious. Although I have a long experience with Java programming, I am a total newbie in the field of graphics and OpenGL, and it seems that experience in other kinds of programming is relatively worthless in this field.

My JOGL project is a 2D game, so I have spent a few days going through some tutorials and documentation about the 2D parts of JOGL, but there is something I haven’t found, maybe because it’s too obvious, but I don’t quite get it.

I would like my game to run fine in screens with different resolutions. That seems quite easy to achieve at a first glance, because JOGL lets me set the coordinate system so that the northeast corner is, for example, (1600,1200) regardless of the actual resolution of the screen. If I draw primitives such as lines, dots, etc. in my coordinate system, everything is automatically scaled to fit the screen, but this doesn’t work with images. If I draw images with drawPixels(), they aren’t scaled at all.

This seems quite logical because, well, the method is called drawPixels() so it draws the pixels straight away. But isn’t there a way to draw an image so that it is scaled just like the other primitives? With that, my game’s sprites would scale and the game would be able to run in any resolution.

You should draw them as proper GL primatives, ie. textured quads. This will scale them just like lines and dots, and it generally quite a bit faster than glDrawPixels.

You have to be careful with lines and points though - although their coords will rescale, their size is always in pixels. Ie. a line is always a pixel wide, so as resolution increases it is proportionally smaller. Often you don’t want this, so instead consider drawing lines and points as textured quads too, so their thickness remains constant.

I didn’t think about taking a look at textures because I thought they were only used for 3D. But I have just tried them, and it works. Thank you very much :slight_smile: