~kamalmostafa/ubuntu/lucid/pdp/fix-504941-ftbfs

« back to all changes in this revision

Viewing changes to opengl/modules/pdp_3d_for.c

  • Committer: Bazaar Package Importer
  • Author(s): Guenter Geiger (Debian/GNU)
  • Date: 2005-03-15 22:21:05 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050315222105-1q287rsihmd9j1tb
Tags: 1:0.12.4-2
* fixed the hardcoded depends
* added 3dp library

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *   Pure Data Packet module.
3
 
 *   Copyright (c) by Tom Schouten <pdp@zzz.kotnet.org>
4
 
 *
5
 
 *   This program is free software; you can redistribute it and/or modify
6
 
 *   it under the terms of the GNU General Public License as published by
7
 
 *   the Free Software Foundation; either version 2 of the License, or
8
 
 *   (at your option) any later version.
9
 
 *
10
 
 *   This program is distributed in the hope that it will be useful,
11
 
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *   GNU General Public License for more details.
14
 
 *
15
 
 *   You should have received a copy of the GNU General Public License
16
 
 *   along with this program; if not, write to the Free Software
17
 
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
 
 *
19
 
 */
20
 
 
21
 
/* a for loop for 3dp packets
22
 
   this can later be adapted to a for loop for dpd packets. */
23
 
 
24
 
#include "pdp_opengl.h"
25
 
#include "pdp_internals.h"
26
 
 
27
 
 
28
 
typedef struct pdp_3d_for_struct
29
 
{
30
 
    t_object x_obj;
31
 
 
32
 
    t_int x_count;
33
 
 
34
 
    t_outlet *x_outlet_dpd;
35
 
    t_outlet *x_outlet_float;
36
 
 
37
 
} t_pdp_3d_for;
38
 
 
39
 
 
40
 
 
41
 
static void pdp_3d_for_input_0(t_pdp_3d_for *x, t_symbol *s, t_floatarg f)
42
 
{
43
 
    int i;
44
 
 
45
 
    /* trigger on "accumulate" */
46
 
 
47
 
    if (s == gensym("accumulate")){
48
 
        for (i=0; i<x->x_count; i++){
49
 
            outlet_float(x->x_outlet_float, (float)i);
50
 
            outlet_dpd(x->x_outlet_dpd, (int)f);
51
 
        }
52
 
    }
53
 
}
54
 
 
55
 
static void pdp_3d_for_count(t_pdp_3d_for *x, t_floatarg f)
56
 
{
57
 
    int count = (int)f;
58
 
    if (count >= 0) x->x_count = count;
59
 
}
60
 
 
61
 
 
62
 
static void pdp_3d_for_free(t_pdp_3d_for *x)
63
 
{
64
 
}
65
 
 
66
 
t_class *pdp_3d_for_class;
67
 
 
68
 
 
69
 
 
70
 
void *pdp_3d_for_new(t_floatarg f)
71
 
{
72
 
    int count = (int)f;
73
 
 
74
 
    t_pdp_3d_for *x = (t_pdp_3d_for *)pd_new(pdp_3d_for_class);
75
 
 
76
 
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("count"));
77
 
 
78
 
    x->x_outlet_dpd = outlet_new(&x->x_obj, &s_anything); 
79
 
    x->x_outlet_float = outlet_new(&x->x_obj, &s_float); 
80
 
    x->x_count = (count > 0) ? count : 1;
81
 
 
82
 
    return (void *)x;
83
 
}
84
 
 
85
 
 
86
 
#ifdef __cplusplus
87
 
extern "C"
88
 
{
89
 
#endif
90
 
 
91
 
 
92
 
void pdp_3d_for_setup(void)
93
 
{
94
 
 
95
 
 
96
 
    pdp_3d_for_class = class_new(gensym("3dp_for"), (t_newmethod)pdp_3d_for_new,
97
 
        (t_method)pdp_3d_for_free, sizeof(t_pdp_3d_for), 0, A_DEFFLOAT, A_NULL);
98
 
 
99
 
    class_addmethod(pdp_3d_for_class, (t_method)pdp_3d_for_input_0, gensym("dpd"),  A_SYMBOL, A_DEFFLOAT, A_NULL);
100
 
    class_addmethod(pdp_3d_for_class, (t_method)pdp_3d_for_count, gensym("count"), A_FLOAT, A_NULL);
101
 
 
102
 
}
103
 
 
104
 
#ifdef __cplusplus
105
 
}
106
 
#endif