Quinn1000
Quinn1000

Reputation: 55

In Java Android OpenGL ES, my extended GLSurfaceView sees getHeight()/getWidth() as 0

Well, the title/subject pretty much covers the issue. Using various examples and and the API on googlecode, it seems like my extended GLSurfaceView class ought to be a good place to work my onTouchEvent inputs but when I try to set variables involving getHeight() and getWidth() when I make the call to my "where did the user touch class", the getHeight() and getWidth() are zero. I have verfied this by telling the class method to return the getHeight() or getWidth() int I passed it and it comes back as zero.

I am using an extended SpriteTextRenderer to display the values from my "where did the user touch class", and I know that it is working well because because I can change the other method to return event.getX() or event.getY() and those values display and update just fine.

My question is, is the extended GLSurfaceView class the place where I should be asking to get the getHeight() and getWidth() values?

Upvotes: 2

Views: 1647

Answers (1)

cement
cement

Reputation: 2905

You can get height and width of GLSurfaceView from parameters in onSurfaceChanged and store them in private fields.

Upvotes: 2

Related Questions