Ejemplo n.º 1
0
osg::Node* createTextGroup(const char** text)
{
    osg::Group* group = new osg::Group;

    osg::Vec3 pos(120.0f, 800.0f, 0.0f);
    const osg::Vec3 delta(0.0f, -60.0f, 0.0f);

    // header
    const char** t = text;
    group->addChild(createText(*t++, pos));
    pos += delta;

    // remainder of text under sequence
    osg::Sequence* seq = new osg::Sequence;
    group->addChild(seq);
    while (*t) {
        seq->addChild(createText(*t++, pos));
        seq->setTime(seq->getNumChildren()-1, 2.0f);
        pos += delta;
    }

    // loop through all children
    seq->setInterval(osg::Sequence::LOOP, 0,-1);

    // real-time playback, repeat indefinitively
    seq->setDuration(1.0f, -1);

    // must be started explicitly
    seq->setMode(osg::Sequence::START);

    return group;
}
Ejemplo n.º 2
0
void Context::initTexts() {
	allTexts[0].first = createText(this, "Choose rendering mode");
	allTexts[0].second = allocRect(17,20,235,25);
	allTexts[1].first = createText(this, "Choose accelerated data structure");
	allTexts[1].second = allocRect(17,160,235,20);
	allTexts[2].first = createText(this, "Results preview");
	allTexts[2].second = allocRect(430, 50, 235, 35);
	allTexts[3].first = createText(this, "Progress");
	allTexts[3].second = allocRect(72, 390, 120, 35);
	allTexts[4].first = createText(this, "Seconds to render: ");
	allTexts[4].second = allocRect(290, 15, 150, 25);
}
Ejemplo n.º 3
0
LRESULT camera_path_window::onCreate(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  RECT rcClient;
  GetClientRect(&rcClient);

  createText(0, 20, 20,  200, 30, "Camera mode: ");
  createText(0, 20, 55,  200, 30, "Camera path point count: ");
  createText(0, 20, 90,  200, 30, "Average distance between consecutive camera path points: ");
  createText(0, 20, 125, 200, 30, "Approximate camera path length: ");
  createText(0, 20, 160, 200, 30, "Index of entrance point: ");
  createText(0, 20, 195, 200, 30, "Index of exit point: ");
  createText(0, 20, 230, 200, 30, "Camera path direction normal: ");
  createText(0, 20, 265, 200, 30, "Camera zoom-back distance: ");
  
  cameraMode    = new drop(IDC_CAMERAMODEDROP, rcClient.right-140, 20, 120, 300, hSelf);
  cameraMode->addItem("Stationary");
  cameraMode->addItem("Auto");
  cameraMode->addItem("unused?");
  cameraMode->addItem("Auto (alt)");
  cameraMode->addItem("unused?");
  cameraMode->addItem("Follow");
  cameraMode->addItem("Follow (alt)");
  cameraMode->addItem("Map?");
  cameraMode->addItem("Or is this map?");
  
  pointCount    = createText(WS_EX_CLIENTEDGE, rcClient.right-140, 55, 120, 30, "");
  pointDist     = new edit(IDC_EDITPOINTDIST, rcClient.right-140, 90, 120, 18, hSelf);
  pointDist->addSpin(IDC_SPINPOINTDIST);
  pathLength    = createText(WS_EX_CLIENTEDGE, rcClient.right-140, 125, 120, 30, "");
  entrancePoint = new edit(IDC_EDITENTRANCEPOINT, rcClient.right-140, 160, 120, 18, hSelf);
  entrancePoint->addSpin(IDC_SPINENTRANCEPOINT);
  exitPoint     = new edit(IDC_EDITEXITPOINT, rcClient.right-140, 195, 120, 18, hSelf);
  exitPoint->addSpin(IDC_SPINEXITPOINT);
  
  raw_group_createparams params = {   3,   1, 
                                    IDC_EDITCAMERAVECTORX, 
                                    180, 230, 60, 20,
                                      2,   2,  2,  2,
                                      0,   0 };
                                    
  raw_control::createGroup(cameraVector, params, hSelf);
  for (int lp=0; lp<3; lp++)
    cameraVector[lp]->addSpin(IDC_SPINCAMERAVECTORX+lp, -100000, 100000);
    
  zoomBack = new edit(IDC_EDITZOOMBACK, rcClient.right-140, 265, 120, 18, hSelf);
  zoomBack->addSpin(IDC_SPINZOOMBACK);

  return NULL;
}
Ejemplo n.º 4
0
int main(void) {
  int i;


  chars.w = ResolutionFactor * 160;
  chars.h = ResolutionFactor * 90;
  //chars.name = "0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
  chars.name = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  chars.name = "afg";
  chars.l=strlen(chars.name);
  printf("%d\n",chars.l);
  chars.all = malloc(chars.l*sizeof(Char));
  init();
  for(i=0;i<chars.l;i++) {
    Char cha;
    chars.all[i] = cha;
    createText(chars.name[i],&chars.all[i]);
  }
  for(i=0;i<chars.l;i++) 
    show(&chars.all[i]);
  //Write("chars.txt",&chars);


  // Read("chars.txt",&chars);
  // printf("%d %d %d %s\n", chars.w,chars.h,chars.l,chars.name);
  // for(i=0;i<chars.l;i++) 
  //   show(&chars.all[i]);

  //printf("%s\n", Text);
}
Ejemplo n.º 5
0
OSGTextNode::OSGTextNode(QObject *parent) :
    osgQtQuick::OSGNode(parent),
    h(new Hidden)
{
    osg::ref_ptr<osgText::Font> textFont = createFont(QFont("Times"));

    h->text = createText(osg::Vec3(-100, 20, 0),
                         "The osgQtQuick :-)\n"
                         "И даже по русски!",
                         20.0f,
                         textFont.get());
    osg::ref_ptr<osg::Geode> textGeode = new osg::Geode();
    h->text->setColor(osg::Vec4(0.0f, 1.0f, 0.0f, 1.0f));
    textGeode->addDrawable(h->text.get());
#if 0
    h->text->setAutoRotateToScreen(true);
    setNode(textGeode.get());
#else
    osg::Camera *camera = createHUDCamera(-100, 100, -100, 100);
    camera->addChild(textGeode.get());
    camera->getOrCreateStateSet()->setMode(
        GL_LIGHTING, osg::StateAttribute::OFF);
    setNode(camera);
#endif
}
Ejemplo n.º 6
0
EntityRef MainState::createDamageText(const std::string& text, const Vector3& pos,
                                      const Vector4& color) {
    EntityRef entity = createText(text, pos, color);
    _anims.addComponent(entity);
    AnimationComponent* comp = _anims.get(entity);
    comp->anim = _damageAnim->clone();
    return entity;
}
Ejemplo n.º 7
0
char* rrcCallConv getLogLevel()
{
    start_try
        string level = Logger::getCurrentLevelAsString();
        char* lvl = createText(level.c_str());
        return lvl;
    catch_ptr_macro
}
Ejemplo n.º 8
0
int main(void) {
  createText();
  int i,j,k=0;
  for(i=0;i<HEIGHT;i++) 
    for(j=0;j<WIDTH;j++)
      if(Image[i][j]!=0) 
        k++;
  printf("pixels = %d\n",k);
}
GLuint CBAndroidTextureBuilder::reloadText(const string& text, const float size)
{
	float width = 0;
	float height = 0;
	//GLuint texID = createText(text.c_str(),size,&width,&height);
	GLuint texID = createText(text.c_str(), size, width, height);
	//DebugLog("CBBuilderAndroid::ReloadText:%s,%d",s.c_str(),texID);
	return texID;
}
Ejemplo n.º 10
0
CBTexture* CBAndroidTextureBuilder::buildStringTexture(const string& text, const float size)
{
	float width = 0;
	float height = 0;
	CBTexture* texture;
	GLuint texID = createText(text.c_str(), size, width, height);
	texture = new CBTexture(texID, width, height, width, height, text, size);
	return texture;
}
Ejemplo n.º 11
0
void MenuUI::DisplayTextAtPosition(RenderWindow& target)
{
	if (loadFont())
	{
		createText();
	}
	displayText.setPosition(posX, posY);
	target.draw(displayText);
}
Ejemplo n.º 12
0
char* rrp_cc getParameterInfo(RRParameterHandle handle)
{
    start_try
        PluginParameter* para = castToParameter(handle);
        stringstream s;
        s<<"Name="<<para->getName()<<"\tType="<<para->getType()<<"\tDescription="<<para->getDescription()<<"\tHint="<<para->getHint();
        return createText(s.str());
    catch_ptr_macro
}
Ejemplo n.º 13
0
LRESULT general_window::onCreate(UINT uMsg, WPARAM wParam, LPARAM lParam)
{                        
  createGroupBox(0, 20,  10, 360, 165, "Properties");
  
  createText(0, 30, 32, 120, 12, "Location: ");
  createText(0, 30, 62, 120, 12, "Dimensions: ");
  
  raw_group_createparams params = {   3,  1, 
                                    IDC_EDITLOCATIONX, 
                                    180, 30, 60, 20,
                                      2,  2, 2,  2,
                                      0,  0 };
                                    
  raw_control::createGroup(location, params, hSelf);
  for (int lp=0; lp<3; lp++)
    location[lp]->addSpin(IDC_SPINLOCATIONX+lp, -100000, 100000);

  params.baseID = IDC_EDITDIMENSIONW;
  params.y      = 60;
  
  raw_control::createGroup(dimension, params, hSelf);
  for (int lp=0; lp<3; lp++)
    dimension[lp]->addSpin(IDC_SPINDIMENSIONW+lp, 0, 10000);

  
  checks[0] = new check(  IDC_CHECKBOTTOMSOLID, 30, 95, 320, 12, hSelf,
                        "Bottom of zone != solid ground (causes death if fallen below)");
  checks[1] = new check(     IDC_CHECKTOPSOLID, 30, 110, 320, 12, hSelf,
                        "Top of zone = solid ceiling (top of zone = top of level)");
  checks[2] = new check(IDC_CHECKCONTAINSWATER, 30, 125, 320, 12, hSelf,
                        "Contains water (can cause drowning type death)");
  checks[3] = new check( IDC_CHECKNOSOLIDWALLS, 30, 140, 320, 12, hSelf, 
                        "Does not contain solid walls");
  checks[4] = new check(IDC_CHECKNOCHECKPOINTS, 30, 155, 320, 12, hSelf,
                        "Does not save checkpoint state");

  createGroupBox(0, 20, 180, 360, 160, "Statistics");


  return NULL;
}
Ejemplo n.º 14
0
char* rrp_cc getNamesFromParameterList(RRParametersHandle handle)
{
    start_try
        Parameters* paras = castToParameters(handle);    
        StringList aList;
        for(int i = 0; i < paras->count(); i++)
        {
            aList.add((*paras)[i]->getName());
        }
        return createText(aList.AsString().c_str());

    catch_ptr_macro
}
Ejemplo n.º 15
0
void World::init()
{
    float xPos = kStatsTextXpos, yPos = kStatsTextYpos;
    _framerate = createText(kFramerateName, xPos, yPos, "", kStatsTextSize, sf::Color::Yellow);
    KeyboardMap aKeyboardPressedMapping;
    KeyboardMap aKeyboardReleasedMapping = { { sf::Keyboard::F3, std::make_shared<EnableStatsCommand>(*this, xPos, yPos)} };
    _framerate->addComponent(std::make_shared<InputComponent>(aKeyboardPressedMapping, aKeyboardReleasedMapping));
#ifndef NDEBUG
    _framerate->removeComponent<PositionComponent>();
#endif // NDEBUG
    registerEntity(_framerate);
	createMenus();
}
Ejemplo n.º 16
0
void WidgetCheckBox::load(const Aurora::GFF3Struct &gff) {
	gff.getVector("COLOR", _r, _g, _b);
	_a = gff.getDouble("ALPHA", 1.0);

	Extend extend = createExtend(gff);

	_width  = extend.w;
	_height = extend.h;

	Widget::setPosition(extend.x, extend.y, 0.0f);

	Border border = createBorder(gff);

	if (!border.fill.empty()) {
		_quad = new Graphics::Aurora::HighlightableGUIQuad(border.fill, 0.0f, 0.0f, extend.h * .62, extend.h * .62);
	} else {
		_quad = new Graphics::Aurora::GUIQuad(border.fill, 0.0f, 0.0f, extend.h * .62, extend.h * .62);
	}

	_quad->setPosition(extend.x, extend.y, 0.0f);
	_quad->setTag(getTag());
	_quad->setClickable(true);

	if (border.fill.empty())
		_quad->setColor(0.0f, 0.0f, 0.0f, 0.0f);

	Text text = createText(gff);

	if (!text.text.empty() && !text.font.empty()) {
		_text = new Graphics::Aurora::HighlightableText(FontMan.get(text.font), text.text,
		                                   text.r, text.g, text.b, 1.0f);

		const float hspan = extend.w - _text->getWidth();
		const float vspan = extend.h - _text->getHeight();


		const float x = extend.x + text.halign * hspan;
		const float y = extend.y + text.valign * vspan;

		_text->setPosition(x, y, -1.0f);
		_text->setTag(getTag());
		_text->setClickable(true);
	}

	if (getTextHighlightableComponent() != 0) {
		  setDefaultHighlighting(getTextHighlightableComponent());
	}
	if (getQuadHighlightableComponent() != 0) {
		  setDefaultHighlighting(getQuadHighlightableComponent());
	}
}
Ejemplo n.º 17
0
spButton createButtonHelper(spButton button, const std::string& txt, EventCallback cb)
{
    button->setPriority(10);
    //button->setName(id);
    button->setResAnim(Test::resourcesUI.getResAnim("button"));
    button->addEventListener(TouchEvent::CLICK, cb);

    //Create Actor with Text and add it to button as child
    spTextField text = createText(txt);
    text->setSize(button->getSize());
    text->attachTo(button);

    return button;
}
Ejemplo n.º 18
0
void AboutWindow::createUi()
{
    if (debug) qDebug() << "[AboutWindow]" << "[createUi]";

    QWidget *aboutWidget = new QWidget();
    uiAbout = new Ui::About;
    uiAbout->setupUi(aboutWidget);
    ui->verticalLayout->addWidget(aboutWidget);
    createText();

    QDialogButtonBox *buttonBox = new QDialogButtonBox;
    buttonBox->addButton(QDialogButtonBox::Close);
    ui->verticalLayout->addWidget(buttonBox);
    connect(buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked(bool)), this, SLOT(close()));
}
inGameStatsRenderComponent::inGameStatsRenderComponent(int _background, float scale)
{
    sceneMan = SceneManager::GetSceneManager();
    layer = "layer1";
    int w, h;
    RenderManager::getRenderManager()->getWindowSize(&w, &h);
    purple = new TextAlignment::COLOR(160, 32, 240);
    yellow = new TextAlignment::COLOR(250, 165, 10);
    objRef = sceneMan->InstantiateObject(sceneMan->findLayer(layer), _background, -5, 1, true);
    objRef->setPos(w / 4.0f, h / 5.0f);
    //objRef->setPos(w / 2.0f, h / 2.0f);
    background = _background;

    objRef->setPos(w / 4.0f, h / 5.0f);
    objRef->setScale(scale);
    createText();
    createScoreText();
    toggleOn(false);
}
Ejemplo n.º 20
0
ChatBox createChatBox(int x, int y)
{
  ChatBox box;
  int i;
  box.rect.x = x;
  box.rect.y = y;
  box.rect.h = DY * (NB_MSG);
  box.rect.w = CHAT_W;
  box.callback = NULL;
  box.update = false;
  
  for(i=0;i<NB_MSG;i++)
  {
    strcpy(box.text[i],""); // on met des espaces pour que les surface associé aient une taille
    box.messages[i] = createText(box.text[i],box.rect.x,box.rect.y + DY * i,10);
  }
  box.input = createTextBox("",box.rect.x,box.rect.y + DY * NB_MSG,10,20,15,false);
  return box;
}
Ejemplo n.º 21
0
ScoreBoard::ScoreBoard(Renderer * r, Game * g, sf::Vector2f pos){

	visual = r;
	game = g;

	position.x = pos.x;
	position.y = pos.y;
	font.loadFromFile("resources/fonts/kenvector_future.ttf");
	background.setTexture( *visual->getTexture("resources/textures/backgroundScoreboard.png") );
	float newWidth = blocksizeToScale(   visual->getSize().x, 1366 );
	float newHeight = blocksizeToScale( visual->getSize().y, 1040);
	background.setScale( newWidth, newHeight );
	
	loadFile("scores.txt");
	addScore("lol", 11);
	addScore("Kees", 1000);
	addScore("Jaap", 10);
	createText();
	writeScore("scores_nieuw.txt");
}
Ejemplo n.º 22
0
osg::Node* createHUD()
{
    osg::Group* group = new osg::Group;

    // turn off lighting and depth test
    osg::StateSet* state = group->getOrCreateStateSet();
    state->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
    state->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);

    // add text
    osg::Vec3 pos(120.0f, 800.0f, 0.0f);
    const osg::Vec3 delta(0.0f, -80.0f, 0.0f);

    const char* text[] = {
        "TextureRectangle Mini-HOWTO",
        "- essentially behaves like Texture2D, *except* that:",
        "- tex coords must be non-normalized (0..pixel) instead of (0..1),\nalternatively you can use osg::TexMat to scale normal non dimensional texcoords.",
        "- wrap modes must be CLAMP, CLAMP_TO_EDGE, or CLAMP_TO_BORDER\n  repeating wrap modes are not supported",
        "- filter modes must be NEAREST or LINEAR since\n  mipmaps are not supported",
        "- texture borders are not supported",
        "- defaults should be fine",
        NULL
    };
    const char** t = text;
    while (*t) {
        group->addChild(createText(*t++, pos));
        pos += delta;
    }

    // create HUD
    osg::MatrixTransform* modelview_abs = new osg::MatrixTransform;
    modelview_abs->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
    modelview_abs->setMatrix(osg::Matrix::identity());
    modelview_abs->addChild(group);

    osg::Projection* projection = new osg::Projection;
    projection->setMatrix(osg::Matrix::ortho2D(0,1280,0,1024));
    projection->addChild(modelview_abs);

    return projection;
}
Ejemplo n.º 23
0
//--------------------------------------------------------------
// substitute vars into message and return
void mgErrorTable::msgText(
  mgString& text,               // returned message text
  const char* msgId,           // message to format
  const char* varNames,        // comma-delimited variable names
  const char* format,          // value format spec
  ...)                          // variable values
{
  va_list args;
  va_start(args, format);

  mgString names(varNames);
  if (!names.endsWith(","))
    names += ",";

  mgString values;
  values.formatV(format, args);
  if (!values.endsWith(","))
    values += ",";

  createText(text, msgId, names, values);
}
Ejemplo n.º 24
0
void Test::notify(std::string txt, int time)
{
    size_t N = 0;
    for (size_t i = 0; i < MAX_NOTIFIES; ++i)
    {
        if (_notifies[i])
            continue;
        N = i;
        break;
    }

    _notifies[N] += 1;


    spColorRectSprite sprite = new ColorRectSprite();
    sprite->setUserData((void*)N);
    sprite->setPriority(10);
    Color colors[] = {Color(0xD2691EFF), Color(0x7FFFD4FF), Color(0xDC143CFF), Color(0xADFF2FFF), };
    Color c = colors[rand() % 4];
    sprite->setColor(c);
    sprite->setSize(100, 30);
    //sprite->setAnimFrame(resourcesUI.getResAnim("button"));
    sprite->setAlpha(0);

    spTweenQueue tq = new TweenQueue;
    tq->add(Actor::TweenAlpha(255), 300, 1, false, 0, Tween::ease_inExpo);
    tq->add(Actor::TweenAlpha(0), 300, 1, false, 1200);
    tq->detachWhenDone();
    tq->addDoneCallback(CLOSURE(this, &Test::notifyDone));

    sprite->addTween(tq);
    sprite->attachTo(ui);
    sprite->setPosition(2.0f, getHeight() - 100.0f - N * sprite->getHeight() * 1.1f);

    spTextField text = createText(txt);
    text->attachTo(sprite);
    text->setColor(Color::Black);
    text->setPosition(sprite->getSize() / 2);
}
Ejemplo n.º 25
0
void MainWindow::createActions() {
    // Allows the user to return to menu
    returnAct = new QAction(tr("&Back to Main Menu"), this);
    returnAct->setShortcut(tr("Ctrl+Z"));
    returnAct->setStatusTip(tr("Return to main menu"));
    connect(returnAct, SIGNAL(triggered()), this, SLOT(backToMainMenu()));

    // Allows the user to exit the app through the menu bar
    exitAct = new QAction(tr("&Exit Guess Who"), this);
    exitAct->setShortcut(tr("Ctrl+Q"));
    exitAct->setStatusTip(tr("Exit the application"));
    connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));

    // Allows the user to see the About info about the application
    aboutAct = new QAction(tr("About Guess &Who"), this);
    aboutAct->setStatusTip(tr("Shows info about game"));
    connect(aboutAct, SIGNAL(triggered()), this, SLOT(aboutButtonClicked()));

    // Allows the user to create a new text file for character selection
    createAct = new QAction(tr("Edit characters text"), this);
    createAct->setStatusTip(tr("Create/Edit text file for character selection"));
    connect(createAct, SIGNAL(triggered()), this, SLOT(createText()));
}
Ejemplo n.º 26
0
osg::Node* createFadeText(osg::EllipsoidModel* ellipsoid)
{
    osg::Group* group = new osg::Group;

    group->getOrCreateStateSet()->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
    
    osg::Geode* geode = new osg::Geode;
    group->addChild(geode);
    
    std::vector<std::string> textList;
    textList.push_back("Town");
    textList.push_back("City");
    textList.push_back("Village");
    textList.push_back("River");
    textList.push_back("Mountain");
    textList.push_back("Road");
    textList.push_back("Lake");
    
    unsigned int numLat = 15;
    unsigned int numLong = 20;
    double latitude = 0.0;
    double longitude = -100.0;
    double deltaLatitude = 1.0f;
    double deltaLongitude = 1.0f;

    unsigned int t = 0;
    for(unsigned int i = 0; i < numLat; ++i, latitude += deltaLatitude)
    {
        double lgnt = longitude;
        for(unsigned int j = 0; j < numLong; ++j, ++t, lgnt += deltaLongitude)
        {
            geode->addDrawable( createText( ellipsoid, latitude, lgnt, 0, textList[t % textList.size()]) );
        }
    }

    return group;
} 
Ejemplo n.º 27
0
int main(int argc, char** argv)
{
    initVect(120,40);

    /*
     * Building level 
     */

    initLander();
    

    addLine(createLine(0,20,10,25));
    addLine(createLine(10,24,17,29));
    addLine(createLine(17,29,23,35));

    platform1 = addLine(createLine(22,35,32,35)); // <- first platform

    addLine(createLine(32,34,40,30));
    line1 = addLine(createLine(40,30,43,20));
    addLine(createLine(43,20,48,15));
    line3 = addLine(createLine(48,15,58,20));
    addLine(createLine(57,20,75,18));
    line2 = addLine(createLine(75,18,85,26));

    platform2 = addLine(createLine(84,26,94,26)); // <- second platform
    addLine(createLine(94,25,105,15));
    addLine(createLine(105,14,120,11));

    addText(createText("3X Score",24,36));
    addText(createText("2X Score",86,27));

    addText(createText("SCORE: ",1,1));
    addText(createText("FUEL: ",2,2));
    score = addText(createText("0",7,1));
    fuel = addText(createText("1000",7,2));

    mainLoop();

    return 0;
}
Ejemplo n.º 28
0
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
    RECT window;

    GetWindowRect(hwnd,&window);
    container.left = (window.right - window.left)/2 - 200;
    container.right = (window.right - window.left)/2 + 200;
    container.top = (window.bottom-window.top)/2 - 60;
    container.bottom = (window.bottom-window.top)/2 + 60;

    switch (message) {
        /*case WM_SYSCOMMAND:
            if ((wParam & 0xFFF0) == SC_MINIMIZE){
                ExitProcess(0);
                return 0;
            }
            break;*/
        case WM_CREATE:
            createButtons(hwnd);
            createText(hwnd);
            createTextInput(hwnd);
            break;
        case WM_COMMAND:
            if (wParam == buttonA->getId()) {
                labelA->setText(textA->getText());
                RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE);
            }
            if (wParam == buttonB->getId()) {
                labelB->setText(textB->getText());
                RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE);
            }
            if (wParam == superButton->getId()){
                RECT rect;
                GetWindowRect(hwnd, &rect);
                int x = rect.left;
                int y = rect.top;
                if (rect.left == 0){
                    x = 100-rand()%200;
                    y = 100-rand()%200;
                    switch(rand()%3) {
                        case 0 :
                            superButton->setText("Are you tired ? :D");
                            break;
                        case 1 :
                            superButton->setText("Maybe you want to try another trick ?");
                            break;
                        case 2 :
                            superButton->setText("Not funny ?! Click again ! :D");
                            x = 30;
                            y = 40;
                            break;
                    }
                }
                rect.left = 0;
                rect.right -= x;
                rect.bottom -= y;
                rect.top = 0;
                SetWindowPos(hwnd, HWND_TOP, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
                             SWP_FRAMECHANGED);
                break;
            }
            break;
        case WM_PAINT:
            draw(hwnd);
            break;
        case WM_SIZE:
            draw(hwnd);
            if (wParam == SIZE_MINIMIZED){
                ExitProcess(0);
            }
            if (wParam == SIZE_MAXIMIZED){
                MessageBox(hwnd,"This features is not available in demo.","Sorry",MB_OK|MB_ICONASTERISK);
                return 0;
            }
            break;
        case WM_MOVE:{
            int x = rand()%20 + 230;
            HBRUSH brush = CreateSolidBrush(RGB(x,x,x));
            SetClassLongPtr(hwnd, GCLP_HBRBACKGROUND, (LONG)brush);
            RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE);
            break;}
        case WM_CLOSE:
            MessageBox(hwnd,"NOOOOO ! YOU CANNOT EXIT !!!!","UTM",MB_OK|MB_ICONSTOP);
            return 0;
        case WM_DESTROY:
            PostQuitMessage(0);       /* send a WM_QUIT to the message queue */
            break;
        case WM_GETMINMAXINFO:{
            MINMAXINFO *mmi = (MINMAXINFO *) lParam;
            mmi->ptMinTrackSize.x = 420;
            mmi->ptMinTrackSize.y = 140;
            return 0;
        }
        case WM_CTLCOLORBTN: {
            HDC hdc = (HDC) wParam;
            if ((GetDlgItem(hwnd, textB->getId()) == (HWND) lParam)) {
                SetTextColor(hdc, (COLORREF)whiteColor);

                SetBkColor(hdc,(COLORREF)primaryColor);
                return (LRESULT)CreateSolidBrush((COLORREF)primaryColor);
            }
        }
        case WM_CTLCOLOREDIT: {
            HDC hdc = (HDC) wParam;
            if ((GetDlgItem(hwnd, textB->getId()) == (HWND) lParam)) {
                SetTextColor(hdc, (COLORREF)whiteColor);

                SetBkColor(hdc,(COLORREF)primaryColor);
                return (LRESULT)CreateSolidBrush((COLORREF)primaryColor);
            }
        } default:                      /* for messages that we don't deal with */
            return DefWindowProc(hwnd, message, wParam, lParam);
    }

    return 0;
}
Ejemplo n.º 29
0
int main(int argc, char** argv)
{
    // use an ArgumentParser object to manage the program arguments.
    osg::ArgumentParser arguments(&argc,argv);

    arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
    arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is an example showing osgLeap::PointerPositionListener use.");
    arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
    arguments.getApplicationUsage()->addCommandLineOption("--timebased", "Invoke mouse clicks after some time if the pointer is not moving (Default)");
    arguments.getApplicationUsage()->addCommandLineOption("--time <milliseconds>", "Invoke time-based mouse clicks after <milliseconds> (Default: 3000)");
    arguments.getApplicationUsage()->addCommandLineOption("--noclick", "Initialize osgLeap::PointerEventDevice without ability to send clicks");
    arguments.getApplicationUsage()->addCommandLineOption("--useintersection", "Invoke clicks above a valid geometry, only.");
    arguments.getApplicationUsage()->addCommandLineOption("--screentap", "Invoke mouse clicks upon the screen tap gesture");
    arguments.getApplicationUsage()->addCommandLineOption("--mouse", "While moving pointer send mouse motion events. Clicks are sent as mouse clicks.");
    arguments.getApplicationUsage()->addCommandLineOption("--touch", "While moving pointer send touch move events. Clicks are sent as touch taps.");

    osgViewer::Viewer viewer;
    viewer.setUpViewOnSingleScreen(0);

    osg::Group* root = new osg::Group();
    viewer.setSceneData(root);

    unsigned int helpType = 0;
    if ((helpType = arguments.readHelpType()))
    {
        arguments.getApplicationUsage()->write(std::cout, helpType);
        return 1;
    }

    // report any errors if they have occurred when parsing the program arguments.
    if (arguments.errors())
    {
        arguments.writeErrorMessages(std::cout);
        return 1;
    }

    if (arguments.argc()<=1)
    {
        arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
        return 1;
    }

    viewer.addEventHandler(new osgViewer::WindowSizeHandler);

    // ToDo/j.kroeger: Remove this...
    viewer.setThreadingModel(osgViewer::ViewerBase::SingleThreaded);

    // Defines the time that a pointer needs to stand still
    // before a mouse click is performed at the current position
    int clickEmulateStillStandTime = 3000;
    while (arguments.read("--time", clickEmulateStillStandTime)) {
        // Nothing else to be done.
    }

    osgLeap::PointerEventDevice::EmulationMode emulationMode = osgLeap::PointerEventDevice::MOUSE;
    while (arguments.read("--mouse")) {
        emulationMode = osgLeap::PointerEventDevice::MOUSE;
    }
    while (arguments.read("--touch")) {
    	emulationMode = osgLeap::PointerEventDevice::TOUCH;
    }

    osgLeap::PointerEventDevice::ClickMode clickMode = osgLeap::PointerEventDevice::TIMEBASED_MOUSECLICK;
    while (arguments.read("--noclick")) {
        clickMode = osgLeap::PointerEventDevice::NONE;
        clickEmulateStillStandTime = 0;
    }
    while (arguments.read("--timebased")) {
    	clickMode = osgLeap::PointerEventDevice::TIMEBASED_MOUSECLICK;
    }
    while (arguments.read("--screentap")) {
        clickMode = osgLeap::PointerEventDevice::SCREENTAP;
        //osgLeap::Controller::instance()->controller()->enableGesture(Leap::Gesture::TYPE_SCREEN_TAP);
        clickEmulateStillStandTime = 0;
    }

    bool useIntersection = false;
    while (arguments.read("--useintersection")) {
        useIntersection = true;
    }

    // load the data
    osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
    if (!loadedModel)
    {
        std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
        return 1;
    }

    // any option left unread are converted into errors to write out later.
    arguments.reportRemainingOptionsAsUnrecognized();

    // report any errors if they have occurred when parsing the program arguments.
    if (arguments.errors())
    {
        arguments.writeErrorMessages(std::cout);
        return 1;
    }

    root->addChild(loadedModel.get());

    viewer.realize();

	osg::Camera* hudCamera = new osgLeap::HUDCamera(viewer.getCamera());

    // Adds the osgLeap::HandState visualizer
	osg::Node* hands = new osgLeap::HandState();
    hudCamera->addChild(hands);

    // Add some text to the HUD
    hudCamera->addChild(createText());

    osg::ref_ptr<osg::Group> pointersGroup = new osg::Group();
    // PointerGraphicsUpdateCallback needs clickEmulateStillStandTime to visualize
    // the remaining time until the click is executed.
	osg::ref_ptr<osgLeap::PointerGraphicsUpdateCallback> puc = new osgLeap::PointerGraphicsUpdateCallback(viewer.getCamera(), clickEmulateStillStandTime);
    pointersGroup->addUpdateCallback(puc);
    hudCamera->addChild(pointersGroup);

    // Our PointerEventDevice is initialized to fire mouseclicks after clickEmulateStillStandTime is gone
    osg::ref_ptr<osgLeap::PointerEventDevice> dev = new osgLeap::PointerEventDevice(clickMode, emulationMode, clickEmulateStillStandTime, puc->getPointerPositionListener());
    if (useIntersection) {
        // Setup viewer and nodemask, so clicks will be sent only if we are hovering above some node
        dev->setView(&viewer);
        dev->setTraversalMask(0xffffffff);
    }

    viewer.addDevice(dev);

    // Setup example osgWidgets
	osg::ref_ptr<osg::Camera> widgetCamera = setupWidgets(&viewer);

	if ((osg::DisplaySettings::instance()->getStereoMode() == osg::DisplaySettings::HORIZONTAL_SPLIT ||
		osg::DisplaySettings::instance()->getStereoMode() == osg::DisplaySettings::VERTICAL_SPLIT) &&
		osg::DisplaySettings::instance()->getStereo())
	{
#if 1
		// * When using this mode you should rely on images for displaying the 2d pointer
		//   instead of 3d geometry as in this example
		// ToDo/07.04.2014: Add an example on how to override PointerGraphicsUpdateCallback's
		//                  virtual osg::ref_ptr<osg::Node> createPointerGeode(unsigned int num);

		// Adding camera to scene graph works like charm in horizontal_split stereo mode
		// but messes with the lighting as it is used from the scene
		root->addChild(hudCamera);

		// disable lighting on osgLeap::HandState to ensure it's correctly displayed
		hands->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);

		root->addChild(widgetCamera);
#else
		// ToDo/07.04.2014: Implement CompositeViewer here...
#endif
	} else {
		// does not work with horizontal_split stereo mode
		osgViewer::Viewer::Windows windows;
		viewer.getWindows(windows);

		if (windows.empty()) return 1;

		hudCamera->setGraphicsContext(windows[0]);
		hudCamera->setViewport(0,0,windows[0]->getTraits()->width, windows[0]->getTraits()->height);    
		viewer.addSlave(hudCamera, false);
		root->addChild(widgetCamera);
	}


    return viewer.run();

}
Ejemplo n.º 30
0
void Context::initButtons() {

	//Buttons for render mode (CPU | GPU)
	allButtons[CPU_RENDER].setButton(allocRect(30, 55, 210, 40), allocColor(0xCF, 0xAF, 0xFF, 0xFF), createText(this, "CPU renderer"), true);
	allButtons[GPU_RENDER].setButton(allocRect(30, 105, 210, 40), allocColor(0xCF, 0xAF, 0xFF, 0xFF), createText(this, "GPU renderer"));
	allButtons[CPU_RENDER].addLink(GPU_RENDER);
	allButtons[GPU_RENDER].addLink(CPU_RENDER);
	//Buttons for type of Accelerated data structure
	allButtons[BVH].setButton(allocRect(30, 190, 210, 40), allocColor(0xCF, 0xAF, 0xFF, 0xFF), createText(this, "    BVH     "), true);
	allButtons[UNIFORM_GRID].setButton(allocRect(30, 240, 210, 40), allocColor(0xCF, 0xAF, 0xFF, 0xFF), createText(this, "Uniform grid"));
	allButtons[OCTREE].setButton(allocRect(30, 290, 210, 40), allocColor(0xCF, 0xAF, 0xFF, 0xFF), createText(this, "   Octree   "));
	allButtons[LIST].setButton(allocRect(30, 340, 210, 40), allocColor(0xCF, 0xAF, 0xFF, 0xFF), createText(this, "   List   "));
	//Links
	allButtons[BVH].addLink(UNIFORM_GRID);
	allButtons[BVH].addLink(OCTREE);
	allButtons[BVH].addLink(LIST);
	allButtons[UNIFORM_GRID].addLink(BVH);
	allButtons[UNIFORM_GRID].addLink(OCTREE);
	allButtons[UNIFORM_GRID].addLink(LIST);
	allButtons[OCTREE].addLink(BVH);
	allButtons[OCTREE].addLink(UNIFORM_GRID);
	allButtons[OCTREE].addLink(LIST);
	allButtons[LIST].addLink(BVH);
	allButtons[LIST].addLink(UNIFORM_GRID);
	allButtons[LIST].addLink(OCTREE);
	//Pause button
	allButtons[PAUSE].setButton(allocRect(750, 10, 40, 40), allocColor(0xCF, 0xAF, 0xFF, 0xFF), createText(this, "||"));
}