[android-developers] Re: SurfaceView to slow for games? OpenGL necessary to do games?
Another solution is to display regular view on top of the 3D view. On Sep 2, 8:14 am, Robert Green rbgrn@gmail.com wrote: Light Racer 3D uses dynamic text by drawing to a HUD canvas and then uploading that texture for each update. It did work to upload the new texture every frame (score changing every tick) but it did have a slight impact on performance. I ended up just updating every 10 frames. For my next game I'm going to add a utility that uploads an alphanumeric texture and stores letter sizes and coords, then draws a quad for each, like was suggested above. It takes a little longer to build that but once you've got it, it will be the fastest solution for really dynamic stuff like scores that change very often or timers that count down with 100ths of a second or something like that. On Sep 1, 9:51 pm, David Minor davemi...@gmail.com wrote: I believe you can also draw text on a Canvas, and then use the underlying bitmap to create a texture. On Sep 1, 4:21 pm, Dan Sherman impact...@gmail.com wrote: Yeah, that's what we were looking into doing. Was just hoping that there might be a nice framework I missed somehow :) Thanks man :) On Tue, Sep 1, 2009 at 3:10 PM, Phred phr...@gmail.com wrote: Dan,I've yet to start messing with GL ES so this is coming from Direct3D experience but the idea is the same. What you can do is create a texture with all the letters of the alphabet, numbers 0-9 and symbols. There are apps out there that will create such a texture and an XML file that contains the texture co- ords for each letter/number/symbol. This one would work as it exports in PNG format which Android supports: http://www.angelcode.com/products/bmfont/ To draw the text you have render 1 quad for each alpha-numeric character being drawn at the location on screen you want it drawn too. So if your text is Hello then you will have to render 5 quads. Each quad will contain the texture co-ords of the corresponding alpha- numeric character in the texture. I would create a vertex buffer object at start-up and make it large enough to hold 256 characters. Your draw text function would then fill out this buffer each frame update with the updated text location co- ordinates then all you have to do is get OpenGL to render it. You will want it rendered in orthographic projection mode and using screen space co-ordinates... that is you don't want OpenGL to transform or light those verticies for you. Again not sure of the GLES pipeline as all my experience is Direct3D. Make sense kinda kinda? Fred On Aug 24, 3:27 pm, Dan Sherman impact...@gmail.com wrote: We're having the same issues in some of our games. Unfortunately running into issues drawing dynamic text in OpenGL, any chance you'd care to share your solution for that? (if you have one that is) - Dan On Mon, Aug 24, 2009 at 2:39 PM, TjerkW tje...@gmail.com wrote: The SpriteMethodTest application shows the benefits of opengl, the main benefit is: If you have a lot of sprites / a lot of things happening at the same time it is better to use opengl. I am porting my game to opengl now. It was too slow on only the Canvas (30+ things moving at the same time) On 22 jul, 12:45, MrChaz mrchazmob...@googlemail.com wrote: The SurfaceView is fine for games, at least simple ones. Have a look at the LunarLander sample. http://developer.android.com/guide/samples/LunarLander/index.html On Jul 21, 9:33 pm, klirr haskell...@gmail.com wrote: I use SurfaceView for my game, tried normal View first but that was to slow. Problem is, it still is. The redrawing just isn't anywhere fast enough for a game. So unless it is a lot faster on the real phone this won't cut it at all. Is it necessary to use OpenGL for games? package com.android.shmup; import android.app.Activity; import android.content.Context; import android.graphics.*; import android.os.Bundle; import android.view.View; import android.view.KeyEvent; public class Shmup extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new GameView(this)); } private static class GameView extends View { private Paint mPaint = new Paint(); private int x; private int y; public GameView(Context context) { super(context); x = 135; y = 303; setFocusable(true); requestFocus(); } @Override
[android-developers] Re: SurfaceView to slow for games? OpenGL necessary to do games?
Ya the OpenGL solution is the best bet in the long run both for performance as well as all the cool stuff you can do with the text when using the 3D hardware like being able to fade text in and out by modifying the alpha values of the verticies or changing text color by messing with the diffuse settings. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: SurfaceView to slow for games? OpenGL necessary to do games?
Dan,I've yet to start messing with GL ES so this is coming from Direct3D experience but the idea is the same. What you can do is create a texture with all the letters of the alphabet, numbers 0-9 and symbols. There are apps out there that will create such a texture and an XML file that contains the texture co- ords for each letter/number/symbol. This one would work as it exports in PNG format which Android supports: http://www.angelcode.com/products/bmfont/ To draw the text you have render 1 quad for each alpha-numeric character being drawn at the location on screen you want it drawn too. So if your text is Hello then you will have to render 5 quads. Each quad will contain the texture co-ords of the corresponding alpha- numeric character in the texture. I would create a vertex buffer object at start-up and make it large enough to hold 256 characters. Your draw text function would then fill out this buffer each frame update with the updated text location co- ordinates then all you have to do is get OpenGL to render it. You will want it rendered in orthographic projection mode and using screen space co-ordinates... that is you don't want OpenGL to transform or light those verticies for you. Again not sure of the GLES pipeline as all my experience is Direct3D. Make sense kinda kinda? Fred On Aug 24, 3:27 pm, Dan Sherman impact...@gmail.com wrote: We're having the same issues in some of our games. Unfortunately running into issues drawing dynamic text in OpenGL, any chance you'd care to share your solution for that? (if you have one that is) - Dan On Mon, Aug 24, 2009 at 2:39 PM, TjerkW tje...@gmail.com wrote: The SpriteMethodTest application shows the benefits of opengl, the main benefit is: If you have a lot of sprites / a lot of things happening at the same time it is better to use opengl. I am porting my game to opengl now. It was too slow on only the Canvas (30+ things moving at the same time) On 22 jul, 12:45, MrChaz mrchazmob...@googlemail.com wrote: The SurfaceView is fine for games, at least simple ones. Have a look at the LunarLander sample. http://developer.android.com/guide/samples/LunarLander/index.html On Jul 21, 9:33 pm, klirr haskell...@gmail.com wrote: I use SurfaceView for my game, tried normal View first but that was to slow. Problem is, it still is. The redrawing just isn't anywhere fast enough for a game. So unless it is a lot faster on the real phone this won't cut it at all. Is it necessary to use OpenGL for games? package com.android.shmup; import android.app.Activity; import android.content.Context; import android.graphics.*; import android.os.Bundle; import android.view.View; import android.view.KeyEvent; public class Shmup extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new GameView(this)); } private static class GameView extends View { private Paint mPaint = new Paint(); private int x; private int y; public GameView(Context context) { super(context); x = 135; y = 303; setFocusable(true); requestFocus(); } @Override protected void onDraw(Canvascanvas) { Paint paint = mPaint; canvas.translate(10, 10); canvas.drawColor(Color.rgb(184,134,11)); paint.setColor(Color.rgb(107,142,35)); paint.setStrokeWidth(1); canvas.drawRect(x, y, x+30, y+7, paint); canvas.drawRect(x+10, y+7, x+20, y+27, paint); canvas.drawRect(x+5, y+27, x+25, y+32, paint); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_DPAD_UP) { y -= 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) { x -= 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) { y += 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) { x += 3; invalidate(); } return true; } } } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group
[android-developers] Re: SurfaceView to slow for games? OpenGL necessary to do games?
Yeah, that's what we were looking into doing. Was just hoping that there might be a nice framework I missed somehow :) Thanks man :) On Tue, Sep 1, 2009 at 3:10 PM, Phred phr...@gmail.com wrote: Dan,I've yet to start messing with GL ES so this is coming from Direct3D experience but the idea is the same. What you can do is create a texture with all the letters of the alphabet, numbers 0-9 and symbols. There are apps out there that will create such a texture and an XML file that contains the texture co- ords for each letter/number/symbol. This one would work as it exports in PNG format which Android supports: http://www.angelcode.com/products/bmfont/ To draw the text you have render 1 quad for each alpha-numeric character being drawn at the location on screen you want it drawn too. So if your text is Hello then you will have to render 5 quads. Each quad will contain the texture co-ords of the corresponding alpha- numeric character in the texture. I would create a vertex buffer object at start-up and make it large enough to hold 256 characters. Your draw text function would then fill out this buffer each frame update with the updated text location co- ordinates then all you have to do is get OpenGL to render it. You will want it rendered in orthographic projection mode and using screen space co-ordinates... that is you don't want OpenGL to transform or light those verticies for you. Again not sure of the GLES pipeline as all my experience is Direct3D. Make sense kinda kinda? Fred On Aug 24, 3:27 pm, Dan Sherman impact...@gmail.com wrote: We're having the same issues in some of our games. Unfortunately running into issues drawing dynamic text in OpenGL, any chance you'd care to share your solution for that? (if you have one that is) - Dan On Mon, Aug 24, 2009 at 2:39 PM, TjerkW tje...@gmail.com wrote: The SpriteMethodTest application shows the benefits of opengl, the main benefit is: If you have a lot of sprites / a lot of things happening at the same time it is better to use opengl. I am porting my game to opengl now. It was too slow on only the Canvas (30+ things moving at the same time) On 22 jul, 12:45, MrChaz mrchazmob...@googlemail.com wrote: The SurfaceView is fine for games, at least simple ones. Have a look at the LunarLander sample. http://developer.android.com/guide/samples/LunarLander/index.html On Jul 21, 9:33 pm, klirr haskell...@gmail.com wrote: I use SurfaceView for my game, tried normal View first but that was to slow. Problem is, it still is. The redrawing just isn't anywhere fast enough for a game. So unless it is a lot faster on the real phone this won't cut it at all. Is it necessary to use OpenGL for games? package com.android.shmup; import android.app.Activity; import android.content.Context; import android.graphics.*; import android.os.Bundle; import android.view.View; import android.view.KeyEvent; public class Shmup extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new GameView(this)); } private static class GameView extends View { private Paint mPaint = new Paint(); private int x; private int y; public GameView(Context context) { super(context); x = 135; y = 303; setFocusable(true); requestFocus(); } @Override protected void onDraw(Canvascanvas) { Paint paint = mPaint; canvas.translate(10, 10); canvas.drawColor(Color.rgb(184,134,11)); paint.setColor(Color.rgb(107,142,35)); paint.setStrokeWidth(1); canvas.drawRect(x, y, x+30, y+7, paint); canvas.drawRect(x+10, y+7, x+20, y+27, paint); canvas.drawRect(x+5, y+27, x+25, y+32, paint); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_DPAD_UP) { y -= 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) { x -= 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) { y += 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) { x += 3; invalidate(); } return true; } } }
[android-developers] Re: SurfaceView to slow for games? OpenGL necessary to do games?
I believe you can also draw text on a Canvas, and then use the underlying bitmap to create a texture. On Sep 1, 4:21 pm, Dan Sherman impact...@gmail.com wrote: Yeah, that's what we were looking into doing. Was just hoping that there might be a nice framework I missed somehow :) Thanks man :) On Tue, Sep 1, 2009 at 3:10 PM, Phred phr...@gmail.com wrote: Dan,I've yet to start messing with GL ES so this is coming from Direct3D experience but the idea is the same. What you can do is create a texture with all the letters of the alphabet, numbers 0-9 and symbols. There are apps out there that will create such a texture and an XML file that contains the texture co- ords for each letter/number/symbol. This one would work as it exports in PNG format which Android supports: http://www.angelcode.com/products/bmfont/ To draw the text you have render 1 quad for each alpha-numeric character being drawn at the location on screen you want it drawn too. So if your text is Hello then you will have to render 5 quads. Each quad will contain the texture co-ords of the corresponding alpha- numeric character in the texture. I would create a vertex buffer object at start-up and make it large enough to hold 256 characters. Your draw text function would then fill out this buffer each frame update with the updated text location co- ordinates then all you have to do is get OpenGL to render it. You will want it rendered in orthographic projection mode and using screen space co-ordinates... that is you don't want OpenGL to transform or light those verticies for you. Again not sure of the GLES pipeline as all my experience is Direct3D. Make sense kinda kinda? Fred On Aug 24, 3:27 pm, Dan Sherman impact...@gmail.com wrote: We're having the same issues in some of our games. Unfortunately running into issues drawing dynamic text in OpenGL, any chance you'd care to share your solution for that? (if you have one that is) - Dan On Mon, Aug 24, 2009 at 2:39 PM, TjerkW tje...@gmail.com wrote: The SpriteMethodTest application shows the benefits of opengl, the main benefit is: If you have a lot of sprites / a lot of things happening at the same time it is better to use opengl. I am porting my game to opengl now. It was too slow on only the Canvas (30+ things moving at the same time) On 22 jul, 12:45, MrChaz mrchazmob...@googlemail.com wrote: The SurfaceView is fine for games, at least simple ones. Have a look at the LunarLander sample. http://developer.android.com/guide/samples/LunarLander/index.html On Jul 21, 9:33 pm, klirr haskell...@gmail.com wrote: I use SurfaceView for my game, tried normal View first but that was to slow. Problem is, it still is. The redrawing just isn't anywhere fast enough for a game. So unless it is a lot faster on the real phone this won't cut it at all. Is it necessary to use OpenGL for games? package com.android.shmup; import android.app.Activity; import android.content.Context; import android.graphics.*; import android.os.Bundle; import android.view.View; import android.view.KeyEvent; public class Shmup extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new GameView(this)); } private static class GameView extends View { private Paint mPaint = new Paint(); private int x; private int y; public GameView(Context context) { super(context); x = 135; y = 303; setFocusable(true); requestFocus(); } @Override protected void onDraw(Canvascanvas) { Paint paint = mPaint; canvas.translate(10, 10); canvas.drawColor(Color.rgb(184,134,11)); paint.setColor(Color.rgb(107,142,35)); paint.setStrokeWidth(1); canvas.drawRect(x, y, x+30, y+7, paint); canvas.drawRect(x+10, y+7, x+20, y+27, paint); canvas.drawRect(x+5, y+27, x+25, y+32, paint); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_DPAD_UP) { y -= 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) { x -= 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) { y += 3; invalidate(); } else if (keyCode
[android-developers] Re: SurfaceView to slow for games? OpenGL necessary to do games?
Light Racer 3D uses dynamic text by drawing to a HUD canvas and then uploading that texture for each update. It did work to upload the new texture every frame (score changing every tick) but it did have a slight impact on performance. I ended up just updating every 10 frames. For my next game I'm going to add a utility that uploads an alphanumeric texture and stores letter sizes and coords, then draws a quad for each, like was suggested above. It takes a little longer to build that but once you've got it, it will be the fastest solution for really dynamic stuff like scores that change very often or timers that count down with 100ths of a second or something like that. On Sep 1, 9:51 pm, David Minor davemi...@gmail.com wrote: I believe you can also draw text on a Canvas, and then use the underlying bitmap to create a texture. On Sep 1, 4:21 pm, Dan Sherman impact...@gmail.com wrote: Yeah, that's what we were looking into doing. Was just hoping that there might be a nice framework I missed somehow :) Thanks man :) On Tue, Sep 1, 2009 at 3:10 PM, Phred phr...@gmail.com wrote: Dan,I've yet to start messing with GL ES so this is coming from Direct3D experience but the idea is the same. What you can do is create a texture with all the letters of the alphabet, numbers 0-9 and symbols. There are apps out there that will create such a texture and an XML file that contains the texture co- ords for each letter/number/symbol. This one would work as it exports in PNG format which Android supports: http://www.angelcode.com/products/bmfont/ To draw the text you have render 1 quad for each alpha-numeric character being drawn at the location on screen you want it drawn too. So if your text is Hello then you will have to render 5 quads. Each quad will contain the texture co-ords of the corresponding alpha- numeric character in the texture. I would create a vertex buffer object at start-up and make it large enough to hold 256 characters. Your draw text function would then fill out this buffer each frame update with the updated text location co- ordinates then all you have to do is get OpenGL to render it. You will want it rendered in orthographic projection mode and using screen space co-ordinates... that is you don't want OpenGL to transform or light those verticies for you. Again not sure of the GLES pipeline as all my experience is Direct3D. Make sense kinda kinda? Fred On Aug 24, 3:27 pm, Dan Sherman impact...@gmail.com wrote: We're having the same issues in some of our games. Unfortunately running into issues drawing dynamic text in OpenGL, any chance you'd care to share your solution for that? (if you have one that is) - Dan On Mon, Aug 24, 2009 at 2:39 PM, TjerkW tje...@gmail.com wrote: The SpriteMethodTest application shows the benefits of opengl, the main benefit is: If you have a lot of sprites / a lot of things happening at the same time it is better to use opengl. I am porting my game to opengl now. It was too slow on only the Canvas (30+ things moving at the same time) On 22 jul, 12:45, MrChaz mrchazmob...@googlemail.com wrote: The SurfaceView is fine for games, at least simple ones. Have a look at the LunarLander sample. http://developer.android.com/guide/samples/LunarLander/index.html On Jul 21, 9:33 pm, klirr haskell...@gmail.com wrote: I use SurfaceView for my game, tried normal View first but that was to slow. Problem is, it still is. The redrawing just isn't anywhere fast enough for a game. So unless it is a lot faster on the real phone this won't cut it at all. Is it necessary to use OpenGL for games? package com.android.shmup; import android.app.Activity; import android.content.Context; import android.graphics.*; import android.os.Bundle; import android.view.View; import android.view.KeyEvent; public class Shmup extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new GameView(this)); } private static class GameView extends View { private Paint mPaint = new Paint(); private int x; private int y; public GameView(Context context) { super(context); x = 135; y = 303; setFocusable(true); requestFocus(); } @Override protected void onDraw(Canvascanvas) { Paint paint = mPaint; canvas.translate(10, 10); canvas.drawColor(Color.rgb(184,134,11)); paint.setColor(Color.rgb(107,142,35));
[android-developers] Re: SurfaceView to slow for games? OpenGL necessary to do games?
The SpriteMethodTest application shows the benefits of opengl, the main benefit is: If you have a lot of sprites / a lot of things happening at the same time it is better to use opengl. I am porting my game to opengl now. It was too slow on only the Canvas (30+ things moving at the same time) On 22 jul, 12:45, MrChaz mrchazmob...@googlemail.com wrote: The SurfaceView is fine for games, at least simple ones. Have a look at the LunarLander sample. http://developer.android.com/guide/samples/LunarLander/index.html On Jul 21, 9:33 pm, klirr haskell...@gmail.com wrote: I use SurfaceView for my game, tried normal View first but that was to slow. Problem is, it still is. The redrawing just isn't anywhere fast enough for a game. So unless it is a lot faster on the real phone this won't cut it at all. Is it necessary to use OpenGL for games? package com.android.shmup; import android.app.Activity; import android.content.Context; import android.graphics.*; import android.os.Bundle; import android.view.View; import android.view.KeyEvent; public class Shmup extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new GameView(this)); } private static class GameView extends View { private Paint mPaint = new Paint(); private int x; private int y; public GameView(Context context) { super(context); x = 135; y = 303; setFocusable(true); requestFocus(); } @Override protected void onDraw(Canvascanvas) { Paint paint = mPaint; canvas.translate(10, 10); canvas.drawColor(Color.rgb(184,134,11)); paint.setColor(Color.rgb(107,142,35)); paint.setStrokeWidth(1); canvas.drawRect(x, y, x+30, y+7, paint); canvas.drawRect(x+10, y+7, x+20, y+27, paint); canvas.drawRect(x+5, y+27, x+25, y+32, paint); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_DPAD_UP) { y -= 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) { x -= 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) { y += 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) { x += 3; invalidate(); } return true; } } } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: SurfaceView to slow for games? OpenGL necessary to do games?
We're having the same issues in some of our games. Unfortunately running into issues drawing dynamic text in OpenGL, any chance you'd care to share your solution for that? (if you have one that is) - Dan On Mon, Aug 24, 2009 at 2:39 PM, TjerkW tje...@gmail.com wrote: The SpriteMethodTest application shows the benefits of opengl, the main benefit is: If you have a lot of sprites / a lot of things happening at the same time it is better to use opengl. I am porting my game to opengl now. It was too slow on only the Canvas (30+ things moving at the same time) On 22 jul, 12:45, MrChaz mrchazmob...@googlemail.com wrote: The SurfaceView is fine for games, at least simple ones. Have a look at the LunarLander sample. http://developer.android.com/guide/samples/LunarLander/index.html On Jul 21, 9:33 pm, klirr haskell...@gmail.com wrote: I use SurfaceView for my game, tried normal View first but that was to slow. Problem is, it still is. The redrawing just isn't anywhere fast enough for a game. So unless it is a lot faster on the real phone this won't cut it at all. Is it necessary to use OpenGL for games? package com.android.shmup; import android.app.Activity; import android.content.Context; import android.graphics.*; import android.os.Bundle; import android.view.View; import android.view.KeyEvent; public class Shmup extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new GameView(this)); } private static class GameView extends View { private Paint mPaint = new Paint(); private int x; private int y; public GameView(Context context) { super(context); x = 135; y = 303; setFocusable(true); requestFocus(); } @Override protected void onDraw(Canvascanvas) { Paint paint = mPaint; canvas.translate(10, 10); canvas.drawColor(Color.rgb(184,134,11)); paint.setColor(Color.rgb(107,142,35)); paint.setStrokeWidth(1); canvas.drawRect(x, y, x+30, y+7, paint); canvas.drawRect(x+10, y+7, x+20, y+27, paint); canvas.drawRect(x+5, y+27, x+25, y+32, paint); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_DPAD_UP) { y -= 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) { x -= 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) { y += 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) { x += 3; invalidate(); } return true; } } } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: SurfaceView to slow for games? OpenGL necessary to do games?
Some phones implement this functionality in hardware, others in software. Here is a tutorial I found recently: http://sites.google.com/site/drpaulthomasandroidstuff/Home/voxel-fun/how-it-works --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: SurfaceView to slow for games? OpenGL necessary to do games?
The SurfaceView is fine for games, at least simple ones. Have a look at the LunarLander sample. http://developer.android.com/guide/samples/LunarLander/index.html On Jul 21, 9:33 pm, klirr haskell...@gmail.com wrote: I use SurfaceView for my game, tried normal View first but that was to slow. Problem is, it still is. The redrawing just isn't anywhere fast enough for a game. So unless it is a lot faster on the real phone this won't cut it at all. Is it necessary to use OpenGL for games? package com.android.shmup; import android.app.Activity; import android.content.Context; import android.graphics.*; import android.os.Bundle; import android.view.View; import android.view.KeyEvent; public class Shmup extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new GameView(this)); } private static class GameView extends View { private Paint mPaint = new Paint(); private int x; private int y; public GameView(Context context) { super(context); x = 135; y = 303; setFocusable(true); requestFocus(); } @Override protected void onDraw(Canvas canvas) { Paint paint = mPaint; canvas.translate(10, 10); canvas.drawColor(Color.rgb(184,134,11)); paint.setColor(Color.rgb(107,142,35)); paint.setStrokeWidth(1); canvas.drawRect(x, y, x+30, y+7, paint); canvas.drawRect(x+10, y+7, x+20, y+27, paint); canvas.drawRect(x+5, y+27, x+25, y+32, paint); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_DPAD_UP) { y -= 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) { x -= 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) { y += 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) { x += 3; invalidate(); } return true; } } } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: SurfaceView to slow for games? OpenGL necessary to do games?
Did you try to have the rendering done in a seperate thread? On Jul 21, 4:33 pm, klirr haskell...@gmail.com wrote: I use SurfaceView for my game, tried normal View first but that was to slow. Problem is, it still is. The redrawing just isn't anywhere fast enough for a game. So unless it is a lot faster on the real phone this won't cut it at all. Is it necessary to use OpenGL for games? package com.android.shmup; import android.app.Activity; import android.content.Context; import android.graphics.*; import android.os.Bundle; import android.view.View; import android.view.KeyEvent; public class Shmup extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new GameView(this)); } private static class GameView extends View { private Paint mPaint = new Paint(); private int x; private int y; public GameView(Context context) { super(context); x = 135; y = 303; setFocusable(true); requestFocus(); } @Override protected void onDraw(Canvas canvas) { Paint paint = mPaint; canvas.translate(10, 10); canvas.drawColor(Color.rgb(184,134,11)); paint.setColor(Color.rgb(107,142,35)); paint.setStrokeWidth(1); canvas.drawRect(x, y, x+30, y+7, paint); canvas.drawRect(x+10, y+7, x+20, y+27, paint); canvas.drawRect(x+5, y+27, x+25, y+32, paint); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_DPAD_UP) { y -= 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) { x -= 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) { y += 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) { x += 3; invalidate(); } return true; } } }- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: SurfaceView to slow for games? OpenGL necessary to do games?
no, thanks for the tip. should I have one main thread and then have one drawing-thread running the whole time then? and GameView should implement Runnable? what should be in run()? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: SurfaceView to slow for games? OpenGL necessary to do games?
You can't make any judgements about performance based on the emulator. You HAVE to run your code on a device, plain and simple. It could be faster than the emulator, it could be slower, you don't know. On Tue, Jul 21, 2009 at 1:33 PM, klirr haskell...@gmail.com wrote: I use SurfaceView for my game, tried normal View first but that was to slow. Problem is, it still is. The redrawing just isn't anywhere fast enough for a game. So unless it is a lot faster on the real phone this won't cut it at all. Is it necessary to use OpenGL for games? package com.android.shmup; import android.app.Activity; import android.content.Context; import android.graphics.*; import android.os.Bundle; import android.view.View; import android.view.KeyEvent; public class Shmup extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new GameView(this)); } private static class GameView extends View { private Paint mPaint = new Paint(); private int x; private int y; public GameView(Context context) { super(context); x = 135; y = 303; setFocusable(true); requestFocus(); } @Override protected void onDraw(Canvas canvas) { Paint paint = mPaint; canvas.translate(10, 10); canvas.drawColor(Color.rgb(184,134,11)); paint.setColor(Color.rgb(107,142,35)); paint.setStrokeWidth(1); canvas.drawRect(x, y, x+30, y+7, paint); canvas.drawRect(x+10, y+7, x+20, y+27, paint); canvas.drawRect(x+5, y+27, x+25, y+32, paint); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_DPAD_UP) { y -= 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) { x -= 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) { y += 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) { x += 3; invalidate(); } return true; } } } -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---