Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - dl.zerocool

Pages: 1 ... 3 4 [5] 6 7
Projects / Alpha version of Benchmark, was: GUI example anyone?
« on: May 26, 2010, 01:03:20 am »
Hi, Here are some results, ps : If you have new version of JPCT I would like to try them because Tuesday we have to
give our application to our teacher, it's the dead line. :P

I'll publish what we have done, in the forum at the same time, but I'm too busy at moment to deliver a stable version.

Nexus one : Froyo 2.2 Results :  (1st test)

Fillrate ST/MT : 10.05/9.14 Megapixel/sec
High object count: 18.24 fps
Multiple lights: 45.05 fps
High polygon count: 22.60 fps

(I really like the high poly and multiple light test ;) )

(2nd test)
Fillrate ST/MT : 10.11/9.11 Megapixel/sec
High object count: 17.94 fps
Multiple lights: 45.37 fps
High polygon count: 22.43 fps

Results are pretty stable

Support / [Tips] Android, augmented reality 3D with JPCT + Camera.
« on: May 11, 2010, 08:06:35 pm »
All the code provide here is free to use and I'm not responsible for what you use it for.

I received a question that I found very interesting to share with everybody.

There is very few information about this subject on android and how to setup a correct working layout.

So in this topic, I'll answer the simple question : How to use Android Camera and JPCT-AE as a render that overlays the camera.
(Augmented reality concept)

You have to code your own engines around it to get it fully functional.

First we need to set up an XML layout.
Our minimum requirement is a glSurfaceView that's where we will draw 3D(JPCT engine),
and a SurfaceView to draw the camera preview.

Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android=""
android:orientation="vertical" android:layout_width="fill_parent"

<android.opengl.GLSurfaceView android:id="@+id/glsurfaceview"
android:layout_width="fill_parent" android:layout_height="fill_parent" />

<SurfaceView android:id="@+id/surface_camera"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_centerInParent="true" android:keepScreenOn="true" />

This is to Initialize the window and the glSurfaceView.
Code: [Select]
       // It talks from itself, please refer to android developer documentation.

        // Fullscreen is not necessary... it's up to you.

        // attach our glSurfaceView to the one in the XML file.
glSurfaceView = (GLSurfaceView) findViewById(;

Now let's create the camera and the engine.
This is an example of my own code, so perhaps it won't fill exactly your needs,
but you can be inspired by this one.

The following code is pretty easy to understand,
I create a new camera and I give a render to my glSurfaceView
and of course set the Translucent window  (8888) pixel format and depth buffer to it.
(Without that your glSurfaceView will not support alpha channel and you will not see the camera layer.)

So basically :
1) Create the camera view.
2) Set up the glSurfaceView.
3) Set a Render to glSurfaceView.
4) Set the correct pixelformat to the glSurfaceView holder.

