Esempio n. 1
0
// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
    // OSG init
    glutInit(&argc, argv);
    osgInit(argc, argv);

    std::string fontfile("testfont.ttf");
    std::string testtext("Test Text");
    UInt32 drawmode;
    
    if(argc > 1)
        testtext = argv[1];
    if(argc > 2)
        fontfile = argv[2];
    if(argc < 4 || sscanf(argv[3], "%d", &drawmode) != 1 )
        drawmode = FTGLFont::Outline;
        
    // GLUT 
    int winid = setupGLUT(&argc, argv);
    GLUTWindowPtr gwin= GLUTWindow::create();
    gwin->setId(winid);
    gwin->init();
   
    
    // Create the Cubes node

    NodePtr scene = makeCoredNode<Group>();

    beginEditCP(scene);
    
    scene->addChild( makeBox(200,200,200, 1,1,1) );
//    scene->addChild( SceneFileHandler::the().read("tie.wrl") );
    endEditCP(scene);


    // Create the text
    
    FTGLFontPtr font = FTGLFont::create();
    
    beginEditCP(font);
    font->setName(fontfile);
    font->setDrawType(drawmode);
    font->setSize(40);
    font->setRes(72);
    font->setDepth(20);
    endEditCP(font);

    FTGLTextPtr text;
    NodePtr tnode = makeCoredNode<FTGLText>(&text);
    
    beginEditCP(text);
    text->setFont(font);
    text->setText(testtext);
    text->setPosition(Pnt3f(0,300,0));
    text->setMaterial(getDefaultMaterial());      
    endEditCP(text);
    

    beginEditCP(scene);
    scene->addChild(tnode);
    endEditCP(scene);
    
    
    // create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // tell the manager what to manage
    mgr->setWindow(gwin );
    mgr->setRoot  (scene);

    // show the whole scene
    mgr->showAll();
        
    // copy to second window 
    int winid2 = setupGLUT(&argc, argv);
    gwin2= GLUTWindow::create();
    gwin2->setId(winid2);
    gwin2->init();
    
    ViewportPtr ovp = gwin->getPort()[0];
    
    ViewportPtr vp = Viewport::create();
    
    beginEditCP(vp);
    vp->setLeft(0);
    vp->setRight(400);
    vp->setBottom(0);
    vp->setTop(400);
    vp->setCamera(ovp->getCamera());
    vp->setRoot(ovp->getRoot());
    vp->setBackground(ovp->getBackground());
    vp->setParent(gwin2);
    endEditCP(vp);
    
    beginEditCP(gwin2);
    gwin2->getPort().push_back(vp);
    endEditCP(gwin2);
    
    // GLUT main loop
    glutMainLoop();

    return 0;
}
Esempio n. 2
0
/**
* @brief  Main program.
* @param  None
* @retval None
*/
int main(void)
{
    uint8_t currentLED=0,idx;
    uint16_t xx,yy;
    uint16_t testWord; 
    uint8_t shifter=0;

  /* Initialize LEDs on STM32F4-Discovery --------------------*/

    __IO uint32_t i = 0;  
    uint8_t buf[255];
    uint8_t len;
    STM_EVAL_LEDInit(LED4);
    STM_EVAL_LEDInit(LED3);
    // You can use these for LEDs if you use the upper 8 bits of the 16b FSMC bus to talk to the ILI9238.
    // STM_EVAL_LEDInit(LED5); //GPIOD 14 -> FSMC D0. Do not use for LED, we need them to talk to the ILI9238
    // STM_EVAL_LEDInit(LED6); //GPIOD 14 -> FSMC D1.

   

    // flash the LEDs in a circle to test delayMillis(uint32_t timedelay)

     STM_EVAL_LEDToggle(currentLED);

    for (idx=0;idx<8;idx++)
    {
        STM_EVAL_LEDToggle(currentLED);
        currentLED=(currentLED+1)%2;
        STM_EVAL_LEDToggle(currentLED);
        delayMillis(250);
    }
    // 
    // USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_CDC_cb, &USR_cb);

    // init the printf
    init_printf(0,tft_putc);
    // init_tft_printf(NULL,tft_putc);

    // Get the 32F4 ready to talk to the TFTLCD using FSMC
    initGPIO();
    initFSMC();
    uDelay(1000); // probably don't need this
    reset();
    initDisplay();

    // ** Do the adafruit Demo **
    // fillScreen(BLACK);
    //     setCursor(0, 0);
    //     setTextColor(CYAN);
    //     setTextSize(1);
    //     setRotation(1); 
    //     tft_printf("Please connect to virtual COM port...");
    delayMillis(2000);
    testlines(CYAN);
    delayMillis(2500);
    testfastlines(RED, BLUE);
    delayMillis(2500);
    testdrawrects(GREEN);
    delayMillis(2500);
    testfillrects(YELLOW, MAGENTA);
    delayMillis(2500);
    fillScreen(BLACK);
    testfillcircles(10, MAGENTA);
    testdrawcircles(10, WHITE);
    delayMillis(2500); 
    testtriangles();
    delayMillis(2500); 
    testfilltriangles();
    delayMillis(2500); 
    testRoundRect();
    delayMillis(2500); 
    testFillRoundRect();
    delayMillis(2500); 
    fillScreen(GREEN);
    delayMillis(2500); 
    
    
    // fsmcData        =  0x60020000; // sets a16
    // fsmcRegister    =  0x60000000; // clears a16
    // printf("fsmcData:\t0x%08X\r\n",fsmcData);
    // printf("fsmcRegister:\t0x%08X\r\n",fsmcRegister);

    // fillScreen(BLACK);
    // setCursor(0, 20);
    // setTextColor(color);
    // setTextSize(1);
    // write("Hello World!");
    // setTextSize(2);
    // write(1234.56);
    // setTextSize(3);
    // 
    // println(0xDEADBEEF, HEX);


    // printf("0xFF00>>8 0x%04X\r\n",0xff00>>8);
    // VCP_send_str(&buf[0]);
    // printf("SysTick_Config(SystemCoreClock/1000)\t %d\r\n",SysTick_Config(SystemCoreClock/1000));
    // millisecondCounter=0;
    // for (idx=0;idx<100;idx++)
    // {
    //     printf("millisecondCounter:\t%d",millisecondCounter);
    // }
    // void delayMillis(uint32_t millis) 
    //     {
    //         uint32_t target;
    // 
    //         target=millisecondCounter+millis;
    //         while(millisecondCounter<target);
    //     }

   
    // From stm32f4_discovery.h:
    // typedef enum 
    // {
    // LED4 = 0,
    // LED3 = 1,
    // LED5 = 2,
    // LED6 = 3
    // } Led_TypeDef;
    while(1)
    {
        for (idx=0;idx<8;idx++)
        {
            setRotation(idx%4); 
            testtext(RED);
            delayMillis(1500); 
        }

    }

}