You can view a list of emulators via:
android list avd
Start the emulator with:
emulator -avd [emu name]
Place the apk into the android/tools directory, and install it with:
adb install [apk name].apk
Resubmit the previous command if you get this message:
* daemon not running. starting it now *
* daemon started successfully *
error: device offline
BASH: Running bash script from dos
Lets say you have something that ONLY runs in cygwin... ie. the Android NDK makefile
usually you'd call this with cygwin like so:
make APP=[app name]
instead, you could create a bash script (we'll call it _build) file that contains the following:
#!/bin/bash
make APP=$1 $2;
then call this bash script with the following:
bash _build [app name] [-B]
oh, to make sure this works, you'll have to set windows env. 'path' to include c:\cygwin\bin directory.
usually you'd call this with cygwin like so:
make APP=[app name]
instead, you could create a bash script (we'll call it _build) file that contains the following:
#!/bin/bash
make APP=$1 $2;
then call this bash script with the following:
bash _build [app name] [-B]
oh, to make sure this works, you'll have to set windows env. 'path' to include c:\cygwin\bin directory.
Android: adb shell
To manually kill a process that is running:
adb shell
In the shell, type:
ps
This will produce something like the following:
app_23 --- 19333 --- 19283 --- 840 --- 312 --- ffffffff --- com.sample.app
Kill the process with the PID:
kill 19333
adb shell
In the shell, type:
ps
This will produce something like the following:
app_23 --- 19333 --- 19283 --- 840 --- 312 --- ffffffff --- com.sample.app
Kill the process with the PID:
kill 19333
Android: Dirty build JNI
*EDIT
actually the problem was the JNI shared libraries in eclipse were out of sync with the actual. To solve this issue, simply do a refresh on the entire tree.
*EDIT
I ran into a weird dirty-build bug. Where even after I rebuilt the JNI shared library, it wouldn't load my new library onto the phone.
To solve:
- delete the application from the handset (settings > applications > manage...)
- delete the bin directory
- while you're at it delete the gen directory
- close the project
- delete the project
- import the project as new
at this point you will probably see a very annoying error that states:
"gen directory is missing" fix missing paths before continuing...
- build the application
- if android glitches and doesn't remove the error messages, make sure gen/bin were created by the previous step
- close the project
- delete the project
- import the project as new (AGAIN)
this time the error message should be gone.
actually the problem was the JNI shared libraries in eclipse were out of sync with the actual. To solve this issue, simply do a refresh on the entire tree.
*EDIT
I ran into a weird dirty-build bug. Where even after I rebuilt the JNI shared library, it wouldn't load my new library onto the phone.
To solve:
- delete the application from the handset (settings > applications > manage...)
- delete the bin directory
- while you're at it delete the gen directory
- close the project
- delete the project
- import the project as new
at this point you will probably see a very annoying error that states:
"gen directory is missing" fix missing paths before continuing...
- build the application
- if android glitches and doesn't remove the error messages, make sure gen/bin were created by the previous step
- close the project
- delete the project
- import the project as new (AGAIN)
this time the error message should be gone.
Regex: Eclipse Search & Replace
to convert #defines into java final vars...
#define DEFINE_VARIABLE 0x12AB
Search and replace:
#define -> public static final int
(0x[\dA-F]{4}) -> = \1;
Result:
public static final int DEFINE_VARIABLE = 0x12AB;
#define DEFINE_VARIABLE 0x12AB
Search and replace:
#define -> public static final int
(0x[\dA-F]{4}) -> = \1;
Result:
public static final int DEFINE_VARIABLE = 0x12AB;
JNI: Getting Started
Write something simple in a java class such as below:
class HelloWorld {
public native void print();
public static void main(String[] args) {
new HelloWorld().print();
}
static {
System.loadLibrary("HelloWorld");
}
}
Compile the java class
javac HelloWorld
Use javah to spit out the JNI header file
javah -jni -classpath "(path.to.src)" com.sample.HelloWorld
package com.sample;
class HelloWorld {
public native void print();
public static void main(String[] args) {
new HelloWorld().print();
}
static {
System.loadLibrary("HelloWorld");
}
}
Compile the java class
javac HelloWorld
Use javah to spit out the JNI header file
javah -jni -classpath "(path.to.src)" com.sample.HelloWorld
ANDROID: Pulling libraries from the android device
adb pull (file) (local)
for example, I pulled the system/lib to my local c:\libs
adb pull system/lib c:\libs
for example, I pulled the system/lib to my local c:\libs
adb pull system/lib c:\libs
UNIX: Debugging the contents of a Shared Object file
If you just wanted to see basic header info (not even that preceise), then you could use the following unix command to look into a shared object ((filename).so) file.
nm (directory)\(filename).so
If this is still not working. Try appending -C -D at the end like so:
nm (directory)\(filename).so -C -D
I found this info on some google forum:
http://www.mail-archive.com/.../msg00935.html
The guy also mentioned using the following configurations:
nm
nm (directory)\(filename).so -C -D
I found this info on some google forum:
http://www.mail-archive.com/.../msg00935.html
The guy also mentioned using the following configurations:
arm-none-linux-gnueabi-nm
arm-none-linux-gnueabi-objdump
ANDROID: Starting the Android emulator
here's how to start your android emulator via command prompt:
1. if you haven't already, create an AVD (android virtual device)
where the target id (ie. 4 for android 1.6) can be obtained via:
android list targets
2. list available AVDs
(android.tools.directory)\ android list avds
3. starting your AVD
(android.tools.directory)\emulator -avd
for more information goto:
http://developer.android.com/.../tools/avd.html
1. if you haven't already, create an AVD (android virtual device)
android create avd -n (name) -t (targetID) [-(option) (value)]
android list targets
2. list available AVDs
3. starting your AVD
for more information goto:
ANDROID: Installation errors
This is a part 2 to the previous post on installation.
During installation I received the following failure:
Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE]
You can turn on Logcat to debug the installation failure:
adb logcat
My Logcat yielded the following errors:
E/PackageParser( 74): Package com.website.mclass has no certificates at entry assets/; ignoring!
To solve this issue, you need to sign the apk file before installing. Here's how:
jarsigner -verbose -keystore (directory)\debug.keystore (directory)\(filename).apk androiddebugkey
The default passphrase is android
To verify the certification, you can again use jarsigner:
jarsigner -verify -verbose -certs (directory)\(filename).apk
The last command line printout should now read:
jar verified.
During installation I received the following failure:
Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE]
You can turn on Logcat to debug the installation failure:
adb logcat
My Logcat yielded the following errors:
E/PackageParser( 74): Package com.website.mclass has no certificates at entry assets/
To solve this issue, you need to sign the apk file before installing. Here's how:
jarsigner -verbose -keystore
The default passphrase is android
To verify the certification, you can again use jarsigner:
jarsigner -verify -verbose -certs (directory)
The last command line printout should now read:
jar verified.
ANDROID: Installing application
There are 2 ways to install a pre-built applications:
1. command prompt
adb install(directory)\(filename).apk
2. SD card
A. install the apk to the phone SD card
B. insert SD card to phone
C. goto Android Marketplace, search for Apps Installer application
D. open and click Install
E. open Apps Installer
F. select the application you want to install
G. click on install
1. command prompt
adb install
2. SD card
A. install the apk to the phone SD card
B. insert SD card to phone
C. goto Android Marketplace, search for Apps Installer application
D. open and click Install
E. open Apps Installer
F. select the application you want to install
G. click on install
ANDROID: adb shell commands
For the times you want to log onto the unix command prompt of the device itself, you want to use the following command:
adb shell
this will convert the prompt into:
#
now you can start using unix commands as usual:
ps = list all processes
kill = kill specific process
adb shell
this will convert the prompt into:
#
now you can start using unix commands as usual:
ps = list all processes
kill
OpenGL + OpenVG
Here's my findings on the 2 technologies:
Imagination Technologies:
AMD:
So... Theoretically the 2 technologies can only be combined if the following is satisfied: A single emulator/device, that supports BOTH OpenVG and OpenGL, sharing the same EGL libraries. In other words, the EGL must have support for BOTH OpenVG and OpenGL ES 2.0. The EGL is the key.
Imagination Technologies:
--------------------------------------------The two technologies are individually packaged, so there is no support for combining these 2 technologies at this time by imgtec.
| OpenVG emulator | OpenGL ES 2.0 emulator |
--------------------------------------------
AMD:
--------------------------AMD does not have a OpenVG emulator
| OpenGL ES 2.0 emulator |
--------------------------
So... Theoretically the 2 technologies can only be combined if the following is satisfied: A single emulator/device, that supports BOTH OpenVG and OpenGL, sharing the same EGL libraries. In other words, the EGL must have support for BOTH OpenVG and OpenGL ES 2.0. The EGL is the key.
-----------------------------------
| GL ES 2.0 | VG |
| ----------- |
| | | |
| | E G L | |
-----------------------------------
OpenGL: What is EGL
Taken from Khronos: http://www.khronos.org/egl/
EGL™ is an interface between Khronos rendering APIs such as OpenGL ES or OpenVG and the underlying native platform window system. It handles graphics context management, surface/buffer binding, and rendering synchronization and enables high-performance, accelerated, mixed-mode 2D and 3D rendering using other Khronos APIs.
EGL™ is an interface between Khronos rendering APIs such as OpenGL ES or OpenVG and the underlying native platform window system. It handles graphics context management, surface/buffer binding, and rendering synchronization and enables high-performance, accelerated, mixed-mode 2D and 3D rendering using other Khronos APIs.
OpenGL: Toggling the DepthMask
glDepthMask(GL_TRUE/GL_FALSE);
Sometimes in blending, you will want to inter-mix opaque & translucent objects.
Here's the 2 obvious scenarios:
1. If the opaque object is in front of translucent object, we don't need to blend
2. If the translucent object is in front of the opaque object, we need to blend
There's a easy way to ensure the blending always works as expected. This is to render the opaque object FIRST with the writable depth buffer. And then render the translucent object with a read-only depth buffer. This can be done by using glDepthMask.
This way the renderer will automatically compare the translucent object's depth position with that of the read-only opaque object depth position. Blending is done only when needed, and buffer remains unchanged.
Sometimes in blending, you will want to inter-mix opaque & translucent objects.
Here's the 2 obvious scenarios:
1. If the opaque object is in front of translucent object, we don't need to blend
2. If the translucent object is in front of the opaque object, we need to blend
There's a easy way to ensure the blending always works as expected. This is to render the opaque object FIRST with the writable depth buffer. And then render the translucent object with a read-only depth buffer. This can be done by using glDepthMask.
This way the renderer will automatically compare the translucent object's depth position with that of the read-only opaque object depth position. Blending is done only when needed, and buffer remains unchanged.
OpenGL: Blending Formula
Taken from the Red Book:
Let the source and destination blending factors be (Sr, Sg, Sb, Sa) and (Dr, Dg, Db, Da), respectively, and the RGBA values of the source and destination be indicated with a subscript of s or d. Then the final, blended RGBA values are given by
Let the source and destination blending factors be (Sr, Sg, Sb, Sa) and (Dr, Dg, Db, Da), respectively, and the RGBA values of the source and destination be indicated with a subscript of s or d. Then the final, blended RGBA values are given by
(RsSr+RdDr, GsSg+GdDg, BsSb+BdDb, AsSa+AdDa)
Expanded:
red = Red(src)*Red(srcBlendFactor) +
Red(dest)*Red(destBlendFactor)
green = Green(src)*Green(srcBlendFactor) +
Green(dest)*Green(destBlendFactor)
blue = Blue(src)*Blue(srcBlendFactor) +
Blue(dest)*Blue(destBlendFactor)
alpha = Alpha(src)*Alpha(srcBlendFactor) +
Alpha(dest)*Alpha(destBlendFactor)
OpenGL: Rendering Pipelines
Here's 2 flow-charts explaining the 2 types of rendering pipelines.


