本文整理汇总了C++中MI_WIDTH函数的典型用法代码示例。如果您正苦于以下问题:C++ MI_WIDTH函数的具体用法?C++ MI_WIDTH怎么用?C++ MI_WIDTH使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MI_WIDTH函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stairs_handle_event
ENTRYPOINT Bool
stairs_handle_event (ModeInfo *mi, XEvent *event)
{
stairsstruct *sp = &stairs[MI_SCREEN(mi)];
if (event->xany.type == ButtonPress &&
event->xbutton.button == Button1)
{
sp->button_down_p = True;
gltrackball_start (sp->trackball,
event->xbutton.x, event->xbutton.y,
MI_WIDTH (mi), MI_HEIGHT (mi));
return True;
}
else if (event->xany.type == ButtonRelease &&
event->xbutton.button == Button1)
{
sp->button_down_p = False;
return True;
}
else if (event->xany.type == ButtonPress &&
(event->xbutton.button == Button4 ||
event->xbutton.button == Button5 ||
event->xbutton.button == Button6 ||
event->xbutton.button == Button7))
{
gltrackball_mousewheel (sp->trackball, event->xbutton.button, 10,
!!event->xbutton.state);
return True;
}
else if (event->xany.type == MotionNotify &&
sp->button_down_p)
{
gltrackball_track (sp->trackball,
event->xmotion.x, event->xmotion.y,
MI_WIDTH (mi), MI_HEIGHT (mi));
return True;
}
else if (event->xany.type == KeyPress)
{
KeySym keysym;
char c = 0;
XLookupString (&event->xkey, &c, 1, &keysym, 0);
if (c == ' ')
{
gltrackball_reset (sp->trackball);
return True;
}
}
return False;
}
示例2: pinion_handle_event
ENTRYPOINT Bool
pinion_handle_event (ModeInfo *mi, XEvent *event)
{
pinion_configuration *pp = &pps[MI_SCREEN(mi)];
if (event->xany.type == ButtonPress &&
event->xbutton.button == Button1)
{
pp->button_down_p = True;
gltrackball_start (pp->trackball,
event->xbutton.x, event->xbutton.y,
MI_WIDTH (mi), MI_HEIGHT (mi));
return True;
}
else if (event->xany.type == ButtonRelease &&
event->xbutton.button == Button1)
{
pp->button_down_p = False;
return True;
}
else if (event->xany.type == ButtonPress &&
(event->xbutton.button == Button4 ||
event->xbutton.button == Button5 ||
event->xbutton.button == Button6 ||
event->xbutton.button == Button7))
{
gltrackball_mousewheel (pp->trackball, event->xbutton.button, 5,
!!event->xbutton.state);
return True;
}
else if (event->xany.type == MotionNotify &&
pp->button_down_p)
{
gltrackball_track (pp->trackball,
event->xmotion.x, event->xmotion.y,
MI_WIDTH (mi), MI_HEIGHT (mi));
return True;
}
else if (event->xany.type == KeyPress)
{
KeySym keysym;
char c = 0;
XLookupString (&event->xkey, &c, 1, &keysym, 0);
if (c == ' ' && debug_one_gear_p && pp->ngears)
{
delete_gear (mi, pp->gears[0]);
return True;
}
}
return False;
}
示例3: init_galaxy
void
init_galaxy(ModeInfo * mi)
{
Display *display = MI_DISPLAY(mi);
unistruct *gp;
if (universes == NULL) {
if ((universes = (unistruct *) calloc(MI_NUM_SCREENS(mi),
sizeof (unistruct))) == NULL)
return;
}
gp = &universes[MI_SCREEN(mi)];
gp->f_hititerations = MI_CYCLES(mi);
gp->clip.left = 0;
gp->clip.top = 0;
gp->clip.right = MI_WIDTH(mi);
gp->clip.bottom = MI_HEIGHT(mi);
gp->scale = (double) (gp->clip.right + gp->clip.bottom) / 8.0;
gp->midx = gp->clip.right / 2;
gp->midy = gp->clip.bottom / 2;
if (MI_IS_FULLRANDOM(mi)) {
gp->fisheye = !(NRAND(3));
if (!gp->fisheye)
gp->tracks = (Bool) (LRAND() & 1);
} else {
gp->fisheye = fisheye;
gp->tracks = tracks;
}
if (!startover(mi))
return;
if (gp->fisheye) {
if (gp->pixmap != None)
XFreePixmap(display, gp->pixmap);
if ((gp->pixmap = XCreatePixmap(display, MI_WINDOW(mi),
MI_WIDTH(mi), MI_HEIGHT(mi),
MI_DEPTH(mi))) == None) {
gp->fisheye = False;
}
}
if (gp->fisheye) {
XSetGraphicsExposures(display, MI_GC(mi), False);
gp->scale *= Z_OFFSET;
gp->star_scale_Z = (gp->scale * .005);
/* don't want any exposure events from XCopyPlane */
}
}
示例4: init_stars
static void
init_stars (ModeInfo *mi)
{
planetstruct *gp = &planets[MI_SCREEN(mi)];
int i, j;
int width = MI_WIDTH(mi);
int height = MI_HEIGHT(mi);
int size = (width > height ? width : height);
int nstars = size * size / 80;
int max_size = 3;
GLfloat inc = 0.5;
int steps = max_size / inc;
GLfloat scale = 1;
if (MI_WIDTH(mi) > 2560) { /* Retina displays */
scale *= 2;
nstars /= 2;
}
gp->starlist = glGenLists(1);
glNewList(gp->starlist, GL_COMPILE);
for (j = 1; j <= steps; j++)
{
glPointSize(inc * j * scale);
glBegin (GL_POINTS);
for (i = 0; i < nstars / steps; i++)
{
GLfloat d = 0.1;
GLfloat r = 0.15 + frand(0.3);
GLfloat g = r + frand(d) - d;
GLfloat b = r + frand(d) - d;
GLfloat x = frand(1)-0.5;
GLfloat y = frand(1)-0.5;
GLfloat z = ((random() & 1)
? frand(1)-0.5
: (BELLRAND(1)-0.5)/12); /* milky way */
d = sqrt (x*x + y*y + z*z);
x /= d;
y /= d;
z /= d;
glColor3f (r, g, b);
glVertex3f (x, y, z);
gp->starcount++;
}
glEnd ();
}
glEndList ();
check_gl_error("stars initialization");
}
示例5: new_label
static void
new_label (ModeInfo *mi)
{
pinion_configuration *pp = &pps[MI_SCREEN(mi)];
char label[1024];
int i;
gear *g = 0;
if (pp->mouse_gear_id)
for (i = 0; i < pp->ngears; i++)
if (pp->gears[i]->id == pp->mouse_gear_id)
{
g = pp->gears[i];
break;
}
if (!g)
*label = 0;
else
{
sprintf (label, "%d teeth\n", (int) g->nteeth);
rpm_string (g->rpm, label + strlen(label));
if (debug_p)
sprintf (label + strlen (label), "\nPolys: %d\nModel: %s (%.2f)\n",
g->polygons,
(g->size == INVOLUTE_SMALL ? "small" :
g->size == INVOLUTE_MEDIUM ? "medium"
: "large"),
g->tooth_h * MI_HEIGHT(mi));
}
glNewList (pp->title_list, GL_COMPILE);
if (*label)
{
XFontStruct *f;
GLuint fl;
if (MI_WIDTH(mi) >= 500 && MI_HEIGHT(mi) >= 375)
f = pp->xfont1, fl = pp->font1_dlist; /* big font */
else if (MI_WIDTH(mi) >= 350 && MI_HEIGHT(mi) >= 260)
f = pp->xfont2, fl = pp->font2_dlist; /* small font */
else
f = pp->xfont3, fl = pp->font3_dlist; /* tiny font */
glColor3f (0.8, 0.8, 0);
print_gl_string (mi->dpy, f, fl,
mi->xgwa.width, mi->xgwa.height,
10, mi->xgwa.height - 10,
label, False);
}
glEndList ();
}
示例6: antspotlight_handle_event
/* event handling */
ENTRYPOINT Bool antspotlight_handle_event(ModeInfo *mi, XEvent *event)
{
antspotlightstruct *mp = &antspotlight[MI_SCREEN(mi)];
switch(event->xany.type) {
case ButtonPress:
switch(event->xbutton.button) {
case Button1:
mp->button_down_p = True;
gltrackball_start(mp->trackball,
event->xbutton.x, event->xbutton.y,
MI_WIDTH (mi), MI_HEIGHT (mi));
break;
case Button4:
mp->mag = max(mp->mag-1, 1);
break;
case Button5:
mp->mag = min(mp->mag+1, MAX_MAGNIFICATION);
break;
}
break;
case ButtonRelease:
switch(event->xbutton.button) {
case Button1:
mp->button_down_p = False;
break;
}
break;
case MotionNotify:
if(mp->button_down_p)
gltrackball_track(mp->trackball,
event->xmotion.x, event->xmotion.y,
MI_WIDTH (mi), MI_HEIGHT (mi));
break;
default:
return False;
}
return True;
}
示例7: loading_msg
static void
loading_msg (ModeInfo *mi, int n)
{
carousel_state *ss = &sss[MI_SCREEN(mi)];
int wire = MI_IS_WIREFRAME(mi);
char text[100];
GLfloat scale;
if (wire) return;
if (n == 0)
sprintf (text, "Loading images...");
else
sprintf (text, "Loading images... (%d%%)",
(int) (n * 100 / MI_COUNT(mi)));
if (ss->loading_sw == 0) /* only do this once, so that the string doesn't move. */
ss->loading_sw = texture_string_width (ss->texfont, text, &ss->loading_sh);
scale = ss->loading_sh / (GLfloat) MI_HEIGHT(mi);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0, MI_WIDTH(mi), 0, MI_HEIGHT(mi));
glTranslatef ((MI_WIDTH(mi) - ss->loading_sw) / 2,
(MI_HEIGHT(mi) - ss->loading_sh) / 2,
0);
glColor3f (1, 1, 0);
glEnable (GL_TEXTURE_2D);
glDisable (GL_DEPTH_TEST);
print_texture_string (ss->texfont, text);
glEnable (GL_DEPTH_TEST);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glFinish();
glXSwapBuffers (MI_DISPLAY (mi), MI_WINDOW(mi));
}
示例8: providence_handle_event
/* event handling */
ENTRYPOINT Bool providence_handle_event(ModeInfo *mi, XEvent *event)
{
providencestruct *mp = &providence[MI_SCREEN(mi)];
switch(event->xany.type) {
case ButtonPress:
switch(event->xbutton.button) {
case Button1:
mp->button_down_p = True;
gltrackball_start(mp->trackball,
event->xbutton.x, event->xbutton.y,
MI_WIDTH (mi), MI_HEIGHT (mi));
break;
case Button4:
mp->camera_velocity += 1.0;
break;
case Button5:
mp->camera_velocity -= 1.0;
break;
}
break;
case ButtonRelease:
switch(event->xbutton.button) {
case Button1:
mp->button_down_p = False;
break;
}
break;
case MotionNotify:
if(mp->button_down_p)
gltrackball_track(mp->trackball,
event->xmotion.x, event->xmotion.y,
MI_WIDTH (mi), MI_HEIGHT (mi));
break;
default:
return False;
}
return True;
}
示例9: init_noof
ENTRYPOINT void
init_noof (ModeInfo *mi)
{
int i;
noof_configuration *bp;
if (!bps) {
bps = (noof_configuration *)
calloc (MI_NUM_SCREENS(mi), sizeof (noof_configuration));
if (!bps) {
fprintf(stderr, "%s: out of memory\n", progname);
exit(1);
}
}
bp = &bps[MI_SCREEN(mi)];
bp->glx_context = init_GL(mi);
glDrawBuffer(GL_FRONT);
glClearColor(0.0, 0.0, 0.0, 1.0);
glEnable(GL_LINE_SMOOTH);
glShadeModel(GL_FLAT);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
for (i = 0; i < N_SHAPES; i++)
initshapes(bp, i);
reshape_noof (mi, MI_WIDTH(mi), MI_HEIGHT(mi));
}
示例10: InitDrop
static void InitDrop(ModeInfo * mi, rainstruct *rp, dropstruct *drop)
{
/* Where does the drop fall in the pool?
At least 20% of height from top and not completely at the bottom */
int yMin = MI_HEIGHT(mi) / 5;
int yMax = MI_HEIGHT(mi) - ((MAX_RADIUS * 3) / 2);
drop->pool.x = 0;
drop->pool.y = yMin + NRAND(yMax - yMin);
/* How fast does it fall? */
drop->offset.x = 5 + NRAND(5);
drop->offset.y = 20 + NRAND(20);
/* Where does the drop start */
drop->drop.x = NRAND(MI_WIDTH(mi));
drop->drop.height = 0;
drop->drop.width = drop->drop.x + drop->offset.x;
drop->drop.y = drop->drop.height + drop->offset.y;
/* How large is the pool and how fast does it grow? */
drop->radius = 0;
drop->radius_step = 1 + NRAND(2);
drop->max_radius = (MAX_RADIUS / 2) + NRAND(MAX_RADIUS / 2);
/* Colored drops? */
if (rp->colored_drops)
{
if (rp->base_color == 0)
drop->color = MI_PIXEL(mi, NRAND(MI_NPIXELS(mi)));
else
drop->color = rp->base_color + (NRAND(2) == 1 ? -1 : 1) * NRAND(12);
}
else
drop->color = MI_WHITE_PIXEL(mi);
}
示例11: planet_handle_event
ENTRYPOINT Bool
planet_handle_event (ModeInfo *mi, XEvent *event)
{
planetstruct *gp = &planets[MI_SCREEN(mi)];
if (gltrackball_event_handler (event, gp->trackball,
MI_WIDTH (mi), MI_HEIGHT (mi),
&gp->button_down_p))
return True;
else if (event->xany.type == KeyPress)
{
KeySym keysym;
char c = 0;
XLookupString (&event->xkey, &c, 1, &keysym, 0);
if (c == ' ' || c == '\t' || c == '\r' || c == '\n')
{
switch (gp->state) {
case FLAT: case ICO: case STEL: case AXIS: case ICO2:
gp->ratio = 1;
break;
default:
break;
}
return True;
}
}
return False;
}
示例12: init_hypertorus
ENTRYPOINT void init_hypertorus(ModeInfo *mi)
{
hypertorusstruct *hp;
if (hyper == NULL)
{
hyper = (hypertorusstruct *)calloc(MI_NUM_SCREENS(mi),
sizeof(hypertorusstruct));
if (hyper == NULL)
return;
}
hp = &hyper[MI_SCREEN(mi)];
hp->trackballs[0] = gltrackball_init();
hp->trackballs[1] = gltrackball_init();
hp->current_trackball = 0;
hp->button_pressed = False;
/* make multiple screens rotate at slightly different rates. */
hp->speed_scale = 0.9 + frand(0.3);
if ((hp->glx_context = init_GL(mi)) != NULL)
{
reshape_hypertorus(mi,MI_WIDTH(mi),MI_HEIGHT(mi));
glDrawBuffer(GL_BACK);
init(mi);
}
else
{
MI_CLEARWINDOW(mi);
}
}
示例13: 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);
}
}
示例14: bit_handle_event
ENTRYPOINT Bool
bit_handle_event (ModeInfo *mi, XEvent *event)
{
bit_configuration *bp = &bps[MI_SCREEN(mi)];
if (gltrackball_event_handler (event, bp->trackball,
MI_WIDTH (mi), MI_HEIGHT (mi),
&bp->button_down_p))
return True;
else if (event->xany.type == KeyPress)
{
KeySym keysym;
char c = 0;
XLookupString (&event->xkey, &c, 1, &keysym, 0);
if (keysym == XK_Up || keysym == XK_Left || keysym == XK_Prior)
c = '1';
else if (keysym == XK_Down || keysym == XK_Right || keysym == XK_Next)
c = '0';
if (c == ' ' || c == '\t' || c == '\n' || c == '1' || c == '0')
{
bp->kbd = c;
return True;
}
}
return False;
}
示例15: 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);
}