OpenGL ES/ iPhone 开发问题 - 第一款游戏

发布于 2024-12-12 18:00:01 字数 665 浏览 0 评论 0原文

我目前正在使用 openGLES 开发我的第一个 iPhone 游戏 - 太棒了!热爱它的每一分钟。不过我有几个问题:

  1. 我想制作一个粒子系统 - 最快的方法是什么?我想我可以创建一个可变的粒子对象数组,但是每个粒子都必须从 NSObject 派生,对吗?这似乎带来了相当大的开销..有更好的方法吗?过去,在 C++ 中,我使用了极其简单的粒子对象的向量,并将死粒子交换到末尾,并在需要新粒子时重用它们 - 我可能会在这里做同样的事情。只是担心(也许不公正)效率。

  2. 如何更改 OpenGL 的坐标系,以允许我使用 0 屏幕尺寸作为单位,而不是默认的 -1 到 1? (例如,使用点 {-1,0,0, 1,0,0, 0,1,0} 的简单顶点列表将形成一个三角形,其中斜边沿整个中心水平轴延伸)< /p>

  3. < 我根本无法在 1.1 中使用着色器,但是 2.0 将它们用于一切我有什么理由坚持使用 1.1 吗?

  4. 有充分的理由完全用 OpenGL 创建 GUI 吗?或者我可以很好地使用标准系统吗? (例如使用 GUI 元素创建 xib 文件)

  5. 由于我刚刚开始,OpenGL ES 是否存在通常伴随的常见陷阱?我并不是真的希望这是一个开放式的,我试图根除任何使该规范的许多新用户绊倒的具体内容。

I'm currently working on my first iPhone game with openGLES- it is amazing! Loving every minute of it. However I have a couple questions:

  1. I would like to make a particle system- what is the fastest way to do this? I would imagine that I could just make a mutable array of particle objects, however each particle would then have to be derived from NSObject, correct? This seems like it comes with quite a bit of overhead.. Is there a better way? In the past, with c++ I've used a vector of extremely simple particle objects, and swapped the dead particles to the end, and reuse those when I need a new particle- I'll likely do the same here. Just worried (perhaps unjustly) about efficiency.

  2. How do I change the coordinate system of OpenGL to allow me to use 0-screensize as units instead of the default -1 to 1? (for instance, a simple vertex list using the points {-1,0,0, 1,0,0, 0,1,0} would make a triangle in which the hypotenuse stretched along the entirety of the center horizontal axis)

  3. It looks as though I can't use shaders at all with 1.1, but 2.0 utilizes them for everything is there any reason for me to stick with 1.1?

  4. Is there good reason to create my GUI completely in OpenGL? Or would I be well served to use the standard system? (such as creating a xib file with GUI elements)

  5. Since I'm just beginning are there any common pitfalls that typically accompany OpenGL ES? I don't really intend this to be open-ended, I'm attempting to root out anything concrete that trips up a lot of new users of the specification.

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

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

发布评论

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

评论(1

分開簡單 2024-12-19 18:00:01
  1. 我使用常规的 C 结构,NSObjects 在这种情况下是猪,在 3G 上我可以得到 2000 个粒子,使用 C 结构没有问题,少于 200 个对象。
  2. 这样的东西会给你一个 480x320 坐标系:

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    CGRect 矩形 = self.view.bounds;
    if (highRes && (视网膜 == 1)) {
        glOrthof(0.0, 矩形大小.宽度/2, 0.0 , 矩形大小.高度/2, -1, 1000.0);
    } 别的 {
        glOrthof(0.0, 矩形大小.宽度, 0.0 , 矩形大小.高度, -1, 1000.0);    
    }
    
  3. 仅支持旧设备 < 3GS。
  4. 取决于你想要的外观和工作。如果你需要文本输入,记住你必须在 openGL 中从头开始,还有字体渲染等。有时你可以混合两者(比如打开一个带有文本框等的抽屉),但是当混合 opengl 上发生的事情时,必须是很简单。
  5. 有很多陷阱,最好有一个好的教程,这样你就掌握了基础知识,从设置视图到获得模型纹理,之后如果出现问题你可以参考它。

祝你好运,让它成为一个有趣的游戏:-)

  1. I use regular C structs for mine, NSObjects are hogs in this context, on a 3G I can get 2000 particles no problem with C structs, less than 200 with objects.
  2. Something like this will get you a 480x320 coordinate system:

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    CGRect rect = self.view.bounds;
    if (highRes && (retina == 1)) {
        glOrthof(0.0, rect.size.width/2, 0.0 ,  rect.size.height/2, -1, 1000.0);
    } else {
        glOrthof(0.0, rect.size.width, 0.0 ,  rect.size.height, -1, 1000.0);    
    }
    
  3. Only to support older devices < 3GS.
  4. Depends on the looks and work you want. If you need text input remember you have to do it from scratch in openGL, also font rendering, etc. Sometimes you can mix both (say open a drawer with you text boxes and such), but when mixing whats happening on opengl has to be very simple.
  5. Lots of pitfalls, better get a good tutorial so you have the basics covered, something that goes from setting up your view to getting an model textured, after that you can refer back to it if something goes awry.

Good luck, make it a fun game :-)

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