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

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

build: hide the SDL_main.h inclusion in core.h, and only activate it
on Windows if using Visual Studio; if using MinGW, try to stick to the
original main() entry point.

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