コード例 #1
0
ファイル: uglugi.c プロジェクト: phoboz/vmx
UGL_STATUS uglGraphicsDevDestroy (
    UGL_DEVICE_ID  devId
    ) {
    UGL_STATUS  status;

    if (devId == UGL_NULL) {
        return (UGL_STATUS_ERROR);
    }

    /* Free scratch buffer */
    if (devId->pScratchBuf != UGL_NULL) {
        UGL_FREE (devId->pScratchBuf);
    }

    /* Destroy default graphics context */
    if (devId->defaultGc != UGL_NULL) {
        uglGcDestroy (devId->defaultGc);
    }

    /* Call driver specific device destroy method */
    status = (*devId->destroy) (devId);

    return (status);
}
コード例 #2
0
void windMLAllDemos(void)
    {
    UGL_BOOL windMLFlag = UGL_FALSE;
    UGL_FB_INFO fbInfo;
    UGL_EVENT event;
    UGL_EVENT_SERVICE_ID eventServiceId;
    UGL_EVENT_Q_ID qId;
    UGL_INPUT_EVENT * pInputEvent;
    UGL_INPUT_DEVICE_ID keyboardDevId;
    UGL_DEVICE_ID devId;
    UGL_GC_ID gc;
    UGL_FONT_ID fontId;
    UGL_FONT_DEF fontDef;
    UGL_FONT_DRIVER_ID fontDrvId;
    UGL_ORD textOrigin = UGL_FONT_TEXT_UPPER_LEFT;
    int displayHeight, displayWidth;
    int textWidth, textHeight;
    static UGL_CHAR * message =
	"Do you want to use WindML exclusively ? (y/n) ";
    
    uglInitialize();

    uglDriverFind (UGL_DISPLAY_TYPE, 0, (UGL_UINT32 *)&devId);
    uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId);
    uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId);
    qId = uglEventQCreate (eventServiceId, 100);
    
    gc = uglGcCreate(devId);

    uglDriverFind (UGL_FONT_ENGINE_TYPE, 0, (UGL_UINT32 *)&fontDrvId);
    uglFontDriverInfo(fontDrvId, UGL_FONT_TEXT_ORIGIN, &textOrigin);

    uglFontFindString(fontDrvId, "familyName=Helvetica; pixelSize = 18",
		      &fontDef);

    if ((fontId = uglFontCreate(fontDrvId, &fontDef)) == UGL_NULL)
        {
 	printf("Font not found. Exiting.\n");
	return;       
        }

    uglInfo(devId, UGL_FB_INFO_REQ, &fbInfo);
    displayWidth = fbInfo.width;
    displayHeight = fbInfo.height;

    uglColorAlloc (devId, &colorTable[BLACK].rgbColor, UGL_NULL, 
                   &colorTable[BLACK].uglColor, 1);
    uglColorAlloc(devId, &colorTable[RED].rgbColor, UGL_NULL,
		  &colorTable[RED].uglColor, 1);
    
    uglBackgroundColorSet(gc, colorTable[BLACK].uglColor);
    uglForegroundColorSet(gc, colorTable[RED].uglColor);
    uglFontSet(gc, fontId);
    uglTextSizeGet(fontId, &textWidth, &textHeight, -1, message);
    uglTextDraw(gc, (displayWidth - textWidth) / 2, 
		(displayHeight - textHeight) / 2  - textHeight, -1, message);
/*    flushQ();
 */   
    if (uglEventGet (qId, &event, sizeof (event), UGL_WAIT_FOREVER)
	!= UGL_STATUS_Q_EMPTY)
	{
	pInputEvent = (UGL_INPUT_EVENT *)&event;
	    
	if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD &&
	    pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN)
	    {
	    switch(pInputEvent->type.keyboard.key)
		{
		case 'Y':
		case 'y':
		    windMLFlag = UGL_TRUE;
		    break;
		default:
		    windMLFlag = UGL_FALSE;
		}
	    }
	}
    
    uglFontDestroy (fontId);
    uglGcDestroy (gc);
    uglEventQDestroy (eventServiceId, qId);
    uglDeinitialize();
		   
    windMLPoint(windMLFlag);

    windMLLine(windMLFlag);
    
    windMLFlip(windMLFlag);

    windMLCube(windMLFlag);

    windMLBounce(windMLFlag);

    windMLGears(windMLFlag);

    windMLIcoTorus(windMLFlag);

    windMLOlympic(windMLFlag);

    windMLTexCube(windMLFlag);
    
    windMLTexCyl(windMLFlag);

    windMLTeapot(windMLFlag);

    windMLStencil(windMLFlag);

    windMLDrawPix(windMLFlag);

    windMLAccum(windMLFlag);

    return;
    }