Take the 2-minute tour ×

I already have my game loading up at the correct dimensions, displaying a background and playing some background music, this is supposed to be a log-in screen, I've never messed with graphics before, although I know how to write most of the server/client communication so that won't be a problem.

How do I draw multiple images, and how do I put them where I want them?

More importantly, does OpenGL support the "Transparent" feature of PNG Images? Because that's how I developed my start screen by having a semi-transparent login box, semi-transparent buttons, etc.

I'm aware of how to load the images, although drawing them is a different story..

public void drawStartScreen() {
        c.getAssets().backgroundImage.bind(); // or GL11.glBind(c.getAssets().backgroundImage.getTextureID());
        GL11.glTexCoord2f(0, 0);
        GL11.glVertex2f(0, 0);
        GL11.glTexCoord2f(1, 0);
        GL11.glVertex2f(c.getAssets().backgroundImage.getTextureWidth(), 0);
        GL11.glTexCoord2f(1, 1);
        GL11.glTexCoord2f(0, 1);
        GL11.glVertex2f(0, c.getAssets().backgroundImage.getTextureHeight());

        if(playMusic == true) {
            c.getAssets().backgroundMusic.playAsMusic(1.0f, 1.0f, true);

I can't figure out how to move the image around using the above code, so I can't write my own method to "Fill in" the above code with "Parameters".

I'm trying to get my secondary image to draw to the middle of the client, I know people may look down on me for this although this is a slight example of what I'm talking about and where some of my experience in programming comes from what creating server-based emulators for Runescape for many years, so below I will leave an image showing the "LoginBox" ontop of the Background.. the buttons are transparent with a black edge, which allows you to see the loginbox beneath it, besides for where the black border was drawn.

This is what I meant by "Transparent" support:


share|improve this question

1 Answer 1

up vote 1 down vote accepted


If you followed one of the many bad tutorials scattered around the internet, you're prbably doing it wrong. OpenGL is a state machine, which means you can change whatever you want right when you need it.

Most tutorials put glViewport and projection matrix setup in the window resize handler. This works if you display just a scene without further elements. But in cases like yours this setup is rather inconvenient.

Just do the simple thing: You can change the viewport and projection to whatever suits your needs best, when you need it. You want to draw an image centered on the screen? Just set the viewport and projection as you need it:

glViewport(0, 0, win_width, win_height);
aspect = win_width/win_height;
projection_ortho(-aspect, aspect, -1, 1);


Yes, it's called blending.

share|improve this answer
Could you perhaps link me to a tutorial that shows how to use OpenGL Correctly then, because everything is showing a different method that gets more and more confusing each time, also, I can't find anything in OpenGL for projection_ortho, is that a custom void I'll have to make? There is however a GL_ProjectionMatrix –  Christian Tucker Feb 21 '13 at 23:43
@ChristianTucker: It was just a shorthand for several lines of orthographic projection setup. However you asking these questions clearly indicates you need to step back a bit and get your OpenGL basics done. First and foremost: Forget about the fixed function pipeline. It's outdated and every GPU built since 2004 is programmable through shaders. As a tutorial I recommend Nicol Bolas' arcsynthesis.org/gltut – follow it through and you've got a solid understanding of what to do. –  datenwolf Feb 22 '13 at 0:11
Thanks for that, yeah as I was saying I had no previous experience with graphics and the tutorials online are seriously sending me all over the place. –  Christian Tucker Feb 22 '13 at 0:19
@ChristianTucker: I can only praise Nicol Bolas' work in the highest tones. Not only is it a really well written work that gets to the point. It also gives usefull background information about why things are, how they are. They are IMHO by far the best OpenGL tutorials you can find right now. –  datenwolf Feb 22 '13 at 0:56

Your Answer