Code: [Select]
cameraView = new CameraView(this.getApplicationContext(),
(SurfaceView) findViewById(, imageCaptureCallback);
catch(Exception e){
// Translucent window 8888 pixel format and depth buffer
glSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);

        // GLEngine is a class I design to interact with JPCT and with all the basic function needed,
        // create a world, render it, OnDrawFrame event etc.
        glEngine = new GLEngine(getResources());

game = new Game(glEngine, (ImageView) findViewById(, getResources(), this

// Use a surface format with an Alpha channel:

// Start game

Here is my CameraView class :
Code: [Select]
package com.dlcideas.ARescue.Camera;


import com.threed.jpct.Logger;

import android.content.Context;
import android.hardware.Camera;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class CameraView extends SurfaceView implements SurfaceHolder.Callback {
     * Create the cameraView and
     * @param context
     * @param surfaceView
    public CameraView(Context context, SurfaceView surfaceView,
   ImageCaptureCallback imageCaptureCallback) {

// Install a SurfaceHolder.Callback so we get notified when the
// underlying surface is created and destroyed.
previewHolder = surfaceView.getHolder();

// Hold the reference of the caputreCallback (null yet, will be changed
// on SurfaceChanged).
this.imageCaptureCallback = imageCaptureCallback;

     * Initialize the hardware camera. holder The holder
    public void surfaceCreated(SurfaceHolder holder) {
camera =;
try {
} catch (IOException e) {
   // TODO Auto-generated catch block

    public void surfaceDestroyed(SurfaceHolder holder) {

    public void surfaceChanged(SurfaceHolder holder, int format, int width,
   int height) {
if (previewRunning)

Camera.Parameters p = camera.getParameters();
p.setPreviewSize(width, height);
// camera.setParameters(p);

try {
} catch (IOException e) {
previewRunning = true;
Logger.log("camera callback huhihihihih", Logger.MESSAGE);
imageCaptureCallback = new ImageCaptureCallback(camera, width, height);


    public void onStop() {
// Surface will be destroyed when we return, so stop the preview.
// Because the CameraDevice object is not a shared resource, it's very
// important to release it when the activity is paused.
previewRunning = false;

    public void onResume() {
camera =;
previewRunning = true;

    private Camera camera;
    private SurfaceHolder previewHolder;
    private boolean previewRunning;
    private ImageCaptureCallback imageCaptureCallback;


Support / Re: Version updates!
« on: May 10, 2010, 09:54:24 pm »
So your functions aren't threaded.
That's what I was asking :).

I found a solution so, just start the loading screen before starting loading the models, then after all loads and builds stop it.


I do that in a thread and the animation screen is a thread too.

Thank you.

ps: sorry lately I've not been answering quite fast, but I'm overloaded at school with projects and tests, it's the end of my 2nd year of engineer in 7weeks...
So I've been very busy.

Support / Re: Version updates!
« on: May 05, 2010, 10:14:43 am »

I didn't find a way to check if all the models are build and ready to draw.
Is it possible to implement this feature ? So we will be able to do a loading screen (while the resources are being loaded).

Thank you.

Best Regards

"A returned value would be great for example"

I don't know if you threaded your buildObject that's why I'm asking for it.

Support / Re: Activity switching
« on: May 05, 2010, 10:00:49 am »

Opengl context is definitely lost, you were true!

Thank you, so I reload the models each time now :P

Support / Activity switching
« on: April 30, 2010, 12:08:09 am »

Well I'm confronting a problem but I'm unsure from where it comes.
I pass few hours checking around my code and found nothing yet.

So I wanted to know if you are encountering the same problem as me.

If you run engine, add objects etc.. then push the HOME button,
then with multi task selection return back to game are you models and textures still there ?

When I do this, I loose all my models and textures.

Thank you in advance for help, if don't come from JPCT I'll work harder to find what's wrong on my side.

Best regards.

Support / Re: Started to write some game prototype...
« on: April 27, 2010, 09:11:36 pm »
I understand, but our goal is to imitate augmented reality without using picture detection.
We just use sensors to move around :) 

Of course it's less precise, but lot's more easy in the time we have :)

Support / Re: Started to write some game prototype...
« on: April 27, 2010, 05:45:48 pm »
At the moment I'm fighting with sensors...
I don't understand how to detect if the screen is looking to sky (user looking to the ground) and when the phone is turned screen down (user looking to sky).
Using sensors is real mess !

found something very useful to understand how it works.

Support / Re: Started to write some game prototype...
« on: April 27, 2010, 03:20:20 pm »
it looks great ! :)

Support / Re: Version updates!
« on: April 15, 2010, 02:23:27 pm »
Yeah another update :P

About the Textures : Certainly, anyway I'm no more using textures so it's not the problem, thank you for the check :)
I'm using materials instead. It's enough for what I'm doing at moment.

Support / Re: Version updates!
« on: April 14, 2010, 02:44:31 pm »
This low end phones are definitely built with no standard.

About exception, I'll take a look when I'll have time at what you told me, but at moment I can't.
I understand and respect your point of view, so I'll continue using without throws.

Another question is, are you sure that TextureManager flush works correctly ? Because sometimes I got the error :
Code: [Select]
04-14 14:26:52.923: ERROR/AndroidRuntime(4318): java.lang.RuntimeException: [ Wed Apr 14 14:26:52 Europe/Zurich 2010 ] - ERROR: A texture with the name 'grassy' has been declared twice!
Here is how I do things:
Code: [Select]
gameModels.add(new GameModels(Primitives.getPlane(20, 30), new Texture(
textureManager.addTexture("grassy", gameModels.get(0).modelTexture);

Code: [Select]
private class GameModels
public GameModels(Object3D model, Texture modelTexture)
this.model = model;
this.modelTexture = modelTexture;

public Texture modelTexture;
public Object3D model;
Is there something wrong ?

Support / Re: Version updates!
« on: April 14, 2010, 12:39:50 pm »
Great, I don't see much difference since I'm working at 30 or 60fps depending if I'm using the camera or not. (With the Nexus One)

But it's always nice to see such improvement.
But it does improve the fps on the Samsung Spica, the latest update made the fps go from 5 to 20~ so it's really great :)

I just wanted to ask if it's possible to next release to add in front of functions that throw any exception
the code
Code: [Select]
throws Exception or Better
Code: [Select]
throws SpecificException .

This really would help to Dev/Debug and avoid exceptions randomly uncaught that make the program FC.

Support / Re: Support for Android 2.1?
« on: April 13, 2010, 12:26:16 am »
Take care, I was using a 2.1 hero before I bought the Nexus one.

Please consider visiting your rom forum or change your rom to another one wich include OpenGL driver and libs.
You'll find all the help you need on their forums (Specific devices).

AE runs fine on 2.1, no problems here.

Support / Re: Version updates!
« on: April 09, 2010, 05:14:44 pm »
Really happy to see all this updates :)

Support / Re: First alpha version released
« on: April 02, 2010, 06:35:47 pm »
I'll try enabling VBO to see if there's any change on my phone (since I'm always on landscape mode, I don't care about that problem)

Pages: 1 ... 3 4 [5] 6 7