本文整理汇总了C++中MI_COUNT函数的典型用法代码示例。如果您正苦于以下问题:C++ MI_COUNT函数的具体用法?C++ MI_COUNT怎么用?C++ MI_COUNT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MI_COUNT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Datetime_EnumerateInstances
void MI_CALL Datetime_EnumerateInstances(
Datetime_Self* self,
MI_Context* context,
const MI_Char* nameSpace,
const MI_Char* className,
const MI_PropertySet* propertySet,
MI_Boolean keysOnly,
const MI_Filter* filter)
{
Datetime inst;
Datetime_Construct(&inst, context);
MI_Datetime iv;
MI_Datetime ts;
memset(&ts, 0, sizeof(ts));
ts.isTimestamp = MI_TRUE;
ts.u.timestamp.year = 2001;
ts.u.timestamp.month = 12;
ts.u.timestamp.month = 25;
memset(&iv, 0, sizeof(iv));
iv.isTimestamp = MI_FALSE;
iv.u.interval.days = 365;
iv.u.interval.hours = 24;
iv.u.interval.minutes = 60;
// Datetime.timestamp:
Datetime_Set_timestamp(&inst, ts);
// Datetime.timestamp:
Datetime_Set_interval(&inst, iv);
// Datetime.timestamps:
{
MI_Datetime data[2];
data[0] = ts;
data[1] = ts;
Datetime_Set_timestamps(&inst, data, MI_COUNT(data));
}
// Datetime.interval:
{
MI_Datetime data[2];
data[0] = iv;
data[1] = iv;
Datetime_Set_intervals(&inst, data, MI_COUNT(data));
}
// Datetime.interval:
{
MI_Datetime data[2];
data[0] = ts;
data[1] = iv;
Datetime_Set_mixed(&inst, data, MI_COUNT(data));
}
Datetime_Post(&inst, context);
MI_PostResult(context, MI_RESULT_OK);
}
示例2: init_morph3d
void
init_morph3d(ModeInfo * mi)
{
morph3dstruct *mp;
if (morph3d == NULL) {
if ((morph3d = (morph3dstruct *) calloc(MI_NUM_SCREENS(mi),
sizeof (morph3dstruct))) == NULL)
return;
}
mp = &morph3d[MI_SCREEN(mi)];
mp->step = NRAND(90);
mp->VisibleSpikes = 1;
if ((mp->glx_context = init_GL(mi)) != NULL) {
reshape_morph3d(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
glDrawBuffer(GL_BACK);
mp->object = MI_COUNT(mi);
if (mp->object <= 0 || mp->object > 5)
mp->object = NRAND(5) + 1;
pinit(mi);
} else {
MI_CLEARWINDOW(mi);
}
}
示例3: draw_spikes
static void
draw_spikes (ModeInfo *mi)
{
ball_configuration *bp = &bps[MI_SCREEN(mi)];
GLfloat diam = 0.2;
GLfloat pos = bp->pos;
int i;
if (pos < 0) pos = -pos;
pos = (asin (0.5 + pos/2) - 0.5) * 2;
for (i = 0; i < MI_COUNT(mi); i++)
{
glPushMatrix();
glRotatef(bp->spikes[i*2], 0, 1, 0);
glRotatef(bp->spikes[i*2+1], 0, 0, 1);
glTranslatef(0.7, 0, 0);
glRotatef(-90, 0, 0, 1);
glScalef (diam, pos, diam);
glCallList (bp->spike_list);
glPopMatrix();
mi->polygon_count += (SPIKE_FACES + 1);
}
}
示例4: set_new_positions
/* Calculate new positions for all images.
*/
static void
set_new_positions(photopile_state *ss)
{
ModeInfo *mi = ss->mi;
int i;
for (i = 0; i < MI_COUNT(mi)+1; ++i)
{
image *frame = ss->frames + i;
GLfloat w = frame->w;
GLfloat h = frame->h;
GLfloat d = sqrt(w*w + h*h);
GLfloat leave = frand(M_PI * 2.0);
GLfloat enter = frand(M_PI * 2.0);
/* start position */
frame->pos[0] = frame->pos[3];
/* end position */
frame->pos[3].x = BELLRAND(MI_WIDTH(mi));
frame->pos[3].y = BELLRAND(MI_HEIGHT(mi));
frame->pos[3].angle = (frand(2.0) - 1.0) * max_tilt;
/* Try to keep the images mostly inside the screen bounds */
frame->pos[3].x = MAX(0.5*w, MIN(MI_WIDTH(mi)-0.5*w, frame->pos[3].x));
frame->pos[3].y = MAX(0.5*h, MIN(MI_HEIGHT(mi)-0.5*h, frame->pos[3].y));
/* intermediate points */
frame->pos[1] = offset_pos(frame->pos[0], leave, d * (0.5 + frand(1.0)));
frame->pos[2] = offset_pos(frame->pos[3], enter, d * (0.5 + frand(1.0)));
}
}
示例5: draw_puzzle
void
draw_puzzle(ModeInfo * mi)
{
puzzlestruct *pp;
if (puzzles == NULL)
return;
pp = &puzzles[MI_SCREEN(mi)];
if (pp->fixbuff == NULL)
return;
MI_IS_DRAWN(mi) = True;
pp->painted = False;
if (pp->movingBox) {
if (moveboxdelta(mi)) {
wrapupmovedelta(mi);
wrapupmove(mi);
pp->movingBox = False;
if (pp->moves++ > 2 * MI_COUNT(mi))
init_puzzle(mi);
}
} else {
if (setupmove(mi)) {
setupmovedelta(mi);
pp->movingBox = True;
}
}
}
示例6: init_lisa
ENTRYPOINT void
init_lisa (ModeInfo * mi)
{
int lctr;
lisacons *lc;
if (Lisa == NULL) {
if ((Lisa = (lisacons *) calloc(MI_NUM_SCREENS(mi),
sizeof (lisacons))) == NULL)
return;
}
lc = &Lisa[MI_SCREEN(mi)];
lc->width = MI_WIDTH(mi);
lc->height = MI_HEIGHT(mi);
lc->loopcount = 0;
lc->nlissajous = MI_COUNT(mi);
if (lc->nlissajous <= 0)
lc->nlissajous = 1;
MI_CLEARWINDOW(mi);
lc->painted = False;
if (lc->lissajous == NULL) {
if ((lc->lissajous = (lisas *) calloc(lc->nlissajous,
sizeof (lisas))) == NULL)
return;
for (lctr = 0; lctr < lc->nlissajous; lctr++) {
if (!initlisa(mi, &lc->lissajous[lctr]))
return;
lc->loopcount++;
}
} else {
refreshlisa(mi);
}
}
示例7: init_sierpinski
ENTRYPOINT void
init_sierpinski(ModeInfo * mi)
{
int i;
sierpinskistruct *sp;
if (tris == NULL) {
if ((tris = (sierpinskistruct *) calloc(MI_NUM_SCREENS(mi),
sizeof (sierpinskistruct))) == NULL)
return;
}
sp = &tris[MI_SCREEN(mi)];
sp->width = MI_WIDTH(mi);
sp->height = MI_HEIGHT(mi);
sp->total_npoints = MI_COUNT(mi);
if (sp->total_npoints < 1)
sp->total_npoints = 1;
sp->corners = MI_SIZE(mi);
if (sp->corners < 3 || sp->corners > 4) {
sp->corners = (int) (LRAND() & 1) + 3;
}
for (i = 0; i < sp->corners; i++) {
if (!sp->pointBuffer[i])
if ((sp->pointBuffer[i] = (XPoint *) malloc(sp->total_npoints *
sizeof (XPoint))) == NULL) {
free_sierpinski(sp);
return;
}
}
startover(mi);
}
示例8: draw_hydrostat
ENTRYPOINT void
draw_hydrostat (ModeInfo *mi)
{
hydrostat_configuration *bp = &bps[MI_SCREEN(mi)];
Display *dpy = MI_DISPLAY(mi);
Window window = MI_WINDOW(mi);
int i;
if (!bp->glx_context)
return;
glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(bp->glx_context));
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix ();
glScalef (0.03, 0.03, 0.03);
# ifdef USE_TRACKBALL
gltrackball_rotate (bp->trackball);
# endif
mi->polygon_count = 0;
if (opacity_arg < 1.0)
qsort (bp->squids, MI_COUNT(mi), sizeof(*bp->squids), cmp_squid);
for (i = 0; i < MI_COUNT(mi); i++)
{
squid *sq = bp->squids[i];
move_squid (mi, sq);
draw_squid (mi, sq);
if (opacity_arg < 1.0)
glClear (GL_DEPTH_BUFFER_BIT);
}
if (! (random() % 700)) /* Reverse the flow every now and then */
current_arg = -current_arg;
glPopMatrix ();
if (mi->fps_p) do_fps (mi);
glFinish();
glXSwapBuffers(dpy, window);
}
示例9: init_blot
void
init_blot(ModeInfo * mi)
{
Display *display = MI_DISPLAY(mi);
blotstruct *bp;
if (blots == NULL) {
if ((blots = (blotstruct *) calloc(MI_NUM_SCREENS(mi),
sizeof (blotstruct))) == NULL)
return;
}
bp = &blots[MI_SCREEN(mi)];
bp->width = MI_WIDTH(mi);
bp->height = MI_HEIGHT(mi);
bp->xmid = bp->width / 2;
bp->ymid = bp->height / 2;
bp->offset = 4;
bp->ysym = (int) LRAND() & 1;
bp->xsym = (bp->ysym) ? (int) LRAND() & 1 : 1;
if (MI_NPIXELS(mi) > 2)
bp->pix = NRAND(MI_NPIXELS(mi));
if (bp->offset <= 0)
bp->offset = 3;
if (MI_COUNT(mi) < 0)
bp->size = NRAND(-MI_COUNT(mi) + 1);
else
bp->size = MI_COUNT(mi);
/* Fudge the size so it takes up the whole screen */
bp->size *= (bp->width / 32 + 1) * (bp->height / 32 + 1);
if (!bp->pointBuffer || bp->pointBufferSize < bp->size * sizeof (XPoint)) {
if (bp->pointBuffer != NULL)
free(bp->pointBuffer);
bp->pointBufferSize = bp->size * sizeof (XPoint);
if ((bp->pointBuffer = (XPoint *) malloc(bp->pointBufferSize)) ==
NULL) {
return;
}
}
MI_CLEARWINDOW(mi);
XSetForeground(display, MI_GC(mi), MI_WHITE_PIXEL(mi));
bp->count = 0;
}
示例10: init_fire
ENTRYPOINT void
init_fire(ModeInfo * mi)
{
firestruct *fs;
/* allocate the main fire table if needed */
if (fire == NULL) {
if ((fire = (firestruct *) calloc(MI_NUM_SCREENS(mi),
sizeof(firestruct))) == NULL)
return;
}
/* initialise the per screen fire structure */
fs = &fire[MI_SCREEN(mi)];
fs->np = MI_COUNT(mi);
fs->fog = do_fog;
fs->shadows = do_shadows;
/* initialise fire particles if any */
if ((fs->np)&&(fs->p == NULL)) {
if ((fs->p = (part *) calloc(fs->np, sizeof(part))) == NULL) {
free_fire(fs);
return;
}
}
else if (fs->r == NULL) {
/* initialise rain particles if no fire particles */
if ((fs->r = (rain *) calloc(NUMPART, sizeof(part))) == NULL) {
free_fire(fs);
return;
}
}
/* check tree number */
if (do_texture)
fs->num_trees = (num_trees<MAX_TREES)?num_trees:MAX_TREES;
else
fs->num_trees = 0;
fs->trackball = gltrackball_init ();
/* xlock GL stuff */
if ((fs->glx_context = init_GL(mi)) != NULL) {
#ifndef STANDALONE
Reshape(mi); /* xlock mode */
#else
reshape_fire(mi,MI_WIDTH(mi),MI_HEIGHT(mi)); /* xscreensaver mode */
#endif
glDrawBuffer(GL_BACK);
if (!Init(mi)) {
free_fire(fs);
return;
}
} else {
MI_CLEARWINDOW(mi);
}
}
示例11: load_initial_images
static Bool
load_initial_images (ModeInfo *mi)
{
carousel_state *ss = &sss[MI_SCREEN(mi)];
int i;
Bool all_loaded_p = True;
for (i = 0; i < ss->nframes; i++)
if (! ss->frames[i]->loaded_p)
all_loaded_p = False;
if (all_loaded_p)
{
if (ss->nframes < MI_COUNT (mi))
{
/* The frames currently on the list are fully loaded.
Start the next one loading. (We run the image loader
asynchronously, but we load them one at a time.)
*/
load_image (mi, alloc_frame (mi));
}
else
{
/* The first batch of images are now all loaded!
Stagger the expire times so that they don't all drop out at once.
*/
time_t now = time((time_t *) 0);
int i;
for (i = 0; i < ss->nframes; i++)
{
image_frame *frame = ss->frames[i];
frame->r = 1.0;
frame->theta = i * 360.0 / ss->nframes;
frame->expires = now + (duration * (i + 1));
frame->mode = NORMAL;
}
/* Instead of always going clockwise, shuffle the expire times
of the frames so that they drop out in a random order.
*/
for (i = 0; i < ss->nframes; i++)
{
image_frame *frame1 = ss->frames[i];
image_frame *frame2 = ss->frames[random() % ss->nframes];
time_t swap = frame1->expires;
frame1->expires = frame2->expires;
frame2->expires = swap;
}
ss->awaiting_first_images_p = False;
}
}
loading_msg (mi, ss->nframes-1);
return !ss->awaiting_first_images_p;
}
示例12: init_cube
ENTRYPOINT void
init_cube (ModeInfo *mi)
{
int i;
cube_configuration *cc;
MI_INIT (mi, ccs);
cc = &ccs[MI_SCREEN(mi)];
if ((cc->glx_context = init_GL(mi)) != NULL) {
reshape_cube (mi, MI_WIDTH(mi), MI_HEIGHT(mi));
}
cc->trackball = gltrackball_init (False);
cc->ncolors = 256;
cc->colors = (XColor *) calloc(cc->ncolors, sizeof(XColor));
reset_colors (mi);
init_wave (mi);
cc->ncubes = MI_COUNT (mi);
if (cc->ncubes < 1) cc->ncubes = 1;
cc->cubes = (cube *) calloc (sizeof(cube), cc->ncubes);
for (i = 0; i < cc->ncubes; i++)
{
/* Set the size to roughly cover a 2x2 square on average. */
GLfloat scale = 1.8 / sqrt (cc->ncubes);
cube *cube = &cc->cubes[i];
double th = -(skew ? frand(skew) : 0) * M_PI / 180;
cube->x = (frand(1)-0.5);
cube->y = (frand(1)-0.5);
cube->z = frand(0.12);
cube->cth = cos(th);
cube->sth = sin(th);
cube->w = scale * (frand(1) + 0.2);
cube->d = scale * (frand(1) + 0.2);
if (cube->x < cc->min_x) cc->min_x = cube->x;
if (cube->y < cc->min_y) cc->min_y = cube->y;
if (cube->x > cc->max_x) cc->max_x = cube->x;
if (cube->y > cc->max_y) cc->max_y = cube->y;
}
/* Sorting by depth improves frame rate slightly. With 6000 polygons we get:
3.9 FPS unsorted;
3.1 FPS back to front;
4.3 FPS front to back.
*/
qsort (cc->cubes, cc->ncubes, sizeof(*cc->cubes), cmp_cubes);
}
示例13: make_plane
static void
make_plane (ModeInfo *mi)
{
hexstrut_configuration *bp = &bps[MI_SCREEN(mi)];
int n = MI_COUNT(mi) * 2;
GLfloat size = 2.0 / n;
int x, y;
GLfloat w = size;
GLfloat h = size * sqrt(3) / 2;
triangle **grid = (triangle **) calloc (n * n, sizeof(*grid));
for (y = 0; y < n; y++)
for (x = 0; x < n; x++)
{
triangle *t;
t = (triangle *) calloc (1, sizeof(*t));
t->p[0].x = (x - n/2) * w;
t->p[0].y = (y - n/2) * h;
if (y & 1)
t->p[0].x += w / 2;
t->p[1].x = t->p[0].x - w/2;
t->p[2].x = t->p[0].x + w/2;
t->p[1].y = t->p[0].y + h;
t->p[2].y = t->p[0].y + h;
if (x > 0)
{
triangle *t2 = grid[y * n + (x-1)];
link_neighbor (t, t2);
link_neighbor (t2, t);
}
if (y > 0)
{
triangle *t2 = grid[(y-1) * n + x];
link_neighbor (t, t2);
link_neighbor (t2, t);
if (x < n-1)
{
t2 = grid[(y-1) * n + (x+1)];
link_neighbor (t, t2);
link_neighbor (t2, t);
}
}
t->next = bp->triangles;
bp->triangles = t;
grid[y * n + x] = t;
bp->count++;
}
free (grid);
}
示例14: init_photopile
ENTRYPOINT void
init_photopile (ModeInfo *mi)
{
int screen = MI_SCREEN(mi);
photopile_state *ss;
int wire = MI_IS_WIREFRAME(mi);
if (sss == NULL) {
if ((sss = (photopile_state *)
calloc (MI_NUM_SCREENS(mi), sizeof(photopile_state))) == NULL)
return;
}
ss = &sss[screen];
ss->mi = mi;
if ((ss->glx_context = init_GL(mi)) != NULL) {
reshape_photopile (mi, MI_WIDTH(mi), MI_HEIGHT(mi));
clear_gl_error(); /* WTF? sometimes "invalid op" from glViewport! */
} else {
MI_CLEARWINDOW(mi);
}
ss->shadow = init_drop_shadow();
ss->texfont = load_texture_font (MI_DISPLAY(mi), "font");
if (debug_p)
hack_resources (MI_DISPLAY (mi));
ss->frames = (image *)calloc (MI_COUNT(mi) + 1, sizeof(image));
ss->nframe = 0;
if (!wire)
{
int i;
for (i = 0; i < MI_COUNT(mi) + 1; ++i)
{
glGenTextures (1, &(ss->frames[i].texid));
if (ss->frames[i].texid <= 0) abort();
}
}
ss->mode = EARLY;
load_image(mi); /* start loading the first image */
}
示例15: free_hydrostat
static void
free_hydrostat (ModeInfo *mi)
{
hydrostat_configuration *bp = &bps[MI_SCREEN(mi)];
int i;
if (!bp->squids)
return;
for (i = 0; i < MI_COUNT(mi); i++)
free_squid (bp->squids[i]);
free (bp->squids);
}