Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2021 jMonkeyEngine
* Copyright (c) 2009-2023 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -37,10 +37,13 @@
import android.content.DialogInterface;
import android.content.pm.ConfigurationInfo;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.opengl.GLSurfaceView;
import android.os.Build;
import android.text.InputType;
import android.view.Gravity;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.EditText;
Expand Down Expand Up @@ -484,4 +487,61 @@ public com.jme3.opencl.Context getOpenCLContext() {
logger.warning("OpenCL is not yet supported on android");
return null;
}

/**
* Returns the height of the input surface.
*
* @return the height (in pixels)
*/
@Override
public int getFramebufferHeight() {
Rect rect = getSurfaceFrame();
int result = rect.height();
return result;
}

/**
* Returns the width of the input surface.
*
* @return the width (in pixels)
*/
@Override
public int getFramebufferWidth() {
Rect rect = getSurfaceFrame();
int result = rect.width();
return result;
}

/**
* Returns the screen X coordinate of the left edge of the content area.
*
* @throws UnsupportedOperationException
*/
@Override
public int getWindowXPosition() {
throw new UnsupportedOperationException("not implemented yet");
}

/**
* Returns the screen Y coordinate of the top edge of the content area.
*
* @throws UnsupportedOperationException
*/
@Override
public int getWindowYPosition() {
throw new UnsupportedOperationException("not implemented yet");
}

/**
* Retrieves the dimensions of the input surface. Note: do not modify the
* returned object.
*
* @return the dimensions (in pixels, left and top are 0)
*/
private Rect getSurfaceFrame() {
SurfaceView view = (SurfaceView) androidInput.getView();
SurfaceHolder holder = view.getHolder();
Rect result = holder.getSurfaceFrame();
return result;
}
}
33 changes: 32 additions & 1 deletion jme3-core/src/main/java/com/jme3/system/JmeContext.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2021 jMonkeyEngine
* Copyright (c) 2009-2023 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -187,4 +187,35 @@ public enum Type {
*/
public void destroy(boolean waitFor);

/**
* Returns the height of the framebuffer.
*
* @return the height (in pixels)
* @throws IllegalStateException for a headless or null context
*/
public int getFramebufferHeight();

/**
* Returns the width of the framebuffer.
*
* @return the width (in pixels)
* @throws IllegalStateException for a headless or null context
*/
public int getFramebufferWidth();

/**
* Returns the screen X coordinate of the left edge of the content area.
*
* @return the screen X coordinate
* @throws IllegalStateException for a headless or null context
*/
public int getWindowXPosition();

/**
* Returns the screen Y coordinate of the top edge of the content area.
*
* @return the screen Y coordinate
* @throws IllegalStateException for a headless or null context
*/
public int getWindowYPosition();
}
42 changes: 41 additions & 1 deletion jme3-core/src/main/java/com/jme3/system/NullContext.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2020 jMonkeyEngine
* Copyright (c) 2009-2023 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -256,4 +256,44 @@ public boolean isRenderable() {
public Context getOpenCLContext() {
return null;
}

/**
* Returns the height of the framebuffer.
*
* @throws UnsupportedOperationException
*/
@Override
public int getFramebufferHeight() {
throw new UnsupportedOperationException("null context");
}

/**
* Returns the width of the framebuffer.
*
* @throws UnsupportedOperationException
*/
@Override
public int getFramebufferWidth() {
throw new UnsupportedOperationException("null context");
}

/**
* Returns the screen X coordinate of the left edge of the content area.
*
* @throws UnsupportedOperationException
*/
@Override
public int getWindowXPosition() {
throw new UnsupportedOperationException("null context");
}

/**
* Returns the screen Y coordinate of the top edge of the content area.
*
* @throws UnsupportedOperationException
*/
@Override
public int getWindowYPosition() {
throw new UnsupportedOperationException("null context");
}
}
46 changes: 40 additions & 6 deletions jme3-desktop/src/main/java/com/jme3/system/AWTContext.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2018 jMonkeyEngine
* Copyright (c) 2009-2023 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -38,11 +38,6 @@
import com.jme3.input.TouchInput;
import com.jme3.opencl.Context;
import com.jme3.renderer.Renderer;
import com.jme3.system.AppSettings;
import com.jme3.system.JmeContext;
import com.jme3.system.JmeSystem;
import com.jme3.system.SystemListener;
import com.jme3.system.Timer;

/**
* A JMonkey {@link JmeContext context} that is dedicated to AWT component rendering.
Expand Down Expand Up @@ -231,4 +226,43 @@ public void destroy(final boolean waitFor) {
backgroundContext.destroy(waitFor);
}

/**
* Returns the height of the framebuffer.
*
* @return the height (in pixels)
*/
@Override
public int getFramebufferHeight() {
return height;
}

/**
* Returns the width of the framebuffer.
*
* @return the width (in pixels)
*/
@Override
public int getFramebufferWidth() {
return width;
}

/**
* Returns the screen X coordinate of the left edge of the content area.
*
* @throws UnsupportedOperationException
*/
@Override
public int getWindowXPosition() {
throw new UnsupportedOperationException("not implemented yet");
}

/**
* Returns the screen Y coordinate of the top edge of the content area.
*
* @throws UnsupportedOperationException
*/
@Override
public int getWindowYPosition() {
throw new UnsupportedOperationException("not implemented yet");
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2021 jMonkeyEngine
* Copyright (c) 2009-2023 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -276,4 +276,43 @@ public void restart() {
// only relevant if changing pixel format.
}

/**
* Returns the height of the input panel.
*
* @return the height (in pixels)
*/
@Override
public int getFramebufferHeight() {
return inputSource.getHeight();
}

/**
* Returns the width of the input panel.
*
* @return the width (in pixels)
*/
@Override
public int getFramebufferWidth() {
return inputSource.getWidth();
}

/**
* Returns the screen X coordinate of the left edge of the input panel.
*
* @return the screen X coordinate
*/
@Override
public int getWindowXPosition() {
return inputSource.getX();
}

/**
* Returns the screen Y coordinate of the top edge of the input panel.
*
* @return the screen Y coordinate
*/
@Override
public int getWindowYPosition() {
return inputSource.getY();
}
}
42 changes: 41 additions & 1 deletion jme3-ios/src/main/java/com/jme3/system/ios/IGLESContext.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2012 jMonkeyEngine
* Copyright (c) 2009-2023 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -216,4 +216,44 @@ public Context getOpenCLContext() {
logger.warning("OpenCL not yet supported on this platform");
return null;
}

/**
* Returns the height of the framebuffer.
*
* @throws UnsupportedOperationException
*/
@Override
public int getFramebufferHeight() {
throw new UnsupportedOperationException("not implemented yet");
}

/**
* Returns the width of the framebuffer.
*
* @throws UnsupportedOperationException
*/
@Override
public int getFramebufferWidth() {
throw new UnsupportedOperationException("not implemented yet");
}

/**
* Returns the screen X coordinate of the left edge of the content area.
*
* @throws UnsupportedOperationException
*/
@Override
public int getWindowXPosition() {
throw new UnsupportedOperationException("not implemented yet");
}

/**
* Returns the screen Y coordinate of the top edge of the content area.
*
* @throws UnsupportedOperationException
*/
@Override
public int getWindowYPosition() {
throw new UnsupportedOperationException("not implemented yet");
}
}
Loading