source: trunk/tutorial/11_fractal.cpp @ 1645

Last change on this file since 1645 was 1645, checked in by sam, 8 years ago

core: switch the Win32/x64 binaries to the Windows subsystem so that they
do not open a console at startup.

  • Property svn:keywords set to Id
File size: 20.7 KB
Line 
1//
2// Lol Engine - Fractal tutorial
3//
4// Copyright: (c) 2011-2012 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
9//
10
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include <cstring>
16
17#include "core.h"
18#include "lolgl.h"
19#include "loldebug.h"
20
21using namespace lol;
22
23#if defined _WIN32 && defined USE_D3D9
24#   define FAR
25#   define NEAR
26#   include <d3d9.h>
27#endif
28
29#if USE_SDL
30#   include <SDL_main.h>
31#endif
32
33#if defined _WIN32
34#   include <direct.h>
35#endif
36
37extern char const *lolfx_11_fractal;
38
39#if defined USE_D3D9
40extern IDirect3DDevice9 *g_d3ddevice;
41#elif defined _XBOX
42extern D3DDevice *g_d3ddevice;
43#elif __CELLOS_LV2__
44static GLint const INTERNAL_FORMAT = GL_ARGB_SCE;
45static GLenum const TEXTURE_FORMAT = GL_BGRA;
46static GLenum const TEXTURE_TYPE = GL_UNSIGNED_INT_8_8_8_8_REV;
47#elif defined __native_client__
48static GLint const INTERNAL_FORMAT = GL_RGBA;
49static GLenum const TEXTURE_FORMAT = GL_RGBA;
50static GLenum const TEXTURE_TYPE = GL_UNSIGNED_BYTE;
51#else
52/* Seems efficient for little endian textures */
53static GLint const INTERNAL_FORMAT = GL_RGBA;
54static GLenum const TEXTURE_FORMAT = GL_BGRA;
55static GLenum const TEXTURE_TYPE = GL_UNSIGNED_INT_8_8_8_8_REV;
56#endif
57
58class Fractal : public WorldEntity
59{
60public:
61    Fractal(ivec2 const &size)
62    {
63        /* Ensure texture size is a multiple of 16 for better aligned
64         * data access. Store the dimensions of a texel for our shader,
65         * as well as the half-size of the screen. */
66        m_size = size;
67        m_size.x = (m_size.x + 15) & ~15;
68        m_size.y = (m_size.y + 15) & ~15;
69        m_texel_settings = vec4(1.0, 1.0, 2.0, 2.0) / m_size.xyxy;
70        m_screen_settings = vec4(1.0, 1.0, 0.5, 0.5) * m_size.xyxy;
71
72        /* Window size decides the world aspect ratio. For instance, 640×480
73         * will be mapped to (-0.66,-0.5) - (0.66,0.5). */
74#if !defined __native_client__
75        m_window_size = Video::GetSize();
76#else
77        /* FIXME: it's illegal to call this on the game thread! */
78        m_window_size = ivec2(640, 480);
79#endif
80        if (m_window_size.y < m_window_size.x)
81            m_window2world = 0.5 / m_window_size.y;
82        else
83            m_window2world = 0.5 / m_window_size.x;
84        m_texel2world = (vec2)m_window_size / m_size * m_window2world;
85
86        m_oldmouse = ivec2(0, 0);
87
88        m_pixels = new u8vec4[m_size.x * m_size.y];
89        m_tmppixels = new u8vec4[m_size.x / 2 * m_size.y / 2];
90        m_frame = -1;
91        m_slices = 4;
92        for (int i = 0; i < 4; i++)
93        {
94            m_deltashift[i] = 0.0;
95            m_deltascale[i] = 1.0;
96            m_dirty[i] = 2;
97        }
98#if defined __CELLOS_LV2__ || defined _XBOX
99        //m_center = dcmplx(-.22815528839841, -1.11514249704382);
100        //m_center = dcmplx(0.001643721971153, 0.822467633298876);
101        m_center = dcmplx(-0.65823419062254, 0.50221777363480);
102        m_zoom_speed = -0.025;
103#else
104        m_center = -0.75;
105        m_zoom_speed = 0.0;
106#endif
107        m_translate = 0;
108        m_radius = 5.0;
109        m_ready = false;
110        m_drag = false;
111
112        m_palette = new u8vec4[(MAX_ITERATIONS + 1) * PALETTE_STEP];
113        for (int i = 0; i < (MAX_ITERATIONS + 1) * PALETTE_STEP; i++)
114        {
115            double f = (double)i / PALETTE_STEP;
116
117            double r = 0.5 * lol::sin(f * 0.27 + 2.0) + 0.5;
118            double g = 0.5 * lol::sin(f * 0.17 - 1.8) + 0.5;
119            double b = 0.5 * lol::sin(f * 0.21 - 2.6) + 0.5;
120
121            if (f < 7.0)
122            {
123                f = f < 1.0 ? 0.0 : (f - 1.0) / 6.0;
124                r *= f;
125                g *= f;
126                b *= f;
127            }
128
129            uint8_t red = r * 255.99f;
130            uint8_t green = g * 255.99f;
131            uint8_t blue = b * 255.99f;
132#if defined __CELLOS_LV2__ || defined _XBOX
133            m_palette[i] = u8vec4(255, red, green, blue);
134#elif defined __native_client__
135            m_palette[i] = u8vec4(red, green, blue, 255);
136#else
137            m_palette[i] = u8vec4(blue, green, red, 255);
138#endif
139        }
140
141#if !defined __native_client__
142        m_centertext = new Text(NULL, "src/data/font/ascii.png");
143        m_centertext->SetPos(ivec3(5, m_window_size.y - 15, 1));
144        Ticker::Ref(m_centertext);
145
146        m_mousetext = new Text(NULL, "src/data/font/ascii.png");
147        m_mousetext->SetPos(ivec3(5, m_window_size.y - 29, 1));
148        Ticker::Ref(m_mousetext);
149
150        m_zoomtext = new Text(NULL, "src/data/font/ascii.png");
151        m_zoomtext->SetPos(ivec3(5, m_window_size.y - 43, 1));
152        Ticker::Ref(m_zoomtext);
153#endif
154
155        m_position = ivec3(0, 0, 0);
156        m_bbox[0] = m_position;
157        m_bbox[1] = ivec3(m_window_size, 0);
158        Input::TrackMouse(this);
159
160        /* Spawn worker threads and wait for their readiness. */
161        for (int i = 0; i < MAX_THREADS; i++)
162            m_threads[i] = new Thread(DoWorkHelper, this);
163        for (int i = 0; i < MAX_THREADS; i++)
164            m_spawnqueue.Pop();
165    }
166
167    ~Fractal()
168    {
169        /* Signal worker threads for completion and wait for
170         * them to quit. */
171        for (int i = 0; i < MAX_THREADS; i++)
172            m_jobqueue.Push(-1);
173        for (int i = 0; i < MAX_THREADS; i++)
174            m_donequeue.Pop();
175
176        Input::UntrackMouse(this);
177#if !defined __native_client__
178        Ticker::Unref(m_centertext);
179        Ticker::Unref(m_mousetext);
180        Ticker::Unref(m_zoomtext);
181#endif
182        delete m_pixels;
183        delete m_tmppixels;
184        delete m_palette;
185    }
186
187    inline dcmplx TexelToWorldOffset(vec2 texel)
188    {
189        double dx = (0.5 + texel.x - m_size.x / 2) * m_texel2world.x;
190        double dy = (0.5 + m_size.y / 2 - texel.y) * m_texel2world.y;
191        return m_radius * dcmplx(dx, dy);
192    }
193
194    inline dcmplx ScreenToWorldOffset(vec2 pixel)
195    {
196        /* No 0.5 offset here, because we want to be able to position the
197         * mouse at (0,0) exactly. */
198        double dx = pixel.x - m_window_size.x / 2;
199        double dy = m_window_size.y / 2 - pixel.y;
200        return m_radius * m_window2world * dcmplx(dx, dy);
201    }
202
203    virtual void TickGame(float seconds)
204    {
205        WorldEntity::TickGame(seconds);
206
207        int prev_frame = m_frame;
208        m_frame = (m_frame + 1) % 4;
209
210        dcmplx worldmouse = m_center + ScreenToWorldOffset(m_mousepos);
211
212        ivec3 buttons = Input::GetMouseButtons();
213#if !defined __CELLOS_LV2__ && !defined _XBOX
214        if (buttons[1])
215        {
216            if (!m_drag)
217            {
218                m_oldmouse = m_mousepos;
219                m_drag = true;
220            }
221            m_translate = ScreenToWorldOffset(m_oldmouse)
222                        - ScreenToWorldOffset(m_mousepos);
223            /* XXX: the purpose of this hack is to avoid translating by
224             * an exact number of pixels. If this were to happen, the step()
225             * optimisation for i915 cards in our shader would behave
226             * incorrectly because a quarter of the pixels in the image
227             * would have tie rankings in the distance calculation. */
228            m_translate *= 1023.0 / 1024.0;
229            m_oldmouse = m_mousepos;
230        }
231        else
232        {
233            m_drag = false;
234            if (m_translate != 0.0)
235            {
236                m_translate *= std::pow(2.0, -seconds * 5.0);
237                if (m_translate.norm() / m_radius < 1e-4)
238                    m_translate = 0.0;
239            }
240        }
241
242        if ((buttons[0] || buttons[2]) && m_mousepos.x != -1)
243        {
244            double zoom = buttons[0] ? -0.5 : 0.5;
245            m_zoom_speed += seconds * zoom;
246            if (m_zoom_speed / zoom > 5e-3f)
247                m_zoom_speed = 5e-3f * zoom;
248        }
249        else if (m_zoom_speed)
250        {
251            m_zoom_speed *= std::pow(2.0, -seconds * 5.0);
252            if (abs(m_zoom_speed) < 1e-5 || m_drag)
253                m_zoom_speed = 0.0;
254        }
255#endif
256
257        if (m_zoom_speed || m_translate != 0.0)
258        {
259            dcmplx oldcenter = m_center;
260            double oldradius = m_radius;
261            double zoom = std::pow(2.0, seconds * 1e3f * m_zoom_speed);
262            if (m_radius * zoom > 8.0)
263            {
264                m_zoom_speed *= -1.0;
265                zoom = 8.0 / m_radius;
266            }
267            else if (m_radius * zoom < 1e-14)
268            {
269                m_zoom_speed *= -1.0;
270                zoom = 1e-14 / m_radius;
271            }
272            m_radius *= zoom;
273#if !defined __CELLOS_LV2__ && !defined _XBOX
274            m_center += m_translate;
275            m_center = (m_center - worldmouse) * zoom + worldmouse;
276            worldmouse = m_center + ScreenToWorldOffset(m_mousepos);
277#endif
278
279            /* Store the transformation properties to go from m_frame - 1
280             * to m_frame. */
281            m_deltashift[prev_frame] = (m_center - oldcenter) / oldradius;
282            m_deltashift[prev_frame].x /= m_size.x * m_texel2world.x;
283            m_deltashift[prev_frame].y /= m_size.y * m_texel2world.y;
284            m_deltascale[prev_frame] = m_radius / oldradius;
285            m_dirty[0] = m_dirty[1] = m_dirty[2] = m_dirty[3] = 2;
286        }
287        else
288        {
289            /* If settings didn't change, set transformation from previous
290             * frame to identity. */
291            m_deltashift[prev_frame] = 0.0;
292            m_deltascale[prev_frame] = 1.0;
293        }
294
295        /* Transformation from current frame to current frame is always
296         * identity. */
297        m_zoom_settings[m_frame][0] = 0.0f;
298        m_zoom_settings[m_frame][1] = 0.0f;
299        m_zoom_settings[m_frame][2] = 1.0f;
300
301        /* Compute transformation from other frames to current frame */
302        for (int i = 0; i < 3; i++)
303        {
304            int prev_index = (m_frame + 4 - i) % 4;
305            int cur_index = (m_frame + 3 - i) % 4;
306
307            m_zoom_settings[cur_index][0] = m_zoom_settings[prev_index][0] * m_deltascale[cur_index] + m_deltashift[cur_index].x;
308            m_zoom_settings[cur_index][1] = m_zoom_settings[prev_index][1] * m_deltascale[cur_index] + m_deltashift[cur_index].y;
309            m_zoom_settings[cur_index][2] = m_zoom_settings[prev_index][2] * m_deltascale[cur_index];
310        }
311
312        /* Precompute texture offset change instead of doing it in GLSL */
313        for (int i = 0; i < 4; i++)
314        {
315            m_zoom_settings[i][0] += 0.5 * (1.0 - m_zoom_settings[i][2]);
316            m_zoom_settings[i][1] -= 0.5 * (1.0 - m_zoom_settings[i][2]);
317        }
318
319#if !defined __native_client__
320        char buf[128];
321        sprintf(buf, "center: %+16.14f%+16.14fi", m_center.x, m_center.y);
322        m_centertext->SetText(buf);
323        sprintf(buf, " mouse: %+16.14f%+16.14fi", worldmouse.x, worldmouse.y);
324        m_mousetext->SetText(buf);
325        sprintf(buf, "  zoom: %g", 1.0 / m_radius);
326        m_zoomtext->SetText(buf);
327#endif
328
329        if (m_dirty[m_frame])
330        {
331            m_dirty[m_frame]--;
332
333            for (int i = 0; i < m_size.y; i += MAX_LINES * 2)
334                m_jobqueue.Push(i);
335        }
336    }
337
338    static void *DoWorkHelper(void *data)
339    {
340        Fractal *that = (Fractal *)data;
341        that->m_spawnqueue.Push(0);
342        for ( ; ; )
343        {
344            int line = that->m_jobqueue.Pop();
345            if (line == -1)
346                break;
347            that->DoWork(line);
348            that->m_donequeue.Push(0);
349        }
350        that->m_donequeue.Push(0);
351        return NULL;
352    };
353
354    void DoWork(int line)
355    {
356        double const maxsqlen = 1024;
357        double const k1 = 1.0 / (1 << 10) / (std::log(maxsqlen) / std::log(2.0));
358
359        int jmin = ((m_frame + 1) % 4) / 2 + line;
360        int jmax = jmin + MAX_LINES * 2;
361        if (jmax > m_size.y)
362            jmax = m_size.y;
363        u8vec4 *m_pixelstart = m_pixels
364                             + m_size.x * (m_size.y / 4 * m_frame + line / 4);
365
366        for (int j = jmin; j < jmax; j += 2)
367        for (int i = m_frame % 2; i < m_size.x; i += 2)
368        {
369            dcmplx z0 = m_center + TexelToWorldOffset(ivec2(i, j));
370            dcmplx z1, z2, z3, r0 = z0;
371            //dcmplx r0(0.28693186889504513, 0.014286693904085048);
372            //dcmplx r0(0.001643721971153, 0.822467633298876);
373            //dcmplx r0(-1.207205434596, 0.315432814901);
374            //dcmplx r0(-0.79192956889854, -0.14632423080102);
375            //dcmplx r0(0.3245046418497685, 0.04855101129280834);
376            int iter = MAX_ITERATIONS - 4;
377            for (;;)
378            {
379                /* Unroll the loop: tests are more expensive to do at each
380                 * iteration than the few extra multiplications. */
381                z1 = z0 * z0 + r0;
382                z2 = z1 * z1 + r0;
383                z3 = z2 * z2 + r0;
384                z0 = z3 * z3 + r0;
385                if (sqlength(z0) >= maxsqlen)
386                    break;
387                iter -= 4;
388                if (iter < 4)
389                    break;
390            }
391
392            if (iter)
393            {
394                double n = sqlength(z0);
395
396                if (sqlength(z1) >= maxsqlen) { iter += 3; n = sqlength(z1); }
397                else if (sqlength(z2) >= maxsqlen) { iter += 2; n = sqlength(z2); }
398                else if (sqlength(z3) >= maxsqlen) { iter += 1; n = sqlength(z3); }
399
400                if (n > maxsqlen * maxsqlen)
401                    n = maxsqlen * maxsqlen;
402
403                /* Approximate log(sqrt(n))/log(sqrt(maxsqlen)) */
404                double f = iter;
405                union { double n; uint64_t x; } u = { n };
406                double k = (u.x >> 42) - (((1 << 10) - 1) << 10);
407                k *= k1;
408
409                /* Approximate log2(k) in [1,2]. */
410                f += (- 0.344847817623168308695977510213252644185 * k
411                      + 2.024664188044341212602376988171727038739) * k
412                      - 1.674876738008591047163498125918330313237;
413
414                *m_pixelstart++ = m_palette[(int)(f * PALETTE_STEP)];
415            }
416            else
417            {
418#if defined __CELLOS_LV2__ || defined _XBOX
419                *m_pixelstart++ = u8vec4(255, 0, 0, 0);
420#else
421                *m_pixelstart++ = u8vec4(0, 0, 0, 255);
422#endif
423            }
424        }
425    }
426
427    virtual void TickDraw(float seconds)
428    {
429        WorldEntity::TickDraw(seconds);
430
431        static float const vertices[] =
432        {
433             1.0f,  1.0f,
434            -1.0f,  1.0f,
435            -1.0f, -1.0f,
436            -1.0f, -1.0f,
437             1.0f, -1.0f,
438             1.0f,  1.0f,
439        };
440
441        static float const texcoords[] =
442        {
443             1.0f,  1.0f,
444             0.0f,  1.0f,
445             0.0f,  0.0f,
446             0.0f,  0.0f,
447             1.0f,  0.0f,
448             1.0f,  1.0f,
449        };
450
451        if (!m_ready)
452        {
453#if !defined _XBOX && !defined USE_D3D9
454            /* Create a texture of half the width and twice the height
455             * so that we can upload four different subimages each frame. */
456            glGenTextures(1, &m_texid);
457            glBindTexture(GL_TEXTURE_2D, m_texid);
458            glTexImage2D(GL_TEXTURE_2D, 0, INTERNAL_FORMAT,
459                         m_size.x / 2, m_size.y * 2, 0,
460                         TEXTURE_FORMAT, TEXTURE_TYPE, m_pixels);
461#   if defined __CELLOS_LV2__
462            /* We need this hint because by default the storage type is
463             * GL_TEXTURE_SWIZZLED_GPU_SCE. */
464            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_ALLOCATION_HINT_SCE,
465                            GL_TEXTURE_TILED_GPU_SCE);
466#   endif
467            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
468            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
469#elif defined _XBOX
470            /* By default the X360 will swizzle the texture. Ask for linear. */
471            g_d3ddevice->CreateTexture(m_size.x / 2, m_size.y * 2, 1,
472                                       D3DUSAGE_WRITEONLY, D3DFMT_LIN_A8R8G8B8,
473                                       D3DPOOL_DEFAULT, &m_tex, NULL);
474#else
475            g_d3ddevice->CreateTexture(m_size.x / 2, m_size.y * 2, 1,
476                                       D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8,
477                                       D3DPOOL_SYSTEMMEM, &m_tex, NULL);
478#endif
479
480            m_shader = Shader::Create(lolfx_11_fractal);
481
482            m_vertexattrib = m_shader->GetAttribLocation("a_Vertex", VertexUsage::Position, 0);
483            m_texattrib = m_shader->GetAttribLocation("a_TexCoord", VertexUsage::TexCoord, 0);
484            m_texeluni = m_shader->GetUniformLocation("u_TexelSize");
485            m_screenuni = m_shader->GetUniformLocation("u_ScreenSize");
486            m_zoomuni = m_shader->GetUniformLocation("u_ZoomSettings");
487
488            m_vdecl =
489              new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position),
490                                    VertexStream<vec2>(VertexUsage::TexCoord));
491            m_vbo = new VertexBuffer(sizeof(vertices));
492            m_tbo = new VertexBuffer(sizeof(texcoords));
493
494            void *tmp = m_vbo->Lock(0, 0);
495            memcpy(tmp, vertices, sizeof(vertices));
496            m_vbo->Unlock();
497
498            tmp = m_tbo->Lock(0, 0);
499            memcpy(tmp, texcoords, sizeof(texcoords));
500            m_tbo->Unlock();
501
502            /* FIXME: this object never cleans up */
503            m_ready = true;
504        }
505
506#if defined _XBOX || defined USE_D3D9
507
508#else
509#   if !defined HAVE_GLES_2X
510        glEnable(GL_TEXTURE_2D);
511#   endif
512        glBindTexture(GL_TEXTURE_2D, m_texid);
513#endif
514
515        if (m_dirty[m_frame])
516        {
517            for (int i = 0; i < m_size.y; i += MAX_LINES * 2)
518                m_donequeue.Pop();
519
520            m_dirty[m_frame]--;
521
522#if defined _XBOX || defined USE_D3D9
523            D3DLOCKED_RECT rect;
524#   if defined _XBOX
525            m_tex->LockRect(0, &rect, NULL, D3DLOCK_NOOVERWRITE);
526#   else
527            m_tex->LockRect(0, &rect, NULL,
528                            D3DLOCK_DISCARD | D3DLOCK_NOOVERWRITE);
529#   endif
530            for (int j = 0; j < m_size.y * 2; j++)
531            {
532                u8vec4 *line = (u8vec4 *)rect.pBits + j * rect.Pitch / 4;
533                for (int i = 0; i < m_size.x / 2; i++)
534                    line[i] = m_pixels[m_size.x / 2 * j + i];
535            }
536            m_tex->UnlockRect(0);
537#elif defined __CELLOS_LV2__
538            /* glTexSubImage2D is extremely slow on the PS3, to the point
539             * that uploading the whole texture is 40 times faster. */
540            glTexImage2D(GL_TEXTURE_2D, 0, INTERNAL_FORMAT,
541                         m_size.x / 2, m_size.y * 2, 0,
542                         TEXTURE_FORMAT, TEXTURE_TYPE, m_pixels);
543#else
544            glTexSubImage2D(GL_TEXTURE_2D, 0, 0, m_frame * m_size.y / 2,
545                            m_size.x / 2, m_size.y / 2,
546                            TEXTURE_FORMAT, TEXTURE_TYPE,
547                            m_pixels + m_size.x * m_size.y / 4 * m_frame);
548#endif
549        }
550
551        m_shader->Bind();
552        m_shader->SetUniform(m_texeluni, m_texel_settings);
553        m_shader->SetUniform(m_screenuni, m_screen_settings);
554        m_shader->SetUniform(m_zoomuni, m_zoom_settings);
555        m_vdecl->Bind();
556        m_vdecl->SetStream(m_vbo, m_vertexattrib);
557        m_vdecl->SetStream(m_tbo, m_texattrib);
558#if defined _XBOX || defined USE_D3D9
559        g_d3ddevice->SetTexture(0, m_tex);
560        g_d3ddevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
561#elif !defined __CELLOS_LV2__ && !defined __ANDROID__
562#else
563#endif
564        m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, 2);
565        m_vdecl->Unbind();
566    }
567
568private:
569    static int const MAX_ITERATIONS = 340;
570    static int const PALETTE_STEP = 32;
571    static int const MAX_THREADS = 8;
572    static int const MAX_LINES = 8;
573
574    ivec2 m_size, m_window_size, m_oldmouse;
575    double m_window2world;
576    dvec2 m_texel2world;
577    u8vec4 *m_pixels, *m_tmppixels, *m_palette;
578
579    Shader *m_shader;
580    ShaderAttrib m_vertexattrib, m_texattrib;
581    ShaderUniform m_texeluni, m_screenuni, m_zoomuni;
582
583    VertexDeclaration *m_vdecl;
584    VertexBuffer *m_vbo, *m_tbo;
585#if defined USE_D3D9
586    IDirect3DTexture9 *m_tex;
587#elif defined _XBOX
588    D3DTexture *m_tex;
589#else
590    GLuint m_texid;
591#endif
592    int m_frame, m_slices, m_dirty[4];
593    bool m_ready, m_drag;
594
595    dcmplx m_center, m_translate;
596    double m_zoom_speed, m_radius;
597    vec4 m_texel_settings, m_screen_settings;
598    mat4 m_zoom_settings;
599    dcmplx m_deltashift[4];
600    double m_deltascale[4];
601
602    /* Worker threads */
603    Thread *m_threads[MAX_THREADS];
604    Queue<int> m_spawnqueue, m_jobqueue, m_donequeue;
605
606    /* Debug information */
607#if !defined __native_client__
608    Text *m_centertext, *m_mousetext, *m_zoomtext;
609#endif
610};
611
612int main(int argc, char **argv)
613{
614    Application app("Tutorial 3: Fractal", ivec2(640, 480), 60.0f);
615
616#if defined _MSC_VER && !defined _XBOX
617    _chdir("..");
618#elif defined _WIN32 && !defined _XBOX
619    _chdir("../..");
620#endif
621
622    new DebugFps(5, 5);
623    new Fractal(ivec2(640, 480));
624    //new DebugRecord("fractalol.ogm", 60.0f);
625
626    app.Run();
627
628    return EXIT_SUCCESS;
629}
630
Note: See TracBrowser for help on using the repository browser.