yangweigbh / Libgdx-CardBoard-Extension

Android CardBoard SDK development using Libgdx
67 stars 16 forks source link

What module are you rendering in? #6

Open snapfractalpop opened 8 years ago

snapfractalpop commented 8 years ago

@yangweigbh I noticed that your extension has rendering directly in the android module (instead of the core module). Was there a reasoning behind deviating from the typical structure of a LibGdx app?

Or am I just doing something wrong? I cannot seem to get my project to work.

yangweigbh commented 8 years ago

actually you have the libgdx core module included(in the gradle build script). As the libgdx core and android module is included, we don't have to follow the typical structure of libgdx app. So what's your problem, can you please give more detail?

xeoshow commented 8 years ago

I think the concern here is about cross platform? Should it support both android and iOS?

snapfractalpop commented 8 years ago

@yangweigbh as @xeoshow mentions, I have my codebase structured the typical LibGDX way for cross platform support. I'm wondering what would be required to get your extension to work with such a structure.

Cross platform is nice for several reasons (even if google cardboard sdk isn't ready for integration with LibGDX on iOS, desktop or web:

I began trying to create an abstract class called CardboardApplicationAdapter which implements CardboardApplicationListener (an analogue to ApplicationAdapter, which implements ApplicationListener). The problem is, I don't know where this would go. I believe it belongs in core, but the methods onNewFrame, onDrawEye, and onFinishFrame have arguments HeadTransform, Eye, and Viewport respectively, which are not present in core (only the android module).

Is an interface (for cardboard) necessary in core for this to work?

Do you have any advice on how to proceed? I'm interesting in contributing to this project, and could make any such additions available as PRs, but I'd like to confirm that this is a sane approach. What are your thoughts?

EtK2000 commented 7 years ago

If this is still an issue, I can write code you can add into the main module that will interface well with this. Do remember, this is a backend, and it's not capable of porting your render code to its format well (due to cameras and transforms).

If you want to write the code yourself, essentially extend the class you're rendering from (for example Screen) so that the render() method calls a render(Matrix4) function that you do the actual rendering in. In your desktop you'll need to give it the camera's matrix, and in cardboard you'll give it the eye's matrices.