Skip to content

Commit

Permalink
Merge pull request #54 from eandr127/master
Browse files Browse the repository at this point in the history
Allow for large width in monitors
  • Loading branch information
ryanlarkin committed Apr 27, 2015
2 parents 4582a82 + 342e1f5 commit 7d26786
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Luminescent/src/astechzgo/luminescent/rendering/Room.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public class Room extends RenderableQuadrilateralGameObject {
public Room() {
super(

DisplayUtils.SCREEN_WIDTH / 45,
(DisplayUtils.SCREEN_WIDTH - DisplayUtils.WIDTH_OFFSET * 2) / 45 + DisplayUtils.WIDTH_OFFSET,
(DisplayUtils.SCREEN_HEIGHT - DisplayUtils.HEIGHT_OFFSET * 2) / 25 + DisplayUtils.HEIGHT_OFFSET,
DisplayUtils.SCREEN_WIDTH - (DisplayUtils.SCREEN_WIDTH / 45 * 2),
(DisplayUtils.SCREEN_WIDTH - DisplayUtils.WIDTH_OFFSET * 2) - ((DisplayUtils.SCREEN_WIDTH - DisplayUtils.WIDTH_OFFSET ) / 45 * 2),
(DisplayUtils.SCREEN_HEIGHT - DisplayUtils.HEIGHT_OFFSET * 2) - ((DisplayUtils.SCREEN_HEIGHT - DisplayUtils.HEIGHT_OFFSET )/ 25 * 2)

);
Expand Down
16 changes: 8 additions & 8 deletions Luminescent/src/astechzgo/luminescent/rendering/RoomWalls.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

public class RoomWalls extends RenderableMultipleRenderedObjects {

private static int posX = DisplayUtils.SCREEN_WIDTH / 45;
private static int posX = (DisplayUtils.SCREEN_WIDTH - DisplayUtils.WIDTH_OFFSET * 2) / 45 + DisplayUtils.WIDTH_OFFSET;
private static int posY = (DisplayUtils.SCREEN_HEIGHT - DisplayUtils.HEIGHT_OFFSET * 2) / 25 + DisplayUtils.HEIGHT_OFFSET;

private static int width = DisplayUtils.SCREEN_WIDTH - (DisplayUtils.SCREEN_WIDTH / 45 * 2);
private static int width = (DisplayUtils.SCREEN_WIDTH - DisplayUtils.WIDTH_OFFSET * 2) - ((DisplayUtils.SCREEN_WIDTH - DisplayUtils.WIDTH_OFFSET ) / 45 * 2);
private static int height = (DisplayUtils.SCREEN_HEIGHT - DisplayUtils.HEIGHT_OFFSET * 2) - ((DisplayUtils.SCREEN_HEIGHT - DisplayUtils.HEIGHT_OFFSET )/ 25 * 2);

public RoomWalls() {
Expand All @@ -32,33 +32,33 @@ public void render() {

private static List<IRenderedObject> getRoomObjects() {
RenderableQuadrilateralGameObject wall1 = new RenderableQuadrilateralGameObject(
0,
DisplayUtils.WIDTH_OFFSET,
DisplayUtils.HEIGHT_OFFSET,
posX,
DisplayUtils.SCREEN_HEIGHT - DisplayUtils.HEIGHT_OFFSET * 2
);
wall1.setColour(new Color(0.0f, 0.4f, 0.6f));

RenderableQuadrilateralGameObject wall2 = new RenderableQuadrilateralGameObject(
0,
DisplayUtils.WIDTH_OFFSET,
DisplayUtils.HEIGHT_OFFSET,
DisplayUtils.SCREEN_WIDTH,
DisplayUtils.SCREEN_WIDTH - DisplayUtils.WIDTH_OFFSET * 2,
posY - DisplayUtils.HEIGHT_OFFSET
);
wall2.setColour(new Color(0.0f, 0.4f, 0.6f));

RenderableQuadrilateralGameObject wall3 = new RenderableQuadrilateralGameObject(
width + posX,
DisplayUtils.HEIGHT_OFFSET,
DisplayUtils.SCREEN_WIDTH - (width + posX),
DisplayUtils.SCREEN_WIDTH - DisplayUtils.WIDTH_OFFSET - (width + posX),
DisplayUtils.SCREEN_HEIGHT - DisplayUtils.HEIGHT_OFFSET * 2
);
wall3.setColour(new Color(0.0f, 0.4f, 0.6f));

RenderableQuadrilateralGameObject wall4 = new RenderableQuadrilateralGameObject(
0,
DisplayUtils.WIDTH_OFFSET,
height + posY,
DisplayUtils.SCREEN_WIDTH,
DisplayUtils.SCREEN_WIDTH - DisplayUtils.WIDTH_OFFSET * 2,
DisplayUtils.SCREEN_HEIGHT - DisplayUtils.HEIGHT_OFFSET - (height + posY)
);
wall4.setColour(new Color(0.0f, 0.4f, 0.6f));
Expand Down
15 changes: 8 additions & 7 deletions Luminescent/src/astechzgo/luminescent/utils/DisplayUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public class DisplayUtils {
public static final int SCREEN_WIDTH = Display.getDisplayMode().getWidth();
public static final int SCREEN_HEIGHT = Display.getDisplayMode().getHeight();

public static final int HEIGHT_OFFSET = (SCREEN_HEIGHT - (SCREEN_WIDTH / 16 * 9)) / 2;
public static final int WIDTH_OFFSET = Math.max(0, (SCREEN_WIDTH - (SCREEN_HEIGHT / 9 * 16)) / 2);
public static final int HEIGHT_OFFSET = Math.max(0, (SCREEN_HEIGHT - (SCREEN_WIDTH / 16 * 9)) / 2);

/**
* Set the display mode to be used
Expand Down Expand Up @@ -124,20 +125,20 @@ public static void takeScreenshot(File file) throws LWJGLException {
int width = Display.getDisplayMode().getWidth();
int height= Display.getDisplayMode().getHeight();
int bpp = Display.getDisplayMode().getBitsPerPixel() / 8;
ByteBuffer buffer = BufferUtils.createByteBuffer(width * (height - DisplayUtils.HEIGHT_OFFSET) * bpp);
GL11.glReadPixels(0, DisplayUtils.HEIGHT_OFFSET, width, height - DisplayUtils.HEIGHT_OFFSET, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer);
ByteBuffer buffer = BufferUtils.createByteBuffer((width - DisplayUtils.WIDTH_OFFSET) * (height - DisplayUtils.HEIGHT_OFFSET) * bpp);
GL11.glReadPixels(DisplayUtils.WIDTH_OFFSET, DisplayUtils.HEIGHT_OFFSET, width - DisplayUtils.WIDTH_OFFSET, height - DisplayUtils.HEIGHT_OFFSET, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer);
String format = "png";
BufferedImage image = new BufferedImage(width, height - DisplayUtils.HEIGHT_OFFSET * 2, BufferedImage.TYPE_INT_RGB);
BufferedImage image = new BufferedImage(width - DisplayUtils.WIDTH_OFFSET * 2, height - DisplayUtils.HEIGHT_OFFSET * 2, BufferedImage.TYPE_INT_RGB);

for(int x = 0; x < width; x++)
for(int x = 0; x < width - DisplayUtils.WIDTH_OFFSET * 2; x++)
{
for(int y = 0; y < height - DisplayUtils.HEIGHT_OFFSET * 2; y++)
{
int i = (x + (width * y)) * bpp;
int i = (x + ((width - DisplayUtils.WIDTH_OFFSET) * y)) * bpp;
int r = buffer.get(i) & 0xFF;
int g = buffer.get(i + 1) & 0xFF;
int b = buffer.get(i + 2) & 0xFF;
image.setRGB(x, height - DisplayUtils.HEIGHT_OFFSET * 2 - (y + 1), (0xFF << 24) | (r << 16) | (g << 8) | b);
image.setRGB(width - DisplayUtils.WIDTH_OFFSET * 2 - (x + 1), height - DisplayUtils.HEIGHT_OFFSET * 2 - (y + 1), (0xFF << 24) | (r << 16) | (g << 8) | b);
}
}

Expand Down

0 comments on commit 7d26786

Please sign in to comment.