Changeset 1084


Ignore:
Timestamp:
Nov 21, 2011, 1:49:53 AM (12 years ago)
Author:
sam
Message:

nacl: the Mandelbrot zoomer is starting to work on NaCl.

Location:
trunk
Files:
7 added
6 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/build/lol-build

    r1082 r1084  
    1616#  - linux-i386
    1717#  - linux-amd64
     18#  - nacl-i386
    1819#  - nacl-amd64
    1920#  - ios-arm
     
    120121            android update project --path .
    121122            ;;
     123        nacl-i386)
     124            ./configure CXX=i686-nacl-g++ CC=i686-nacl-gcc ac_cv_exeext=.32.nexe --host=none LOL_LIBS="-lppapi -lppapi_gles2 -lppapi_cpp -u _ZN2pp12CreateModuleEv"
     125            ;;
    122126        nacl-amd64)
    123             # no need for "-u _ZN2pp12CreateModuleEv" but it could be helpful
    124             ./configure CXX=x86_64-nacl-g++ CC=x86_64-nacl-gcc ac_cv_exeext=.nexe --host=none LOL_LIBS="-lppapi -lppapi_gles2 -lppapi_cpp"
     127            ./configure CXX=x86_64-nacl-g++ CC=x86_64-nacl-gcc ac_cv_exeext=.64.nexe --host=none LOL_LIBS="-lppapi -lppapi_gles2 -lppapi_cpp -u _ZN2pp12CreateModuleEv"
    125128            ;;
    126129        ps3-ppu)
  • trunk/configure.ac

    r1082 r1084  
    191191AC_CHECK_FUNCS(glBegin)
    192192LIBS="${save_LIBS}"
     193
    193194
    194195dnl Use SDL? (always required on Linux or Win32)
     
    253254
    254255
     256dnl  Use NativeClient?
     257ac_cv_my_have_nacl="no"
     258AC_LANG_PUSH(C++)
     259AC_CHECK_HEADERS(ppapi/cpp/instance.h, [ac_cv_my_have_nacl="yes"])
     260AC_LANG_POP(C++)
     261AM_CONDITIONAL(USE_NACL, test "${ac_cv_my_have_nacl}" != "no")
     262
    255263dnl Use EGL?
    256264ac_cv_my_have_egl="no"
  • trunk/src/Makefile.am

    r1082 r1084  
    4444    platform/sdl/sdlinput.cpp platform/sdl/sdlinput.h
    4545
     46if USE_NACL
    4647nacl_sources = \
    47     platform/nacl/naclapp.cpp platform/nacl/naclapp.h
     48    platform/nacl/naclapp.cpp platform/nacl/naclapp.h \
     49    platform/nacl/nacl_instance.cpp platform/nacl/nacl_instance.h \
     50    platform/nacl/nacl_module.cpp \
     51    platform/nacl/opengl_context.cpp platform/nacl/opengl_context.h \
     52    platform/nacl/opengl_context_ptrs.h
     53endif
    4854
    4955if HAVE_PS3
  • trunk/src/platform/nacl/naclapp.cpp

    r1082 r1084  
    1414
    1515#if defined __native_client__
    16 #   include "ppapi/cpp/instance.h"
    17 #   include "ppapi/cpp/module.h"
    18 #   include "ppapi/cpp/var.h"
     16#   include <ppapi/cpp/instance.h>
     17#   include <ppapi/cpp/module.h>
     18#   include <ppapi/cpp/var.h>
    1919#endif
    2020
  • trunk/test/tutorial/tut01.cpp

    r1050 r1084  
    2222#if USE_SDL && defined __APPLE__
    2323#   include <SDL_main.h>
     24#endif
     25
     26#if defined __native_client__
     27#   define main old_main
    2428#endif
    2529
  • trunk/test/tutorial/tut03.cpp

    r1082 r1084  
    6060        /* Window size decides the world aspect ratio. For instance, 640×480
    6161         * will be mapped to (-0.66,-0.5) - (0.66,0.5). */
     62#if !defined __native_client__
    6263        m_window_size = Video::GetSize();
     64#else
     65        /* FIXME: it's illegal to call this on the game thread! */
     66        m_window_size = ivec2(640, 480);
     67#endif
    6368        if (m_window_size.y < m_window_size.x)
    6469            m_window2world = 0.5 / m_window_size.y;
     
    7782        }
    7883        m_center = -0.75;
     84#if defined __CELLOS_LV2__ || defined __native_client__
     85        m_zoom_speed = -0.0025;
     86#else
    7987        m_zoom_speed = 0.0;
     88#endif
    8089        m_radius = 5.0;
    8190        m_ready = false;
     
    101110            uint8_t green = g * 255.99f;
    102111            uint8_t blue = b * 255.99f;
    103             m_palette[i] = u8vec4(blue, green, red, 0);
    104         }
    105 
     112#if defined __native_client__
     113            m_palette[i] = u8vec4(red, green, blue, 255);
     114#else
     115            m_palette[i] = u8vec4(blue, green, red, 255);
     116#endif
     117        }
     118
     119#if !defined __native_client__
    106120        m_centertext = new Text(NULL, "gfx/font/ascii.png");
    107121        m_centertext->SetPos(ivec3(5, m_window_size.y - 15, 1));
     
    115129        m_zoomtext->SetPos(ivec3(5, m_window_size.y - 43, 1));
    116130        Ticker::Ref(m_zoomtext);
     131#endif
    117132
    118133        position = ivec3(0, 0, 0);
     
    125140    {
    126141        Input::UntrackMouse(this);
     142#if !defined __native_client__
    127143        Ticker::Unref(m_centertext);
    128144        Ticker::Unref(m_mousetext);
    129145        Ticker::Unref(m_zoomtext);
     146#endif
    130147        delete m_pixels;
    131148        delete m_tmppixels;
     
    159176
    160177        ivec3 buttons = Input::GetMouseButtons();
    161 #ifdef __CELLOS_LV2__
    162         m_zoom_speed = 0.0005;
    163 #else
     178#if !defined __CELLOS_LV2__ && !defined __native_client__
    164179        if ((buttons[0] || buttons[2]) && mousepos.x != -1)
    165180        {
     
    183198            double zoom = pow(2.0, deltams * m_zoom_speed);
    184199            if (m_radius * zoom > 8.0)
     200            {
     201                m_zoom_speed *= -1.0;
    185202                zoom = 8.0 / m_radius;
     203            }
    186204            else if (m_radius * zoom < 1e-14)
     205            {
     206                m_zoom_speed *= -1.0;
    187207                zoom = 1e-14 / m_radius;
     208            }
    188209            m_radius *= zoom;
    189 #ifdef __CELLOS_LV2__
    190             m_center = f64cmplx(-.22815528839841, -1.11514249704382);
     210#if defined __CELLOS_LV2__ || defined __native_client__
     211            //m_center = f64cmplx(-.22815528839841, -1.11514249704382);
    191212            //m_center = f64cmplx(0.001643721971153, 0.822467633298876);
     213            m_center = f64cmplx(-0.65823419062254, .50221777363480);
    192214#else
    193215            m_center = (m_center - worldmouse) * zoom + worldmouse;
     
    231253        }
    232254
     255#if !defined __native_client__
    233256        char buf[128];
    234257        sprintf(buf, "center: %+16.14f%+16.14fi", m_center.x, m_center.y);
     
    238261        sprintf(buf, "  zoom: %g", 1.0 / m_radius);
    239262        m_zoomtext->SetText(buf);
     263#endif
    240264
    241265        u8vec4 *m_pixelstart = m_pixels + m_size.x * m_size.y / 4 * m_frame;
     
    285309                else
    286310                {
    287                     *m_pixelstart++ = u8vec4(0, 0, 0, 0);
     311                    *m_pixelstart++ = u8vec4(0, 0, 0, 255);
    288312                }
    289313            }
     
    335359            m_shader = Shader::Create(
    336360#if !defined __CELLOS_LV2__
     361#if !defined HAVE_GLES_2X
    337362                "#version 120\n"
    338                 "attribute vec2 in_TexCoord;\n"
     363#else
     364                "precision highp float;"
     365#endif
     366                ""
     367#if defined HAVE_GLES_2X
     368                "varying vec2 pass_TexCoord;"
     369#endif
     370                "attribute vec2 in_TexCoord;"
    339371                "attribute vec2 in_Vertex;"
    340372                "void main(void) {"
    341373                "    gl_Position = vec4(in_Vertex, 0.0, 1.0);"
    342                 "    gl_TexCoord[0] = vec4(in_TexCoord, 0.0, 0.0);\n"
     374#if defined HAVE_GLES_2X
     375                "    pass_TexCoord = in_TexCoord;"
     376#else
     377                "    gl_TexCoord[0] = vec4(in_TexCoord, 0.0, 0.0);"
     378#endif
    343379                "}",
    344380
     381#if !defined HAVE_GLES_2X
    345382                "#version 120\n"
    346                 ""
     383#else
     384                "precision highp float;"
     385#endif
     386                ""
     387#if defined HAVE_GLES_2X
     388                "varying vec2 pass_TexCoord;"
     389#endif
    347390                "uniform vec4 in_TexelSize;"
    348391                "uniform mat4 in_ZoomSettings;"
     
    412455                ""
    413456                "void main(void) {"
     457#if defined HAVE_GLES_2X
     458                "    vec2 coord = pass_TexCoord;"
     459#else
    414460                "    vec2 coord = gl_TexCoord[0].xy;"
     461#endif
    415462                /* Slightly shift our pixel so that it does not lie at
    416463                 * an exact texel boundary. This would lead to visual
     
    514561        }
    515562
     563#if !defined HAVE_GLES_2X
    516564        glEnable(GL_TEXTURE_2D);
     565#endif
    517566        glBindTexture(GL_TEXTURE_2D, m_texid);
    518567
     
    599648
    600649    /* Debug information */
     650#if !defined __native_client__
    601651    Text *m_centertext, *m_mousetext, *m_zoomtext;
     652#endif
    602653};
    603654
Note: See TracChangeset for help on using the changeset viewer.