~ubuntu-branches/ubuntu/warty/aqsis/warty

« back to all changes in this revision

Viewing changes to framebuffer_glut/framebuffer_glut.cpp

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-08-24 07:25:04 UTC
  • Revision ID: james.westby@ubuntu.com-20040824072504-zf993vnevvisdsvb
Tags: upstream-0.9.1
Import upstream version 0.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Aqsis
 
2
// Copyright � 1997 - 2001, Paul C. Gregory
 
3
//
 
4
// Contact: pgregory@aqsis.com
 
5
//
 
6
// This library is free software; you can redistribute it and/or
 
7
// modify it under the terms of the GNU General Public
 
8
// License as published by the Free Software Foundation; either
 
9
// version 2 of the License, or (at your option) any later version.
 
10
//
 
11
// This library is distributed in the hope that it will be useful,
 
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
// General Public License for more details.
 
15
//
 
16
// You should have received a copy of the GNU General Public
 
17
// License along with this library; if not, write to the Free Software
 
18
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
19
 
 
20
 
 
21
/** \file
 
22
                \brief Implements a GLUT based framebuffer display driver for Aqsis
 
23
                \author Timothy M. Shead (tshead@k-3d.com)
 
24
*/
 
25
 
 
26
#include <iomanip>
 
27
#include <iostream>
 
28
#include <sstream>
 
29
#include <string>
 
30
#include <memory>
 
31
 
 
32
#include "aqsis.h"
 
33
#include <logging.h>
 
34
#include <logging_streambufs.h>
 
35
 
 
36
#ifdef AQSIS_SYSTEM_WIN32
 
37
 
 
38
#include <winsock2.h>
 
39
#include <locale>
 
40
#include <direct.h>
 
41
 
 
42
#define getcwd _getcwd
 
43
#define PATH_SEPARATOR "\\"
 
44
 
 
45
#else // !AQSIS_SYSTEM_WIN32
 
46
 
 
47
#include <stdio.h>
 
48
#include <stdlib.h>
 
49
#include <unistd.h>
 
50
#include <netdb.h>
 
51
#include <netinet/in.h>
 
52
#include <sys/types.h>
 
53
#include <sys/socket.h>
 
54
 
 
55
typedef int SOCKET;
 
56
typedef sockaddr_in SOCKADDR_IN;
 
57
typedef sockaddr* PSOCKADDR;
 
58
 
 
59
static const int INVALID_SOCKET = -1;
 
60
static const int SOCKET_ERROR = -1;
 
61
 
 
62
#define PATH_SEPARATOR "/"
 
63
 
 
64
#endif // !AQSIS_SYSTEM_WIN32
 
65
 
 
66
#include <tiffio.h>
 
67
 
 
68
#include "displaydriver.h"
 
69
#include "dd.h"
 
70
 
 
71
using namespace Aqsis;
 
72
 
 
73
#ifdef AQSIS_SYSTEM_MACOSX
 
74
#include <GLUT/glut.h>
 
75
#include <GLUT/macxglut_utilities.h>
 
76
#include <ApplicationServices/ApplicationServices.h>
 
77
#else
 
78
#include <GL/glut.h>
 
79
#endif //!AQSIS_SYSTEM_MACOSX
 
80
 
 
81
#ifndef AQSIS_SYSTEM_WIN32
 
82
typedef int SOCKET;
 
83
#endif // !AQSIS_SYSTEM_WIN32
 
84
 
 
85
static std::string      g_Filename( "output.tif" );
 
86
static TqInt g_ImageWidth = 0;
 
87
static TqInt g_ImageHeight = 0;
 
88
static TqInt g_PixelsProcessed = 0;
 
89
static TqInt g_Channels = 0;
 
90
static TqInt g_Format = 0;
 
91
static int g_Window = 0;
 
92
static GLubyte* g_Image = 0;
 
93
static TqInt g_CWXmin, g_CWYmin;
 
94
static TqInt g_CWXmax, g_CWYmax;
 
95
static TqFloat  quantize_zeroval = 0.0f;
 
96
static TqFloat  quantize_oneval  = 0.0f;
 
97
static TqFloat  quantize_minval  = 0.0f;
 
98
static TqFloat  quantize_maxval  = 0.0f;
 
99
static TqFloat dither_val       = 0.0f;
 
