Hallo Leute,
Ich hab ein kleines Problem und zwar wenn ich das Fenster meiner Anwendung resize also die Größe ändert verziehen sich die ganzen Quadrate.
Im Grund will ich eigentlich nur ein Schachspiel machen.
Ich zeichne das ganze so:
drawQuad:
Die Ausgabe original lautet:
Änder ich jetzt aber die Breite bleiben alle Werte gleich außer die Breite trotzdem ist das ganze Bild verzogen (siehe Screenshot).
Ich hab ein kleines Problem und zwar wenn ich das Fenster meiner Anwendung resize also die Größe ändert verziehen sich die ganzen Quadrate.
Im Grund will ich eigentlich nur ein Schachspiel machen.
Ich zeichne das ganze so:
Java-Quellcode
- boolean changed = false;
- if(displayWidth != Display.getWidth() || displayHeight != Display.getHeight())
- {
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1);
- glMatrixMode(GL_MODELVIEW);
- displayWidth = Display.getWidth();
- displayHeight = Display.getHeight();
- System.out.println("===========================");
- System.out.println("Display size was changed!");
- System.out.println("Width: " + Display.getWidth());
- System.out.println("Height: " + Display.getHeight());
- if(displayWidth / 8 < displayHeight / 8 || displayWidth / 8 == displayHeight / 8)
- {
- blockSize = displayWidth / 8;
- } if (displayWidth / 8 > displayHeight / 8) {
- blockSize = displayHeight / 8;
- }
- System.out.println("Blocksize: " + blockSize);
- changed = true;
- }
- glClear(GL_COLOR_BUFFER_BIT);
- glClearColor(.5f, .5f, .5f, 1);
- glBegin(GL_QUADS);
- int id = 0;
- for(int y = 0; y < blockSize * 8; y += blockSize)
- {
- for(int x = 0; x < blockSize * 8; x += blockSize)
- {
- if(changed)
- {
- System.out.println("Draw block at " + x + ", " + y);
- }
- id++;
- boolean light = id % 2 != 0;
- drawQuad(light ? .9f : 0, light ? .9f : 0, light ? .9f : 0, x, y, blockSize, blockSize);
- }
- id++;
- }
- glEnd();
drawQuad:
Die Ausgabe original lautet:
Quellcode
- ===========================
- Display size was changed!
- Width: 800
- Height: 800
- Blocksize: 100
- Draw block at 0, 0
- Draw block at 100, 0
- Draw block at 200, 0
- Draw block at 300, 0
- Draw block at 400, 0
- Draw block at 500, 0
- Draw block at 600, 0
- Draw block at 700, 0
- Draw block at 0, 100
- Draw block at 100, 100
- Draw block at 200, 100
- Draw block at 300, 100
- Draw block at 400, 100
- Draw block at 500, 100
- Draw block at 600, 100
- Draw block at 700, 100
- Draw block at 0, 200
- Draw block at 100, 200
- Draw block at 200, 200
- Draw block at 300, 200
- Draw block at 400, 200
- Draw block at 500, 200
- Draw block at 600, 200
- Draw block at 700, 200
- Draw block at 0, 300
- Draw block at 100, 300
- Draw block at 200, 300
- Draw block at 300, 300
- Draw block at 400, 300
- Draw block at 500, 300
- Draw block at 600, 300
- Draw block at 700, 300
- Draw block at 0, 400
- Draw block at 100, 400
- Draw block at 200, 400
- Draw block at 300, 400
- Draw block at 400, 400
- Draw block at 500, 400
- Draw block at 600, 400
- Draw block at 700, 400
- Draw block at 0, 500
- Draw block at 100, 500
- Draw block at 200, 500
- Draw block at 300, 500
- Draw block at 400, 500
- Draw block at 500, 500
- Draw block at 600, 500
- Draw block at 700, 500
- Draw block at 0, 600
- Draw block at 100, 600
- Draw block at 200, 600
- Draw block at 300, 600
- Draw block at 400, 600
- Draw block at 500, 600
- Draw block at 600, 600
- Draw block at 700, 600
- Draw block at 0, 700
- Draw block at 100, 700
- Draw block at 200, 700
- Draw block at 300, 700
- Draw block at 400, 700
- Draw block at 500, 700
- Draw block at 600, 700
- Draw block at 700, 700
Änder ich jetzt aber die Breite bleiben alle Werte gleich außer die Breite trotzdem ist das ganze Bild verzogen (siehe Screenshot).