Android :: Drawing 2D Stuff On Screen In OpenGL Over 3D Scene
Jun 27, 2010
Can somebody take me step-by-step how to draw 2D stuff over a 3D scene (such as controls, etc.). What I've been doing so far has not been working (it only draws the 3D scene), which is (in every frame): draw the 3D scene as normal, projection matrix mode, load identity, call GLU.gluOrtho2D(gl, 0, myScreenWidthInPixels, 0, myScreenHeightInPixels), switch the array pointers (vertices and texture coords) to the ones for my 2D stuff, then drawElements with an appropriate index list. (then switch the array pointers back so the 3D stuff works again).I get nothing added to the screen (just the 3D stuff).Do I need to be doing something else for it to draw? Can somebody take me step-by-step?
View 5 Replies
Nov 10, 2010
I'm developing an Android application. I'm very new on it. I have the following classes:
class CustomGLSurfaceView extends GLSurfaceView
class CustomRenderer implements GLSurfaceView.Renderer
CustomGLSurfaceView uses CustomRenderer to render a cube on onDrawFrame method.
I've added an onTouchEvent(MotionEvent event) on CustomGLSurfaceView to manage touch events:
class CustomGLSurfaceView extends GLSurfaceView {
// For touch inputs - previous touch (x, y)
private float previousX; private float previousY;
private CustomRenderer myRenderer; public CustomGLSurfaceView(Context context) {
super(context); myRenderer = new CustomRenderer(); setRenderer(myRenderer);
} @Override public boolean onTouchEvent(MotionEvent event) {
float currentX = event.getX(); float currentY = event.getY();
switch (event.getAction()) { case MotionEvent.ACTION_MOVE:
myRenderer.handleMovement(currentY, currentY, previousX, previousY);
} // Save current x, y
previousX = currentX; previousY = currentY;
return true; // Event handled } }
May I have to modify onDrawFrame to draw something new or to rotate the cube? I thing I must do it on handleMovement.
View 1 Replies
View Related
Mar 16, 2010
I have to recommend just getting a book on the subject.I learned most everything off of examples and documents on the web.After several months, I finally picked up the blue book and everything I had scoured to find is clearly demonstrated in it.Look for the red book and the blue "superbible."They cover everything you need.There are also books specific to ES.Make sure to get a good 1.1 one and not a 2.0-only one.
View 7 Replies
View Related
Aug 10, 2010
Using OpenGL ES, how do I draw an image from the resources file onto the screen? The image is in png format, if that matters.
View 3 Replies
View Related
Aug 4, 2010
Is there a way to set different bluetooth, screen timeout, and profile settings for each scene on the Evo? I use Pandora and the music player in the car. The problem is my bluetooth headset is set to play media audio so I have to change that every time I get in and out of the car. And I don't want the display shutting off either, so I have to change that every time I get in and out of the car. While I'm at it, is there a way to set a different profile (vibrate, normal, silent) on different Scenes? That's another thing that I find myself manually changing more often than I would like. I'm thinking the "Scenes" feature of Sense would be ideal for this. Just set up the apps you want, the profile settings, display settings, etc, and save that Scene. But I can't make it save any settings other than the wallpaper and widgets/shortuts.Does anyone know how I could go about this? Even is it's not possible in Sense, is there another way to do it?
View 1 Replies
View Related
Oct 15, 2009
Is it possible to change the wall paper for each screen within a scene? Loaded a personal pic for wallpaper and it is like panaromic view. Each screen within scene is a portion of pic. If I cant change pics for each screen, can I at least make the pic whole for each screen?
View 2 Replies
View Related
Mar 3, 2010
I just got my eris so i was experimenting with apps. I was reading a thread about Lockbot and decided to see what it was all about.. I messed with it for a few mins and decided i didn't like it so i uninstalled it. When i pushed the home button a menu pushed up that said something along the lines of "Home or Sence" (or something like that) and i chose sence because i was curious. Now my home screen is completely different and lost my custom scene.
View 1 Replies
View Related
Nov 5, 2010
Ii haven't made any big changes to my Desire and all was working well. suddenly a couple of days ago i noticed that things slowed down significantly.
exmples: when drawing the unlock screen, there is a big lag till the home screen comes up huge lag in opening programmes or menus
so, the only app i recently installed was the BA (british airways) android app. could this have affected the whole phone?
what steps can i take to check what might be wrong?looking at the SPARE PARTS app, i can see that CPU usage shows a huge bar for "init".i don't know if this is a normal process? anyone got info on this? might have nothing to do with my phone lagging of course.
View 1 Replies
View Related
Jan 7, 2010
I wrote a reading software. I implemented the page turning effect when user tap the screen to turn to next/pre page. The display is ok on G1 (320X200 size) but it can not works well on Droid(480*854 size), the font looks a litter fuzzy, not clear as G1. I explain my codes for page turning:
1) create a canvas A
2) create bitmap.
3) set bitmap on canvas A
4) draw the new page content on canvas A
5) the current showing page has been saved in bitmap before since we do from step 1) to setp 4),
6) In order to implement the turning effect of scrolling from left to right, I draw the old bitmap part and draw the new bitmap part until the whole new bitmap has been drawn. all of bitmaps are drawing by canvas.drawBitmap() in onDraw() function.
7) when step 6) is done, it means the new page has been shown on screen, and the bitmap has been saved to use in next page turning.
The above is the whole actions for my page turning. On G1, no problem. But on Droid phone, the font is not clear, I tried if I directly draw text by canvas in OnDraw() not through bitmap, It is ok, but it can not implement the page turning effect that I need. I don't know why, could you please help me to take a look and tell me where is wrong or miss some steps?
View 2 Replies
View Related
Apr 25, 2010
I have a game built for 480x320 screen resolution. When playing the game on a phone with a higher screen resolution (480 x 800 or 480 x 856) the game automatically stretches to fit the screen which works great. Because of different screen dimensions there is a piece of the screen on the right side (game is in landscape mode) that is black, not used by the game. I want to fill this up with an image, so the whole screen is filled. I only draw that image on screens bigger than 480x320. This all works fine, the image is displayed exactly the way I want to. The only problem is that the game runs less smooth then it used to run. There are small stutters noticeable. When I just draw a rectangle instead of an image the same problem occurs. Does anyone have an idea why this is happening?
View 8 Replies
View Related
Nov 15, 2010
How to draw, say, a rectangle on the screen with it being proportional to the current device?
e.g. a rectangle, centered on the viewport, one pixel smaller than the screen on each border.
I can live with Orthogonal, but would like perspective (basically everything at Z=something should be proportional to the screen, and the upper parts of the elements being distorted by perspective)
I can calculate everything on my own if i know the relation... but i don't have a starting point.
I could experiment and get to a relation myself... i even resorted to that while coding for the Wii, but that's a really bad decision on Android and all the screen ratios/sizes out there...
View 1 Replies
View Related
Sep 3, 2009
My application required to draw image on full screen. now the phone screen size will be different. So will i have to make different image for each phone or i can use just one image and it can display on full screen in any device.
View 2 Replies
View Related
Nov 16, 2009
I have been playing with Android for a couple of months, so I'm still kindof newbie on this. I've looking for previous questions like mine, but I was unable to find any proper solution. So here goes my question:
I'm trying to draw a Camera Preview in a certain part of the screen (for instance, square upper-left). So what I suppose I should do is the following:
CODE:.............
And on the Preview Class I have the following lines:
CODE:....................
View 2 Replies
View Related
Sep 17, 2010
Is there off screen drawing possible in android like a imageContext in objective C. if it is kindly tell me the link or some kind of hint.
View 2 Replies
View Related
Sep 16, 2009
I want to make a tile based game for android. At the moment I am drawing each tile as a separate bitmap. I have a big for loop that reads from a string and draws different tiles depending on what character it finds to draw the level. I have allowed the user to scroll the screen using scrolling gestures. However the game is too slow. It takes a long time to update the screen after the user scrolls. I presume this is because it has to draw each tile's bitmap individually. What would be a faster way to draw the level? I was thinking I could merge all the tiles into one bitmap. But I don't know how to do this.
Anyway here is my code so you can see the problem:
package org.example.tutorial2d;
import android.app.Activity;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.GestureDetector.OnGestureListener;
import org.example.tutorial2d.Panel;
public class Tutorial2D extends Activity implements OnGestureListener {
GestureDetector gestureScanner; Panel main;
/** Called when the activity is first created. */
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
gestureScanner = new GestureDetector(this);
//requestWindowFeature(Window.FEATURE_NO_TITLE);
main = new Panel(this); setContentView(main); }
@Override public boolean onTouchEvent(MotionEvent me) {
return gestureScanner.onTouchEvent(me); }
@Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
main.handleScroll(distanceX,distanceY); return true; }
@Override public boolean onDown(MotionEvent e) { return true;
} @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { return true;
} @Override public void onLongPress(MotionEvent e){
} @Override public void onShowPress(MotionEvent e) {
} @Override public boolean onSingleTapUp(MotionEvent e) { return true; } }
And the class that does all the work:
package org.example.tutorial2d;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.View;
import org.example.tutorial2d.Point;
public class Panel extends View {
private int scrollX = 0; private int scrollY = 0;
public Panel(Context context) { super(context);
} @Override public void onDraw(Canvas canvas) {
/*Bitmap scratch; //Drawable scratch;
//scratch = getContext().getResources().getDrawable(
// R.drawable.icon); canvas.drawColor(Color.BLACK);
//scratch.draw(canvas); int origin = 0;
scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5);
canvas.drawBitmap(scratch, origin, origin, null);
int width = scratch.getWidth(); int height = scratch.getHeight();
scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3);
canvas.drawBitmap(scratch, origin + width, origin - 32, null);
[Code]
View 3 Replies
View Related
Apr 9, 2010
I only have my clock and a folder on the home screen, have 2 other screans one is net stuff, and the other one is music, What widgets and stuff do you have on your Droid or Droid Eris?
View 5 Replies
View Related
Jun 24, 2010
I've never had a smartphone YET, but my daughter has a Droid and says she hates that when talking on it, her cheek touches the screen and changes stuff while talking. She's new to the phone itself, so is she doing something wrong or is this just a con of smartphones? Or is this a Droid thing and not an EVO thing?
View 13 Replies
View Related
Oct 7, 2010
I have follow an example of an opengl application and I don't know why is this thing happening...I have a GLSurfaceView with it's corresponding renderer drawing a triangle. But, instead of getting the whole view on screen, I have just the upper half, and it's also duplicated as you can see on the picure. I'm using a Nexus One.
View 3 Replies
View Related
Jun 10, 2010
So far, I love the Evo, but I am having three problems with it. And they are getting annoying. First off, some applications will randomly terminate. It started out being regular downloaded applications that would just end. Whatever, it was bearable albeit annoying. But now, sometimes important applications like "Touch Screen" (I don't think that's the exact name) are starting to terminate randomly. That made it so that I couldn't text (rebooting the phone restarted the application).Two, I seem to manage to accidentally press the screen in a random place just about once per minute when I'm holding the phone. It's getting to the point where I feel like it's starting to push random buttons when I just press the sides of the phone. I don't know, it's tough to describe. Also, there seems to be some other shortcut screen that pops up every so often. It's a small box in the middle of the screen that shows my six most recently used apps. I have no idea why it pops up, or how, but I would actually like to use it if I could figure out how to do it.
Three,lastly, it seems to lock up a lot. It just freezes, just like a computer would. It's probably done this about ten times now.So is anyone else having any problems like this? It's starting to get very annoying. Big blemishes for such an amazing phone... it makes me sad to think this has so many interfering problems.
View 3 Replies
View Related
Oct 23, 2009
I've just dusted off an application I did for Android half a year ago. I upgraded to the latest SDK and Eclipse ADT. After some struggeling I get the application to run again. When I debug it I can see that all the right code are executed the right way. The application shows a OpenGL surface and animates stuff on it. It used to work perfectly (I even have it running on my HTC Magic device), but in the new emulator the screen is just white?
View 11 Replies
View Related
Apr 7, 2010
For some reason my code here (this is the entire thing) doesnt actually render anything besides a red screen..
can anyone tell me why?
CODE:.................
View 2 Replies
View Related
Feb 9, 2010
I am very new to OpenGL ES. I am implementing some demo app to load multiple textures on the screen. For demo purpose I have loaded 2 textures in 2 different locations on the screen using glTranslatef() and glBindTextures() twice. Now I am able to see 2 different images on the screen. Now I want to move one particular texture across the screen using mouse.
View 2 Replies
View Related
Feb 25, 2009
Single Threaded OpenGL game ! (check bottom, you can download and use the helper class) Lighting disabled ! Depth Buffer disabled ! Culling enabled ! Textures disabled !
Just 176 integers (x,y values only) making 88 vertexes along with 132 index numbers making "44 triangles only"
Framerates I get is
with GL_BLENDING disabled - 145 fps approx only! enabled - 110 fps approx only!
I have the screenshot of exact code in the draw function here.. just 2 damn lines ! I have hidden only the comments.. click here to see it http://prasna991.googlepages.com/drawframe.png
variable details in the 2 lines of code =========================== ipts = 176 elements (only x and y for each vertex) totallinetriangles * 3 = 176 lineindexes = 132 elements - type "short"
Here is the screenshot of output drawing and how it will look like http://prasna991.googlepages.com/screen.png
OpenGL single threaded Initialization Helper ================================ Here is my OpenGL helper class.. makes the OpenGL initialization for newbies a cakewalk http://prasna991.googlepages.com/OpenGLHelperclass.txt
I tested by rendering on the touch event only.. frame rate drops only when u touch and drag and here I have just tested by tapping and releasing gently on the emulator and on the device
Is this the device limitations ? So graphics is actually a lot lot lot slower than on iPhone ?
View 8 Replies
View Related
Jul 24, 2010
I would like to be able to use the OpenGL API from both Java and C (via NDK).
In Java, there is a GL object passed, which has all GL methods on it.
In C, you just talk to the native library.
In a single onDrawFrame callback (for which Java is passed a GL), can I use methods on the GL object, and also call NDK methods which access the openGL library?
In other words, is the GL object just a wrapper for the same instance of the native library?
View 3 Replies
View Related
Jan 15, 2010
I connect to my works Exchange server using EAS (I think, it was the default) and it syncs with my mail automagically as stuff comes in. I'd really like to find a way to automatically delete stuff on the Hero as I delete stuff on the exchange server. Is there a way to do this without involving another program?
View 1 Replies
View Related
Nov 2, 2009
Dear all, I want to implement the transition effect ( transparent with Z axis ) when user slip the android home to change home page. therefore, I plan to launch the new activity that is implemented by OpenGL ES to perform this effect. However, i encounter a problem that the screen/display is dark momentarily when launching the OpenGL ES activity.
View 3 Replies
View Related
Mar 21, 2010
How do I use gl.gluUnproject in my OpenGL ES 1.1 android app to determine what is selected when the user touches the screen?
My understanding is that the touch event results in a line and I have to find the first "thing" it intersects with.
Are there any tutorials on how to do this?
View 4 Replies
View Related
Sep 18, 2009
I've been working on a game framework for a little while, and while its far from perfect, I've put the current version online. To be honest, I haven't used much OpenGL in the past. Before last week I had never tried using it. If anyone would like to take a look, please do, I'd appreciate all the help possible on speeding it up. There are many features I have in mind and am planning at the minute, but so far it supports:
# Texture and Sprite management # Text, using TTF fonts # Organised layers # Two audio management classes, one optimized for music, the other for sound effects # Sprite dynamics (acceleration, terminal velocity, collisions) # Animation # Handlers to manage events fired through movement, animation, screen touches, accelerometer input, device shaking and collisions # Several minor features aimed at speeding development, such as screen settings and vibration.
View 1 Replies
View Related
Nov 4, 2009
I was watching a video on Android 2.0 (from the Google Conference, I believe) and the presenter show a feature that allowed you to pull up your contact list and simply start "drawing" the letters of the contact you are looking for and it will jump right to it, rather than having to scroll down. For example you would draw "e" then "r" and it would jump right to Eric.
I haven't seen this discussed anywhere else when testing the phone, so I thought either this feature didn't make it or it needs to be enabled or something.
Anyone else seen or know anything about this?
View 5 Replies
View Related
May 25, 2010
I was wondering if there is any 3D scene graph toolkit available or at least in development for Android? I could not find anything, assuming that all existing solutions for Java won't run on the Android platform.
View 3 Replies
View Related