Here are some typical uses for the programmable function pipeline:
Done within the Vertex stage:
- vertex displacement mapping
- morphing
- particle systems
Done within the Pixel stage:
- per pixel lighting
- toon shading (I'm guessing this is cell-shading)
- parallax mapping
- bump mapping
- custom texture filtering
- color kernel applications


Here are some typical uses for the programmable function pipeline:
Done within the Vertex stage:
- vertex displacement mapping
- morphing
- particle systems
Done within the Pixel stage:
- per pixel lighting
- toon shading (I'm guessing this is cell-shading)
- parallax mapping
- bump mapping
- custom texture filtering
- color kernel applications
Win32: Setting up OpenVG
I'm completely new to the OpenVG sphere, so this is the very basic of basics. How to run the openVG RI from Khronos site...
First, I downloaded the RI from the site at: http://www.khronos.org/files/openvg_1_0_ri
Unzip the package, and attempt to run the bin\wind32\tiger.exe file
If you got a MSVCRTD.dll is missing, this is because you aren't using Visual Studio 6 (or some other prehistoric version).
I don't recommend this, but you CAN find MSVCRTD.dll online, and throw it into your System32 directory. I found the dll inside some symbian directory... threw it in my System32 directory, and the tiger popped up like a charm... after 2 minutes of loading...
The second, and preferred method, is to recompile the project using your version of Visual Studio (mine is V9). Well I got stumped again when I tried compiling. The application couldn't find GL\glext.h
To solve this download the glext.h from: http://www.opengl.org/resources/faq/technical/extensions.htm
Throw this file inside the VC/include/GL folder (create the GL directory if it doesn't already exist).
The full path of said directory is at (for Visual Studio V9):
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\GL
Inside this directory I now have the following:
- glut.h
- glext.h
- glxext.h
- wglext.h
If you also need glut.h, you should refer to an earlier post I wrote about setting up GLUT on your system.
First, I downloaded the RI from the site at: http://www.khronos.org/files/openvg_1_0_ri
Unzip the package, and attempt to run the bin\wind32\tiger.exe file
If you got a MSVCRTD.dll is missing, this is because you aren't using Visual Studio 6 (or some other prehistoric version).
I don't recommend this, but you CAN find MSVCRTD.dll online, and throw it into your System32 directory. I found the dll inside some symbian directory... threw it in my System32 directory, and the tiger popped up like a charm... after 2 minutes of loading...
The second, and preferred method, is to recompile the project using your version of Visual Studio (mine is V9). Well I got stumped again when I tried compiling. The application couldn't find GL\glext.h
To solve this download the glext.h from: http://www.opengl.org/resources/faq/technical/extensions.htm
Throw this file inside the VC/include/GL folder (create the GL directory if it doesn't already exist).
The full path of said directory is at (for Visual Studio V9):
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\GL
Inside this directory I now have the following:
- glut.h
- glext.h
- glxext.h
- wglext.h
If you also need glut.h, you should refer to an earlier post I wrote about setting up GLUT on your system.
3D: Shaders
did some research on shaders:
FROM: http://en.wikipedia.org/wiki/Shader
A shader is a set of software instructions, which is used to calculate rendering effects on GPU. Shaders can program the GPU's programmable rendering pipeline (as opposed to Fixed Function Pipeline, or FFP). Shaders replaces the FFP.
Shaders help determine the traits of a vertex or pixel. There are 3 types of shaders:
1. Vertex shaders: these are run once per vertex. manipulates position, color and tex-coordinates of vertices.
2. Geometry shaders: can add or remove vertices from a mesh (caused by plane-clipping, etc).
3. Pixel/fragment shaders: determines trait of a single pixel (color, z, alpha). typically used in scene lighting, bump-mapping, color toning.
Programming shaders can be done in the following 3D languages: OpenGL, DirectX.
1. DirectX for ATI uses HLSL (high level shader language)
2. DirectX for NVidia uses Cg (C for graphics, very similar to HLSL)
3. OpenGL uses GLSL (OpenGL Shading Language)
FROM: http://en.wikipedia.org/wiki/Shader
A shader is a set of software instructions, which is used to calculate rendering effects on GPU. Shaders can program the GPU's programmable rendering pipeline (as opposed to Fixed Function Pipeline, or FFP). Shaders replaces the FFP.
Shaders help determine the traits of a vertex or pixel. There are 3 types of shaders:
1. Vertex shaders: these are run once per vertex. manipulates position, color and tex-coordinates of vertices.
2. Geometry shaders: can add or remove vertices from a mesh (caused by plane-clipping, etc).
3. Pixel/fragment shaders: determines trait of a single pixel (color, z, alpha). typically used in scene lighting, bump-mapping, color toning.
Programming shaders can be done in the following 3D languages: OpenGL, DirectX.
1. DirectX for ATI uses HLSL (high level shader language)
2. DirectX for NVidia uses Cg (C for graphics, very similar to HLSL)
3. OpenGL uses GLSL (OpenGL Shading Language)
Subscribe to:
Posts (Atom)