Android 응용 프로그램에서 사용할 수 있도록이 Objective C GPUImage Framework의 오픈 소스 Java 포트를 생성하도록 지정되었습니다. 모든 변수 이름, 함수 이름 등을 모두 같은 방식으로 최대한 가깝게 다시 작성하려고합니다. 저는 처음 단계에 있으며 GPUImageOpenGLESContext.h와 GPUImageOpenGLESContext.m을 포팅하려고합니다 (미안하지만, 링크를 제공 할 것이지만, 새로운 사용자로서 나는 더 이상의 링크를 추가 할 수 없습니다).Android OpenGLES의 최대/최소 텍스처 크기 결정
나는이 방법
+ (GLint)maximumTextureSizeForThisDevice;
{
GLint maxTextureSize;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
return maxTextureSize;
}
+ (GLint)maximumTextureUnitsForThisDevice;
{
GLint maxTextureUnits;
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextureUnits);
return maxTextureUnits;
}
어려움에 봉착 목표 C에서, 당신은 단지 이러한 방법을 호출 할 수 보이지만 자바 당신은 할 수 없습니다. 일부 검색을 수행했는데 대부분의 사람들이 GLSurfaceView를 사용한다고 말했지만 활동이 필요했을 것입니다. 맞습니까? 이 코드는 Get Maximum OpenGL ES 2.0 Texture Size Limit on Android으로 매우 흥분했지만 코드가 작동하지 않는다고 응답했습니다.
내 질문은, 어떻게하면 활동이 아닌 클래스에서 최소 및 최대 텍스처를 얻을 수 있습니까? GLSurfaceView 사용하기?
이 문제를 이식하는 방법에 대한 의견을 보내 주시면 감사하겠습니다. 나는 Objective C에서 Java에 이식 한 적이 없으므로 조언을 얻으실 수 있습니다! 나는 이것이 이전 게시물입니다 실현
public class GPUImageOpenGLESContext
{
private static GPUImageOpenGLESContext instance = null;
EGLContext context;
protected GPUImageOpenGLESContext()
{
// This is a protected empty method
// that exists only to prevent
// this singleton object from
// multiple instantiation
return;
}
public enum GPUImageRotationMode {
kGPUImageNoRotation, kGPUImageRotateLeft, kGPUImageRotateRight, kGPUImageFlipVertical,
kGPUImageFlipHorizontal, kGPUImageRotateRightFlipVertical, kGPUImageRotate180
}
public GPUImageRotationMode GPUImageRotationSwapsWidthAndHeight(GPUImageRotationMode rotation)
{
// TODO: Implement GPUImageRotationSwapsWidthAndHeight macro as method
//rotation = ((rotation) == kGPUImageRotateLeft || (rotation) == kGPUImageRotateRight || (rotation) == kGPUImageRotateRightFlipVertical)
return rotation;
}
public static GPUImageOpenGLESContext sharedImageProcessingOpenGLESContext()
{
if (instance == null)
{
instance = new GPUImageOpenGLESContext();
}
return instance;
}
public static void useImageProcessingContext()
{
EGLContext imageProcessingContext = GPUImageOpenGLESContext.sharedImageProcessingOpenGLESContext().context;
if (EGLContext.getEGL() != imageProcessingContext)
{
// In Objective C, this call would be here:
// [EAGLContext setCurrentContext:imageProcessingContext]
// Cannot figure out how to handle this. For now, throws an exception.
throw new RuntimeException("useImageProcessingContext not equal to EGLContext");
}
return;
}
public static int maximumTextureSizeForThisDevice()
{
int[] maxTextureSize = new int[1];
// TODO: See if you can use gl. without an activity
//GL10 gl = new GL10();
//EGL gl = EGLContext.getEGL();
//gl.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxTextureSize, 0);
return maxTextureSize[0];
}
public static int maximumTextureUnitsForThisDevice()
{
// TODO: Implement maximumTextureUnitsForThisDevice();
return -1;
}
public static CGSize sizeThatFitsWithinATextureForSize(CGSize inputSize)
{
int maxTextureSize = maximumTextureSizeForThisDevice();
if ((inputSize.width < maxTextureSize) && (inputSize.height < maxTextureSize))
{
return inputSize;
}
CGSize adjustedSize = new CGSize();
if (inputSize.width > inputSize.height)
{
adjustedSize.width = (float)maxTextureSize;
adjustedSize.height = ((float)maxTextureSize/inputSize.width) * inputSize.height;
}
else
{
adjustedSize.height = (float)maxTextureSize;
adjustedSize.width = ((float)maxTextureSize/inputSize.height) * inputSize.width;
}
return adjustedSize;
}
public EGLContext getContext()
{
if (context == null)
{
// TODO: Implement getContext()
}
}
public interface GPUImageInput
{
public void newFrameReadyAtTime(Time frameTime);
public void setInputTextureAtIndex(int newInputTexture, int textureIndex);
public int nextAvailableTextureIndex();
public void setInputSizeAtIndex(CGSize newSize, int textureIndex);
public void setInputRotationAtIndex(GPUImageRotationMode newInputRotation, int textureIndex);
public CGSize maximumOutputSize();
public void endProcessing();
public boolean shouldIgnoreUpdatesToThisTarget();
}
}
끝나면이 사람에게 알리도록하십시오. http://stackoverflow.com/questions/11405207/gpuimage-port-for-android –
GLES20.glGetIntegerv (GLES20.GL_MAX_TEXTURE_SIZE, size, 0); ? – cleuton