개발환경 2.3.3
opengl을 이용해서 어플을 만들고있는데요
먼저 제상황은 이렇습니다.
1. 검은색배경에 상자가 돌아가는 소스가 있습니다.
2. 소스는 Activity를 상속한 mainactivity소스에서 xmllayout을 화면에 출력했습니다.
3. FrameLayout을 xmllayout에다가 올리고 mainactivity소스에서 FrameLayout에 GLSurfaceView를 이용한 상자돌아가는 소스를
연결했습니다.
이제 여기서 부터 질문입니다.
상자돌아가는 소스는 아래와같습니다.
public class Lesson05 implements Renderer {
..생략!!
public void onDrawFrame(GL10 gl) {
// Clear Screen And Depth Buffer
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity(); // Reset The Current Modelview Matrix
// Drawing
gl.glTranslatef(0.0f, -1.2f, -7.0f); // Move down 1.0 Unit And Into The
// Screen 7.0
// Minor change: Scale the Cube to 80 percent, otherwise it would be too
// large for the Emulator screen
gl.glScalef(0.8f, 0.8f, 0.8f);
gl.glRotatef(rquad, 1.0f, 1.0f, 1.0f); // Rotate The Square On The X
// axis
cube.draw(gl); // Draw the Cube
// Reset The Current Modelview Matrix
gl.glLoadIdentity();
gl.glTranslatef(0.0f, 1.3f, -6.0f); // Move up 1.3 Units and -6.0 as the
// origin matrix is loaded before
gl.glRotatef(rtri, 0.0f, 1.0f, 0.0f); // Rotate The Triangle On The Y
// axis
pyramid.draw(gl); // Draw the Pyramid
// 도형을 회전하기위한 값
Log.d("Main_Less_rcube", Double.toString(rcube));
Log.d("Main_Less_rpyramid", Double.toString(rpyramid));
rtri += rcube;
rquad -= rpyramid;
// Rotation
// rtri += 0.2f; //Increase The Rotation Variable For The Pyramid
// rquad -= 0.15f; //Decrease The Rotation Variable For The Cube
if (!(rcube == 0.0f && rpyramid == 0.0f)) {
// /초당 프레임 확인//
frame++;
// /초당 프레임 확인//
if (currentTime != (System.currentTimeMillis() / 1000))
// 1000으로 나누어주면 1초씩 계산 된다.
{
currentTime = (System.currentTimeMillis() / 1000);
// 시간이 다른경우 다른 변수에 삽입
frame2 = frame;// 동시에 현재 측정된 프레임값을 옮겨준다.
frame = 0; // 프레임 초기화
}
Log.d("fps", String.valueOf(frame2) + "fps");
}
}
..생략!!
}
이소스중 onDrawFrame부분만 올렸습니다. 위와같이 저공식이 fps가 정확한지는 모르지만 로그캣으로는
잘뜹니다. 이걸 이제 화면에 구석에 출력하고싶은데요 위에 클래스자체를 view로 상속받고 onDraw를 만들거나
내부로 view를 상속받는 class를 만들고 호출해보다던가 꾀많은 삽질을 해봣지만. ㅠ..ㅠ.
도저희 안되서 이렇게 글올립니다.
text를 표시하는게 혹시 이canvas말고도 있다면 알려주세요 아니면 제가 방법이 틀렸다면 알려주세요
많은 고수님들의 답변 기달리겠습니다 감사합니다.



