Android 中的 OpenGL

发布于 2024-11-09 06:39:31 字数 380 浏览 0 评论 0原文

我正在开发地图引擎。我想让用户旋转地图。如果我在画布上通过标准绘图进行旋转,它会减慢手机速度,并且通过标准画布 API 旋转的地图图块看起来很糟糕。

我在网上找到了一些Android的OpenGL框架。但他们都没有做我想要的。其中大多数无法在 OpenGL Activity 中使用 Android 标准组件。

我想将 OpenGL 绘制的自定义视图放置到布局组件(例如 LinearLayout)中。因此,我可以将所有内容(包括 OpenGL 布局)放入 Activity 中。我确信可以通过使用标准 Android OpenGL API 来完成。但是OpenGL绘制对我来说太难了。

是否有任何 OpenGL 框架可以让我通过 OpenGL 绘制自定义视图?我需要的只是一个支持简单绘图的框架。

I am working on a map engine. I would like to let user rotate the map. If I do the rotation by standard drawing on canvas, it will slow down the phone and the map tiles rotated by standard canvas API looks bad.

I found some OpenGL frameworks for Android on the Internet. But none of them do what I want. Most of them cannot use Android standard components within the OpenGL Activity.

I want to put a custom view that drawn by OpenGL to a Layout component (eg, LinearLayout). Thus, I can put everything (including OpenGL layout) to a Activity. I am sure that it can be done by using standard Android OpenGL API. But the OpenGL draw is too difficult to me.

Is it any OpenGL framework to let me draw a custom view by OpenGL? All I need is a framework that supports simple drawing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

苏佲洛 2024-11-16 06:39:31

它称为 GLSurfaceView。
在我的一个项目中,我有这样的内容:

public static GLView glSurfaceView;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    glSurfaceView = new GLView(this);

    setContentView(glSurfaceView);
}

确保您创建的类扩展了 GLSurfaceView。

public class GLView extends GLSurfaceView 

在 GLView 类中,您必须具有以下内容:

private GLRenderer _renderer;
public GLView(Context context) {
    super(context);
    _renderer = new GLRenderer(context);
    setRenderer(_renderer);
}

GLRenderer 类将实现 GLSurfaceView.Renderer

至少这就是我认为您要问的。如果没有在下面发表评论,我会尽力更好地回答。

Its called GLSurfaceView.
In one of my projects I have this:

public static GLView glSurfaceView;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    glSurfaceView = new GLView(this);

    setContentView(glSurfaceView);
}

Make sure the class you make extends the GLSurfaceView.

public class GLView extends GLSurfaceView 

In the GLView class you will have to have this:

private GLRenderer _renderer;
public GLView(Context context) {
    super(context);
    _renderer = new GLRenderer(context);
    setRenderer(_renderer);
}

The GLRenderer class will implement GLSurfaceView.Renderer

Atleast this is what I think you are asking. If not post comment below and I will try and answer it better.

平生欢 2024-11-16 06:39:31

很遗憾您放弃了 OpenGL,我最近发现了它,发现它比标准绘图更好。使用纹理而不是将图像保留为位图对象可以更好地利用设备内存(尤其是在蜂窝设备之前),并且如果您使用正交投影,则无需为 OpenGL 花哨的 3D 内容而烦恼。另外,您不再需要(尽可能)关心各种设备的分辨率,这样您放置在屏幕上的所有内容都是比例良好的(您仍然需要关心宽度和高度的比例,但这要好得多)。

It's a shame that you gave up on OpenGL, I've recently discovered it and find it heaps better then doing standard drawing. Using textures instead of keeping images as Bitmap objects takes much better advantage of device's memory (especially on the pre Honeycomb devices) and if you use an orthogonal projection you don't need to bother with a good portion of OpenGL's fancy 3d stuff. Plus, you no longer have to care (as much) about various devices resolutions so that all the stuff you put on screen is well proportioned (you still have to care about width and height ratio's but that's a lot better).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文