• <i id='M47dH'><tr id='M47dH'><dt id='M47dH'><q id='M47dH'><span id='M47dH'><b id='M47dH'><form id='M47dH'><ins id='M47dH'></ins><ul id='M47dH'></ul><sub id='M47dH'></sub></form><legend id='M47dH'></legend><bdo id='M47dH'><pre id='M47dH'><center id='M47dH'></center></pre></bdo></b><th id='M47dH'></th></span></q></dt></tr></i><div id='M47dH'><tfoot id='M47dH'></tfoot><dl id='M47dH'><fieldset id='M47dH'></fieldset></dl></div>
    <tfoot id='M47dH'></tfoot>
      <bdo id='M47dH'></bdo><ul id='M47dH'></ul>
  • <small id='M47dH'></small><noframes id='M47dH'>

    <legend id='M47dH'><style id='M47dH'><dir id='M47dH'><q id='M47dH'></q></dir></style></legend>

        OS X 上 Eclipse 中的 OpenGL 和 GLUT

        时间:2023-09-17
        <tfoot id='ZMz5C'></tfoot>
        • <bdo id='ZMz5C'></bdo><ul id='ZMz5C'></ul>

            <small id='ZMz5C'></small><noframes id='ZMz5C'>

              <tbody id='ZMz5C'></tbody>

              1. <legend id='ZMz5C'><style id='ZMz5C'><dir id='ZMz5C'><q id='ZMz5C'></q></dir></style></legend>

                • <i id='ZMz5C'><tr id='ZMz5C'><dt id='ZMz5C'><q id='ZMz5C'><span id='ZMz5C'><b id='ZMz5C'><form id='ZMz5C'><ins id='ZMz5C'></ins><ul id='ZMz5C'></ul><sub id='ZMz5C'></sub></form><legend id='ZMz5C'></legend><bdo id='ZMz5C'><pre id='ZMz5C'><center id='ZMz5C'></center></pre></bdo></b><th id='ZMz5C'></th></span></q></dt></tr></i><div id='ZMz5C'><tfoot id='ZMz5C'></tfoot><dl id='ZMz5C'><fieldset id='ZMz5C'></fieldset></dl></div>

                • 本文介绍了OS X 上 Eclipse 中的 OpenGL 和 GLUT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我一直试图在 OS X 上使用 CDT 在 Eclipse 中设置 OpenGL 和 GLUT 库,但没有取得多大成功.我似乎无法让 eclipse 真正意识到 GLUT 在哪里.它目前给我的错误是我有一个未解决的包含 GL/glut.h.在网上环顾四周,我发现我应该在 gcc 链接器设置中使用 -framework GLUT 标志,但这似乎无效.

                  I have been trying to setup the OpenGL and GLUT libraries in Eclipse, with CDT, on OS X with not very much success. I cannot seem to get eclipse to actually realize where GLUT is. It is currently giving me the error that I have an unresolved inclusion GL/glut.h. Looking around online I found that I should be using the -framework GLUT flag in the gcc linker settings, but this seems ineffective.

                  推荐答案

                  好的.我让它在 X11 中工作.我只能让它在 X11 上运行的原因是因为操作系统上的 OpenGL 库似乎是针对 64 位架构的,但是如果我们使用 32 位架构,eclipse 只会编译代码.也许如果这个问题得到解决,我们可以使用 OS X 预安装的库.另外,也许操作系统上有一个 32 位版本,我们可以使用它,但我似乎找不到它.但是,我对使用 X11 进行学习感到满意.

                  Ok. I got it working in X11. The reason I could only get it working on X11 is because it seems the OpenGL libs on the OS are for the 64-bit architecture, but eclipse will only compile code if we use 32-bit architecture. Maybe if this got fixed we could use OS X pre-installed libraries. Also, maybe there is a 32-bit version lying around on the OS we could use that but I can't seem to find it. I, however, am content with using X11 for my learning purposes.

                  首先创建您的 C++ 项目.然后,由于您无法使用 Eclipse 编译 64 位代码,请添加以下内容...

                  First create your C++ project. Then since you can't compile code in 64-bit using eclipse add the following...

                  然后你需要你的库和链接设置.为此,请执行以下操作:

                  Then you need your libraries and linking set up. To do this do the following:

                  最后你需要设置一个 DISPLAY 变量.

                  Lastly you need to set a DISPLAY variable.

                  在您尝试运行之前启动 X11.

                  Before you try running start up X11.

                  试试下面的代码,让我在我的机器上运行一些东西.希望对你有用!

                  Try the following code to get something I've got running in my machine. Hope it works for you!

                  //#include <GL/gl.h>
                  //#include <GL/glu.h>
                  #include <GL/glut.h>
                  #define window_width  640
                  #define window_height 480
                  // Main loop
                  void main_loop_function() {
                      // Z angle
                      static float angle;
                      // Clear color (screen)
                      // And depth (used internally to block obstructed objects)
                      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
                      // Load identity matrix
                      glLoadIdentity();
                      // Multiply in translation matrix
                      glTranslatef(0, 0, -10);
                      // Multiply in rotation matrix
                      glRotatef(angle, 0, 0, 1);
                      // Render colored quad
                      glBegin( GL_QUADS);
                      glColor3ub(255, 000, 000);
                      glVertex2f(-1, 1);
                      glColor3ub(000, 255, 000);
                      glVertex2f(1, 1);
                      glColor3ub(000, 000, 255);
                      glVertex2f(1, -1);
                      glColor3ub(255, 255, 000);
                      glVertex2f(-1, -1);
                      glEnd();
                      // Swap buffers (color buffers, makes previous render visible)
                      glutSwapBuffers();
                      // Increase angle to rotate
                      angle += 0.25;
                  }
                  // Initialze OpenGL perspective matrix
                  void GL_Setup(int width, int height) {
                      glViewport(0, 0, width, height);
                      glMatrixMode( GL_PROJECTION);
                      glEnable( GL_DEPTH_TEST);
                      gluPerspective(45, (float) width / height, .1, 100);
                      glMatrixMode( GL_MODELVIEW);
                  }
                  // Initialize GLUT and start main loop
                  int main(int argc, char** argv) {
                      glutInit(&argc, argv);
                      glutInitWindowSize(window_width, window_height);
                      glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
                      glutCreateWindow("GLUT Example!!!");
                      glutDisplayFunc(main_loop_function);
                      glutIdleFunc(main_loop_function);
                      GL_Setup(window_width, window_height);
                      glutMainLoop();
                  }
                  

                  这篇关于OS X 上 Eclipse 中的 OpenGL 和 GLUT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:是否可以以每秒 60 次的速度从点数据构建热图 下一篇:OpenGL 读写相同的纹理

                  相关文章

                  最新文章

                • <legend id='kb9p0'><style id='kb9p0'><dir id='kb9p0'><q id='kb9p0'></q></dir></style></legend>

                  • <bdo id='kb9p0'></bdo><ul id='kb9p0'></ul>
                  1. <small id='kb9p0'></small><noframes id='kb9p0'>

                      <tfoot id='kb9p0'></tfoot>
                      <i id='kb9p0'><tr id='kb9p0'><dt id='kb9p0'><q id='kb9p0'><span id='kb9p0'><b id='kb9p0'><form id='kb9p0'><ins id='kb9p0'></ins><ul id='kb9p0'></ul><sub id='kb9p0'></sub></form><legend id='kb9p0'></legend><bdo id='kb9p0'><pre id='kb9p0'><center id='kb9p0'></center></pre></bdo></b><th id='kb9p0'></th></span></q></dt></tr></i><div id='kb9p0'><tfoot id='kb9p0'></tfoot><dl id='kb9p0'><fieldset id='kb9p0'></fieldset></dl></div>