Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void draw2D(float x, float y, float w, float h, Texture t){
- glColor3f(1,1,1);
- t.bind();
- glBegin(GL_QUADS);
- glTexCoord2f(0,1); glVertex2f(x,y);
- glTexCoord2f(0,0); glVertex2f(x,y+h);
- glTexCoord2f(1,0); glVertex2f(x+w,y+h);
- glTexCoord2f(1,1); glVertex2f(x+w,y);
- glEnd();
- }
- //The actual method that sets up and draws the 2d images
- private void draw2D(){
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0, Display.getWidth(), 0, Display.getHeight(), 1, -1);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef(Display.getWidth() / 2, Display.getHeight() / 2, 0.0f);
- glDisable(GL_DEPTH_TEST);
- //Textures[4] is 400x300. Tested with other 400x300 images
- Static.draw2D(0, -300, 400, 300, textures.get(4));
- //Screen is 800x600 so it should draw from the centre down and right
- //It does but it draws a 314x176 image for some reason
- // back to 3D stuff
- glEnable(GL_DEPTH_TEST);
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
- }
Advertisement
Add Comment
Please, Sign In to add comment