enter image description here 장치에서안드로이드는 OpenGL 원 (구) 타원 ..
또한 첨부 된 스크린 샷, 이 유 pls는 ... 안드로이드 킷캣이 문제를 해결 나를 도울 수없는 투사/카메라처럼 장치에서 버전
public class Balloon
{
private final String vertexShaderCode =
// This matrix member variable provides a hook to manipulate
// the coordinates of the objects that use this vertex shader
"attribute vec4 vPosition;" +
"void main() {" +
"gl_PointSize = 5.0; "+
" gl_Position = vPosition;" +
"}";
private final String fragmentShaderCode =
"precision mediump float;" +
"uniform vec4 vColor;" +
"void main() {" +
" gl_FragColor = vColor;" +
"}";
private FloatBuffer vertexBuffer;
private final int mProgram;
private int mPositionHandle;
private int mColorHandle;
private int mMVPMatrixHandle;
private float[] data = new float[126];
// number of coordinates per vertex in this array
static final int COORDS_PER_VERTEX = 3;
private final int vertexStride = COORDS_PER_VERTEX * 4; // 4 bytes per vertex
float color[] = { 0.63671875f, 0.76953125f, 0.22265625f, 0.0f };
/**
* Sets up the drawing object data for use in an OpenGL ES context.
*/
public Balloon() {
// prepare shaders and OpenGL program
int vertexShader = MyGLRenderer.loadShader(
GLES20.GL_VERTEX_SHADER, vertexShaderCode);
int fragmentShader = MyGLRenderer.loadShader(
GLES20.GL_FRAGMENT_SHADER, fragmentShaderCode);
mProgram = GLES20.glCreateProgram();
// create empty OpenGL Program
GLES20.glAttachShader(mProgram, vertexShader);
// add the vertex shader to program
GLES20.glAttachShader(mProgram, fragmentShader);
// add the fragment shader to program
GLES20.glLinkProgram(mProgram);
// create OpenGL program executables
}
private void FillBalloon(float x1,float y1,float r1)
{
int i=0,j=0;
float angle = 0;
float twicePI = (float)2.0 * (float)3.1415926;
float angle_stepsize = 0.1f;
// go through all angles from 0 to 2 * PI radians
for(;angle < twicePI;angle = (angle + angle_stepsize))
{
// calculate x, y from a vector with known length and angle
data[j++] = x1 + r1 * (float)Math.cos(angle);
data[j++] = y1 + r1 * (float)Math.sin(angle);
}
// initialize vertex byte buffer for shape coordinates
ByteBuffer bb = ByteBuffer.allocateDirect(
// (number of coordinate values * 4 bytes per float)
j * 4);
// use the device hardware's native byte order
bb.order(ByteOrder.nativeOrder());
// create a floating point buffer from the ByteBuffer
vertexBuffer = bb.asFloatBuffer();
// add the coordinates to the FloatBuffer
vertexBuffer.put(data);
// set the buffer to read the first coordinate
vertexBuffer.position(0);
}
/**
* Encapsulates the OpenGL ES instructions for drawing this shape.
*
*/
public void draw() {
// Add program to OpenGL environment
GLES20.glUseProgram(mProgram);
float posX = 0.0f,posY = 0.0f,radius =0.2f;
FillBalloon(posX, posY, radius);
// get handle to vertex shader's vPosition member
mPositionHandle =
GLES20.glGetAttribLocation(mProgram,"vPosition");
// Enable a handle to the triangle vertices
GLES20.glEnableVertexAttribArray(mPositionHandle);
// Prepare the balloon coordinate data
GLES20.glVertexAttribPointer(mPositionHandle, 2, GLES20.GL_FLOAT, false, 0, vertexBuffer);
// get handle to fragment shader's vColor member
mColorHandle = GLES20.glGetUniformLocation(mProgram, "vColor");
// Set color for drawing the triangle
GLES20.glUniform4fv(mColorHandle, 1, color, 0);
MyGLRenderer.checkGlError("mColorHandle");
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_FAN, 0, 63);
// Disable vertex array
GLES20.glDisableVertexAttribArray(mPositionHandle);
}
}
또한 첨부 된 스크린 샷은 유 pls는 저 문제를 해결하는 데 도움이 ... 01,235 X 그 규모에 의해 좌표 그런 다음 드로우 시간을 곱
public void draw(float X_SCALE) {
...
FillBaloon(posX, posY, radius, X_SCALE);
...
}
을 : 16,float 타입을 추가 풍선 동그라미처럼 보이게하기 위해 안드로이드 킷캣 버전
내 모습이 거꾸로 보입니다. 난 당신이 스케일링 요소로 종횡비의 반대를 사용하려는 생각합니다. 또는이 값을 사용하여 x가 아닌 y의 크기를 조정합니다. –
레토 코라 디 (Reto Koradi), 리차드 클라센 (Richard Klaassen) ...Aspect on X에 대한 Aspect 또는 Y에 대한 Factor의 역함수는 잘 작동합니다 ... 당신은 ppl로 하여금 하루를 보냈습니다 ... 감사합니다. – murty
@RetoKoradi 좋은 콜, 코드의 정의를 수정했습니다. –