100
 
 
101
typedef void (text_callback)(const std::string&);
 
102
static std::string g_text_prompt;
 
103
static std::string g_text_input;
 
104
static text_callback* g_text_ok_callback = 0;
 
105
 
 
106
const std::string get_window_title()
 
107
{
 
108
    std::ostringstream buffer;
 
109
    buffer << g_Filename << ": " << std::fixed << std::setprecision(1) << 100.0 * static_cast<double>(g_PixelsProcessed) / static_cast<double>(g_ImageWidth * g_ImageHeight) << "% complete";
 
110
 
 
111
    return buffer.str();
 
112
}
 
113
 
 
114
const std::string get_current_working_directory()
 
115
{
 
116
    std::string result(1024, '\0');
 
117
    getcwd(const_cast<char*>(result.c_str()), result.size());
 
118
    result.resize(strlen(result.c_str()));
 
119
 
 
120
    return result;
 
121
}
 
122
 
 
123
const std::string append_path(const std::string& LHS, const std::string& RHS)
 
124
{
 
125
    return LHS + PATH_SEPARATOR + RHS;
 
126
}
 
127
 
 
128
void write_tiff(const std::string& filename)
 
129
{
 
130
    TIFF* const file = TIFFOpen(filename.c_str(), "w");
 
131
    if(!file)
 
132
    {
 
133
        std::cerr << error << "Could not open [" << filename << "] for TIFF output" << std::endl;
 
134
        return;
 
135
    }
 
136
 
 
137
    TIFFSetField(file, TIFFTAG_IMAGEWIDTH, g_ImageWidth);
 
138
    TIFFSetField(file, TIFFTAG_IMAGELENGTH, g_ImageHeight);
 
139
    TIFFSetField(file, TIFFTAG_BITSPERSAMPLE, 8);
 
140
    TIFFSetField(file, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
 
141
    TIFFSetField(file, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
 
142
    TIFFSetField(file, TIFFTAG_SAMPLESPERPIXEL, 3);
 
143
    TIFFSetField(file, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
 
144
    TIFFSetField(file, TIFFTAG_ROWSPERSTRIP, 1);
 
145
    TIFFSetField(file, TIFFTAG_IMAGEDESCRIPTION, "Image rendered with Aqsis, http://www.aqsis.com");
 
146
 
 
147
    GLubyte* p = g_Image;
 
148
    for(int i = g_ImageHeight - 1; i >= 0; i--)
 
149
    {
 
150
        if(TIFFWriteScanline(file, p, i, 0) < 0)
 
151
        {
 
152
            TIFFClose(file);
 
153
            std::cerr << error << "Could not write data to [" << filename << "] for TIFF output" << std::endl;
 
154
            return;
 
155
        }
 
156
        p += g_ImageWidth * sizeof(GLubyte) * 3;
 
157
    }
 
158
 
 
159
    TIFFClose(file);
 
160
}
 
161
 
 
162
void text_prompt(const std::string& Prompt, const std::string& DefaultValue, text_callback* Callback)
 
163
{
 
164
    g_text_prompt = Prompt;
 
165
    g_text_input = DefaultValue;
 
166
    g_text_ok_callback = Callback;
 
167
 
 
168
    glutPostRedisplay();
 
169
}
 
170
 
 
171
void menu(int value)
 
172
{
 
173
    switch (value)
 
174
    {
 
175
    case 1:
 
176
        text_prompt("Save TIFF: ", append_path(get_current_working_directory(), g_Filename), &write_tiff);
 
177
        break;
 
178
    }
 
179
}
 
180
 
 
181
void draw_text(const std::string& Text)
 
182
{
 
183
    for(std::string::const_iterator c = Text.begin(); c != Text.end(); ++c)
 
184
        glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, *c);
 
185
}
 
186
 
 
187
void display()
 
188
{
 
189
    glDisable(GL_BLEND);
 
190
    glRasterPos2i( 0, 0 );
 
191
    glDrawPixels( g_ImageWidth, g_ImageHeight, GL_RGB, GL_UNSIGNED_BYTE, g_Image );
 
192
 
 
193
    // Prompt the user for input ...
 
194
    if(g_text_prompt.size())
 
195
    {
 
196
        double viewport[4];
 
197
        glGetDoublev(GL_VIEWPORT, viewport);
 
198
 
 
199
        glEnable(GL_BLEND);
 
200
        glColor4d(0, 0, 0.5, 0.5);
 
201
        glRectd(viewport[0], viewport[3] / 2 + 20, viewport[2], viewport[3] / 2 - 10);
 
202
 
 
203
        glColor4d(1, 1, 1, 1);
 
204
        glRasterPos2d(viewport[0] + 10, viewport[3] / 2);
 
205
        draw_text(g_text_prompt);
 
206
        draw_text(g_text_input);
 
207
        draw_text("_");
 
208
    }
 
209
 
 
210
    // We're done ...
 
211
    glFlush();
 
212
}
 
213
 
 
214
void full_display()
 
215
{
 
216
    glDisable( GL_SCISSOR_TEST );
 
217
    glClear( GL_COLOR_BUFFER_BIT );
 
218
 
 
219
    display();
 
220
}
 
221
 
 
222
void reshape( int w, int h )
 
223
{
 
224
    glViewport( 0, 0, ( GLsizei ) w, ( GLsizei ) h );
 
225
    glMatrixMode( GL_PROJECTION );
 
226
    glLoadIdentity();
 
227
    gluOrtho2D( 0.0, ( GLdouble ) w, 0.0, ( GLdouble ) h );
 
228
    glMatrixMode( GL_MODELVIEW );
 
229
    glLoadIdentity();
 
230
}
 
231
 
 
232
void idle( void )
 
233
{
 
234
    if ( !DDProcessMessageAsync( 0, 1000 ) )
 
235
        glutIdleFunc( 0 );
 
236
}
 
237
 
 
238
void keyboard( unsigned char key, int x, int y )
 
239
{
 
240
    // If the text prompt is active, it consumes all input ...
 
241
    if(g_text_prompt.size())
 
242
    {
 
243
        switch(key)
 
244
        {
 
245
        case 8: // Backspace
 
246
            if(g_text_input.size())
 
247
            {
 
248
                std::string::iterator i = g_text_input.end();
 
249
                g_text_input.erase(--i);
 
250
            }
 
251
            glutPostRedisplay();
 
252
            break;
 
253
        case 3: // CTRL-C
 
254
        case 27: // ESC
 
255
            g_text_prompt = "";
 
256
            g_text_input = "";
 
257
            g_text_ok_callback = 0;
 
258
            glutPostRedisplay();
 
259
            break;
 
260
 
 
261
        case 13: // ENTER
 
262
            g_text_ok_callback(g_text_input);
 
263
            g_text_prompt= "";
 
264
            g_text_input = "";
 
265
            g_text_ok_callback = 0;
 
266
            glutPostRedisplay();
 
267
        default:
 
268
            if(isprint(key))
 
269
            {
 
270
                g_text_input += key;
 
271
                glutPostRedisplay();
 
272
            }
 
273
            break;
 
274
        }
 
275
        return;
 
276
    }
 
277
 
 
278
    // No text prompt ...
 
279
    switch ( key )
 
280
    {
 
281
    case 'w':
 
282
        text_prompt("Save TIFF: ", append_path(get_current_working_directory(), g_Filename), &write_tiff);
 
283
        break;
 
284
    case 27: // ESC
 
285
    case 'q':
 
286
        exit( 0 );
 
287
        break;
 
288
    default:
 
289
        break;
 
290
    }
 
291
}
 
292
 
 
293
int main( int argc, char** argv )
 
294
{
 
295
    std::auto_ptr<std::streambuf> reset_level( new Aqsis::reset_level_buf(std::cerr) );
 
296
    std::auto_ptr<std::streambuf> show_timestamps( new Aqsis::timestamp_buf(std::cerr) );
 
297
    std::auto_ptr<std::streambuf> fold_duplicates( new Aqsis::fold_duplicates_buf(std::cerr) );
 
298
    std::auto_ptr<std::streambuf> show_level( new Aqsis::show_level_buf(std::cerr) );
 
299
    std::auto_ptr<std::streambuf> filter_level( new Aqsis::filter_by_level_buf(Aqsis::WARNING, std::cerr) );
 
300
 
 
301
    int port = -1;
 
302
    char *portStr = getenv( "AQSIS_DD_PORT" );
 
303
 
 
304
    if ( portStr != NULL )
 
305
    {
 
306
        port = atoi( portStr );
 
307
    }
 
308
 
 
309
    if ( -1 == DDInitialise( NULL, port ) )
 
310
    {
 
311
        std::cerr << error << "Could not open communications channel to Aqsis" << std::endl;
 
312
        return 1;
 
313
    }
 
314
 
 
315
    glutInit( &argc, argv );
 
316
 
 
317
    // Process messages until we have enough data to create our window ...
 
318
    while ( 0 == g_Window )
 
319
    {
 
320
        if ( !DDProcessMessage() )
 
321
        {
 
322
            std::cerr << "Premature end of messages" << std::endl;
 
323
            return 2;
 
324
        }
 
325
    }
 
326
 
 
327
    // Start the glut message loop ...
 
328
    glutDisplayFunc( full_display );
 
329
    glutReshapeFunc( reshape );
 
330
    glutKeyboardFunc( keyboard );
 
331
    glutIdleFunc( idle );
 
332
    glutCreateMenu(menu);
 
333
    glutAddMenuEntry("Write TIFF file", 1);
 
334
    glutAttachMenu(GLUT_RIGHT_BUTTON);
 
335
 
 
336
    // Setup GL context.
 
337
    glClearColor( 0.0, 0.0, 0.0, 0.0 );
 
338
    glDisable( GL_DEPTH_TEST );
 
339
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
340
    glShadeModel( GL_FLAT );
 
341
    glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
 
342
    glClear( GL_COLOR_BUFFER_BIT );
 
343
 
 
344
    // Start up.
 
345
    glutMainLoop();
 
346
 
 
347
    // Lose our image buffer ...
 
348
    delete g_Image;
 
349
 
 
350
    return 0;
 
351
}
 
352
 
 
353
//----------------------------------------------------------------------------
 
354
// Functions required by libdd.
 
355
 
 
356
SqDDMessageFormatResponse frmt( DataFormat_Signed32 );
 
357
SqDDMessageCloseAcknowledge closeack;
 
358
 
 
359
TqInt Query( SOCKET s, SqDDMessageBase* pMsgB )
 
360
{
 
361
    switch ( pMsgB->m_MessageID )
 
362
    {
 
363
    case MessageID_FormatQuery:
 
364
        {
 
365
            SqDDMessageFormatQuery* pMsg = static_cast<SqDDMessageFormatQuery*>(pMsgB);
 
366
            g_Format = pMsg->m_Formats[0];
 
367
            frmt.m_DataFormat = g_Format;
 
368
            if ( DDSendMsg( s, &frmt ) <= 0 )
 
369
                return ( -1 );
 
370
        }
 
371
        break;
 
372
    }
 
373
 
 
374
    return ( 0 );
 
375
}
 
376
 
 
377
TqInt Open( SOCKET s, SqDDMessageBase* pMsgB )
 
378
{
 
379
    SqDDMessageOpen * const message = static_cast<SqDDMessageOpen*>( pMsgB );
 
380
 
 
381
    g_ImageWidth = ( message->m_CropWindowXMax - message->m_CropWindowXMin );
 
382
    g_ImageHeight = ( message->m_CropWindowYMax - message->m_CropWindowYMin );
 
383
    g_PixelsProcessed = 0;
 
384
 
 
385
    g_Channels = message->m_Channels;
 
386
 
 
387
    g_CWXmin = message->m_CropWindowXMin;
 
388
    g_CWYmin = message->m_CropWindowYMin;
 
389
    g_CWXmax = message->m_CropWindowXMax;
 
390
    g_CWYmax = message->m_CropWindowYMax;
 
391
 
 
392
    g_Image = new GLubyte[ g_ImageWidth * g_ImageHeight * 3 ];
 
393
    //memset( g_Image, 128, g_ImageWidth * g_ImageHeight * 3 );
 
394
    for (TqInt i = 0; i < g_ImageHeight; i ++) {
 
395
        for (TqInt j=0; j < g_ImageWidth; j++)
 
396
        {
 
397
            int     t       = 0;
 
398
            GLubyte d = 255;
 
399
 
 
400
            if ( ( (g_ImageHeight - 1 - i) & 31 ) < 16 ) t ^= 1;
 
401
            if ( ( j & 31 ) < 16 ) t ^= 1;
 
402
 
 
403
            if ( t )
 
404
            {
 
405
                d      = 128;
 
406
            }
 
407
            g_Image[3 * (i*g_ImageWidth + j) ] = d;
 
408
            g_Image[3 * (i*g_ImageWidth + j) + 1] = d;
 
409
            g_Image[3 * (i*g_ImageWidth + j) + 2] = d;
 
410
        }
 
411
    }
 
412
 
 
413
 
 
414
    //  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
 
415
    glutInitDisplayMode( GLUT_SINGLE | GLUT_RGBA );
 
416
    glutInitWindowSize( g_ImageWidth, g_ImageHeight );
 
417
    g_Window = glutCreateWindow( get_window_title().c_str() );
 
418
 
 
419
    return ( 0 );
 
420
}
 
421
 
 
422
#define INT_MULT(a,b,t) ( (t) = (a) * (b) + 0x80, ( ( ( (t)>>8 ) + (t) )>>8 ) )
 
423
#define INT_PRELERP(p, q, a, t) ( (p) + (q) - INT_MULT( a, p, t) )
 
424
 
 
425
TqInt Data( SOCKET s, SqDDMessageBase* pMsgB )
 
426
{
 
427
    SqDDMessageData * const message = static_cast<SqDDMessageData*>( pMsgB );
 
428
 
 
429
    const TqInt linelength = g_ImageWidth * 3;
 
430
    char* bucket = reinterpret_cast<char*>( &message->m_Data );
 
431
 
 
432
    // CHeck if the beck is not at all within the crop window.
 
433
    if ( message->m_XMin > g_CWXmax || message->m_XMaxPlus1 < g_CWXmin ||
 
434
            message->m_YMin > g_CWYmax || message->m_YMaxPlus1 < g_CWYmin )
 
435
        return ( 0 );
 
436
 
 
437
    for ( TqInt y = message->m_YMin - g_CWYmin; y < message->m_YMaxPlus1 - g_CWYmin; y++ )
 
438
    {
 
439
        for ( TqInt x = message->m_XMin - g_CWXmin; x < message->m_XMaxPlus1 - g_CWXmin; x++ )
 
440
        {
 
441
            if ( x >= 0 && y >= 0 && x < g_ImageWidth && y < g_ImageHeight )
 
442
            {
 
443
                const TqInt so = ( ( g_ImageHeight - y - 1 ) * linelength ) + ( x * 3 );
 
444
 
 
445
                TqFloat value0, value1, value2;
 
446
                TqFloat alpha = 255.0f;
 
447
                if ( g_Channels >= 3 )
 
448
                {
 
449
                    value0 = reinterpret_cast<TqFloat*>( bucket ) [ 0 ];
 
450
                    value1 = reinterpret_cast<TqFloat*>( bucket ) [ 1 ];
 
451
                    value2 = reinterpret_cast<TqFloat*>( bucket ) [ 2 ];
 
452
                }
 
453
                else
 
454
                {
 
455
                    value0 = reinterpret_cast<TqFloat*>( bucket ) [ 0 ];
 
456
                    value1 = reinterpret_cast<TqFloat*>( bucket ) [ 0 ];
 
457
                    value2 = reinterpret_cast<TqFloat*>( bucket ) [ 0 ];
 
458
                }
 
459
 
 
460
                if ( g_Channels > 3 )
 
461
                    alpha = (reinterpret_cast<TqFloat*>( bucket ) [ 3 ]);
 
462
 
 
463
                if( !( quantize_zeroval == 0.0f &&
 
464
                        quantize_oneval  == 0.0f &&
 
465
                        quantize_minval  == 0.0f &&
 
466
                        quantize_maxval  == 0.0f ) )
 
467
                {
 
468
                    value0 = ROUND(quantize_zeroval + value0 * (quantize_oneval - quantize_zeroval) + dither_val );
 
469
                    value0 = CLAMP(value0, quantize_minval, quantize_maxval) ;
 
470
                    value1 = ROUND(quantize_zeroval + value1 * (quantize_oneval - quantize_zeroval) + dither_val );
 
471
                    value1 = CLAMP(value1, quantize_minval, quantize_maxval) ;
 
472
                    value2 = ROUND(quantize_zeroval + value2 * (quantize_oneval - quantize_zeroval) + dither_val );
 
473
                    value2 = CLAMP(value2, quantize_minval, quantize_maxval) ;
 
474
                    alpha  = ROUND(quantize_zeroval + alpha * (quantize_oneval - quantize_zeroval) + dither_val );
 
475
                    alpha  = CLAMP(alpha, quantize_minval, quantize_maxval) ;
 
476
                }
 
477
                else if ( g_Format != DataFormat_Unsigned8 )
 
478
                {
 
479
                    // If we are displaying an FP image we will need to quantize ourselves.
 
480
                    value0 *= 255;
 
481
                    value1 *= 255;
 
482
                    value2 *= 255;
 
483
                    alpha  *= 255;
 
484
                }
 
485
 
 
486
                // C� = INT_PRELERP( A�, B�, b, t )
 
487
                TqInt t;
 
488
                if( alpha > 0 )
 
489
                {
 
490
                    int A = INT_PRELERP( g_Image[ so + 0 ], value0, alpha, t );
 
491
                    int B = INT_PRELERP( g_Image[ so + 1 ], value1, alpha, t );
 
492
                    int C = INT_PRELERP( g_Image[ so + 2 ], value2, alpha, t );
 
493
                    g_Image[ so + 0 ] = CLAMP( A, 0, 255 );
 
494
                    g_Image[ so + 1 ] = CLAMP( B, 0, 255 );
 
495
                    g_Image[ so + 2 ] = CLAMP( C, 0, 255 );
 
496
                }
 
497
            }
 
498
            bucket += message->m_ElementSize;
 
499
        }
 
500
    }
 
501
 
 
502
    //std::cerr << message->m_XMin << ", " << message->m_YMin << " - " << message->m_XMaxPlus1 << ", " << message->m_YMaxPlus1 << std::endl;
 
503
 
 
504
    const TqInt BucketX = message->m_XMin - g_CWXmin;
 
505
    const TqInt BucketY = g_ImageHeight - ( message->m_YMaxPlus1 - g_CWYmin );
 
506
    const TqInt BucketW = message->m_XMaxPlus1 - message->m_XMin;
 
507
    const TqInt BucketH = message->m_YMaxPlus1 - message->m_YMin;
 
508
 
 
509
    glEnable( GL_SCISSOR_TEST );
 
510
    glScissor( BucketX, BucketY, BucketW, BucketH );
 
511
    display();
 
512
 
 
513
    g_PixelsProcessed += (BucketW * BucketH);
 
514
    glutSetWindowTitle(get_window_title().c_str());
 
515
 
 
516
    return ( 0 );
 
517
}
 
518
 
 
519
TqInt Close( SOCKET s, SqDDMessageBase* pMsgB )
 
520
{
 
521
    glutPostRedisplay();
 
522
    if ( DDSendMsg( s, &closeack ) <= 0 )
 
523
        return ( -1 );
 
524
    else
 
525
        return ( 1 );
 
526
}
 
527
 
 
528
TqInt Abandon( SOCKET s, SqDDMessageBase* pMsgB )
 
529
{
 
530
    return ( 1 );
 
531
}
 
532
 
 
533
TqInt HandleMessage( SOCKET s, SqDDMessageBase* pMsgB )
 
534
{
 
535
    switch ( pMsgB->m_MessageID )
 
536
    {
 
537
    case MessageID_Filename:
 
538
        {
 
539
            SqDDMessageFilename * message = static_cast<SqDDMessageFilename*>( pMsgB );
 
540
            g_Filename = message->m_String;
 
541
        }
 
542
        break;
 
543
 
 
544
    case MessageID_UserParam:
 
545
        {
 
546
            SqDDMessageUserParam * pMsg = static_cast<SqDDMessageUserParam*>( pMsgB );
 
547
            // Check if we understand the parameter.
 
548
            if( strncmp( pMsg->m_NameAndData, "quantize", pMsg->m_NameLength ) == 0 )
 
549
            {
 
550
                TqFloat* quantize = reinterpret_cast<TqFloat*>( &pMsg->m_NameAndData[ pMsg->m_NameLength + 1 ] );
 
551
                quantize_zeroval = quantize[0];
 
552
                quantize_oneval  = quantize[1];
 
553
                quantize_minval  = quantize[2];
 
554
                quantize_maxval  = quantize[3];
 
555
            }
 
556
        }
 
557
        break;
 
558
    }
 
559
    return ( 0 );
 
560
}
 
561
 
 
562
 
 
563