jPCT-AE - a 3d engine for Android > Support

way for a HUD

(1/1)

coersum:
Hi,

I found this online and figured I'd share it, I just started programing using JPCT-AE and having limited knowledge in java, I experiment a lot.
I wanted to add a HUD of some sort but didn't understand how to "blit" as I read here and there so I searched and found this, please let me know if this will bug or slow down the device:

in HelloWorld demo:

replace:

--- Code: ---mGLView = new GLSurfaceView(getApplication());
--- End code ---
with

--- Code: ---setContentView(R.layout.activity_main); //or whatever the layout you want to use
mGLView = (GLSurfaceView) findViewById(R.id.graphics_glsurfaceview1);
--- End code ---

remove

--- Code: ---setContentView(mGLView);
--- End code ---

now in your layout copy/paste:

--- Code: ---<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/graphics_frameLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <android.opengl.GLSurfaceView
        android:id="@+id/graphics_glsurfaceview1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    </android.opengl.GLSurfaceView>
    <LinearLayout
        android:layout_height="fill_parent"
        android:id="@+id/inventory"
        android:gravity="center"
        android:layout_width="fill_parent"
        android:orientation="vertical"
        android:visibility="gone">
    </LinearLayout>

    <LinearLayout
        android:id="@+id/HUD"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center|bottom"
        android:orientation="vertical" >

        <ImageButton
            android:id="@+id/imageButton1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/icon" />

    </LinearLayout>
</FrameLayout>
--- End code ---

After that play around with placements.

Source where I found it and what it does (2 overlays, 1 for inventory and 1 for hud).
http://stackoverflow.com/questions/8128896/mixing-android-views-and-glsurfaceview


Doing this will keep you from having to blit or making your own opengl, however I don't know enough to know if it will have any undesirable consequences, please let me know.

EgonOlsen:
You can do this, if you want to. As long as you get it working, everything should be fine. The engine itself doesn't care about this. "blit" means to use the blit-methods in FrameBuffer to create a hud from texture images by copying parts of them to the screen (=blit (block image transfer) them). This gui at http://www.jpct.net/forum2/index.php/topic,2471.msg22110.html#msg22110 is done that way for example.

Navigation

[0] Message Index

Go to full version