• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ reshape函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中reshape函数的典型用法代码示例。如果您正苦于以下问题:C++ reshape函数的具体用法?C++ reshape怎么用?C++ reshape使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了reshape函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: for_each


//.........这里部分代码省略.........
                            S32 tex_count = objectp->getNumTEs();
                            for (S32 i = 0; i < tex_count; i++)
                            {
                                if (imagep == objectp->getTEImage(i))
                                {
                                    pri += 2*HIGH_PRIORITY;
                                    break;
                                }
                            }
                        }
                    }
                }

                if (pri > 0.f && pri < HIGH_PRIORITY)
                {
                    if (imagep->mLastPacketTimer.getElapsedTimeF32() < 1.f ||
                            imagep->mFetchDeltaTime < 0.25f)
                    {
                        pri += 1*HIGH_PRIORITY;
                    }
                }
            }

            if (pri > 0.0f)
            {
                display_image_list.insert(std::make_pair(pri, imagep));
            }
        }

        if (mPrintList)
        {
            mPrintList = FALSE;
        }

        static S32 max_count = 50;
        S32 count = 0;
        mNumTextureBars = 0 ;
        for (display_list_t::iterator iter = display_image_list.begin();
                iter != display_image_list.end(); iter++)
        {
            LLViewerFetchedTexture* imagep = iter->second;
            S32 hilite = 0;
            F32 pri = iter->first;
            if (pri >= 1 * HIGH_PRIORITY)
            {
                hilite = (S32)((pri+1) / HIGH_PRIORITY) - 1;
            }
            if ((hilite || count < max_count-10) && (count < max_count))
            {
                if (addBar(imagep, hilite))
                {
                    count++;
                }
            }
        }

        if (mOrderFetch)
            sortChildren(LLTextureBar::sort_fetch());
        else
            sortChildren(LLTextureBar::sort());

        LLGLTexMemBar::Params tmbp;
        LLRect tmbr;
        tmbp.name("gl texmem bar");
        tmbp.rect(tmbr);
        tmbp.follows.flags = FOLLOWS_LEFT|FOLLOWS_TOP;
        tmbp.texture_view(this);
        mGLTexMemBar = LLUICtrlFactory::create<LLGLTexMemBar>(tmbp);
        addChild(mGLTexMemBar);
        sendChildToFront(mGLTexMemBar);

        LLAvatarTexBar::Params atbp;
        LLRect atbr;
        atbp.name("gl avatartex bar");
        atbp.texture_view(this);
        atbp.rect(atbr);
        mAvatarTexBar = LLUICtrlFactory::create<LLAvatarTexBar>(atbp);
        addChild(mAvatarTexBar);
        sendChildToFront(mAvatarTexBar);

        reshape(getRect().getWidth(), getRect().getHeight(), TRUE);

        LLUI::popMatrix();
        LLUI::pushMatrix();
        LLUI::translate((F32)getRect().mLeft, (F32)getRect().mBottom);

        for (child_list_const_iter_t child_iter = getChildList()->begin();
                child_iter != getChildList()->end(); ++child_iter)
        {
            LLView *viewp = *child_iter;
            if (viewp->getRect().mBottom < 0)
            {
                viewp->setVisible(FALSE);
            }
        }
    }

    LLContainerView::draw();

}
开发者ID:JohnMcCaffery,项目名称:Armadillo-Phoenix,代码行数:101,代码来源:lltextureview.cpp


示例2: flatten

Matrix flatten(const Matrix& matrix)
{
    return reshape(matrix, {matrix.elements()});
}
开发者ID:sudnya,项目名称:video-classifier,代码行数:4,代码来源:MatrixTransformations.cpp


示例3: main


//.........这里部分代码省略.........
    int best_fbc = -1, best_num_samp = -1;
    for (int i = 0; i < fbcount; i++) {
        XVisualInfo *vi = glXGetVisualFromFBConfig(display, fbc[i]);
        if (vi != nullptr) {
            int samp_buf, samples;
            glXGetFBConfigAttrib(display, fbc[i], GLX_SAMPLE_BUFFERS, &samp_buf);
            glXGetFBConfigAttrib(display, fbc[i], GLX_SAMPLES, &samples);
            if (best_fbc < 0 || (samp_buf && samples > best_num_samp)) {
                best_fbc = i, best_num_samp = samples;
            }
        }
        XFree(vi);
    }
    GLXFBConfig bestFbc = fbc[best_fbc];
    XFree(fbc);

    XVisualInfo *vi = glXGetVisualFromFBConfig(display, bestFbc);
    XSetWindowAttributes swa;
    Colormap cmap;
    swa.colormap = cmap = XCreateColormap(display, RootWindow(display, vi->screen), vi->visual, AllocNone);
    swa.background_pixmap = None;
    swa.border_pixel = 0;
    swa.event_mask = StructureNotifyMask | KeyPressMask;
    Window win = XCreateWindow(display, RootWindow(display, vi->screen), 0, 0, 800, 600,
        0, vi->depth, InputOutput, vi->visual, CWBorderPixel|CWColormap|CWEventMask, &swa);
    if (!win) {
        printf("Failed to create window.\n");
        exit(1);
    }
    XFree(vi);

    XStoreName(display, win, "Tutorial 02");
    XMapWindow(display, win);

    // Get the default screen's GLX extension list
    const char *glxExts = glXQueryExtensionsString(display, DefaultScreen(display));
    glXCreateContextAttribsARBProc glXCreateContextAttribsARB = 0;
    glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc) glXGetProcAddressARB((const GLubyte *) "glXCreateContextAttribsARB");

    GLXContext ctx = nullptr;

    // Install an X error handler so the application won't exit if GL 3.0
    // context allocation fails.
    ctxErrorOccurred = false;
    int (*oldHandler)(Display*, XErrorEvent*) = XSetErrorHandler(&ctxErrorHandler);

    // Check for the GLX_ARB_create_context extension string and the function.
    if (isExtensionSupported(glxExts, "GLX_ARB_create_context") && glXCreateContextAttribsARB) {
        int context_attribs[] = {
            GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
            GLX_CONTEXT_MINOR_VERSION_ARB, 1,
            None
        };
        ctx = glXCreateContextAttribsARB(display, bestFbc, 0, True, context_attribs);

        // Sync to ensure any errors generated are processed.
        XSync(display, False);
        if (ctxErrorOccurred || ctx == nullptr) {
            printf("Could not create GL 3.0 context\n");
            exit(1);
        }
    }

    // Sync to ensure any errors generated are processed.
    XSync(display, False);
    // Restore the original error handler
    XSetErrorHandler(oldHandler);

    glXMakeCurrent(display, win, ctx);

    // must be called AFTER the OpenGL context has been created
    glewInit(); 

    reshape(800, 600);

    bool done = false;
    while (!done) {
        while (XPending(display) > 0) {
            XEvent event;
            XNextEvent(display, &event);
            switch (event.type) {
            case Expose:
                break;
            case ConfigureNotify:
                reshape(event.xconfigure.width, event.xconfigure.height);
                break;
            case KeyPress:
                done = true;
                break;
            }
        }
        render();
        glXSwapBuffers(display, win);
    }

    glXDestroyContext(display, ctx);
    XDestroyWindow(display, win);
    XFreeColormap(display, cmap);
    XCloseDisplay(display);
}
开发者ID:glurbi,项目名称:cglcore,代码行数:101,代码来源:tutorial01.cpp


示例4: main

int
main(int argc, char *argv[])
{
    char *fileName0 = defaultFile0,
        *fileName1 = defaultFile1,
        *fileName2 = defaultFile2;

    glutInit(&argc, argv);
    if (argc > 1) {
	fileName0 = fileName1 = argv[1];
    }
    if (argc > 2) {
	fileName2 = argv[2];
    }
    if (argc > 3) {
	fileName1 = fileName2;
	fileName2 = argv[3];
    }
    if (argc > 4) {
	if (argc == 6 || argc == 7) {
	    key[0] = atof(argv[argc - 3]);
	    key[1] = atof(argv[argc - 2]);
	    key[2] = atof(argv[argc - 1]);
	} else {
	    show_usage();
	    exit(1);
	}
    }
    printf("Matte file is %s\n", fileName0);
    printf("Image file 1 is %s\n", fileName1);
    printf("Image file 2 is %s\n", fileName2);
    printf("Key is (%f %f %f)\n", key[0], key[1], key[2]);
    img0 = load_img(fileName0, &w0, &h0);
    img1 = load_img(fileName1, &w1, &h1);
    img2 = load_img(fileName2, &w2, &h2);

#define MAX(a, b) ((a) > (b) ? (a) : (b))
    w = MAX(MAX(w0, w1), w2);
    h = MAX(MAX(h0, h1), h2);

    glutInitWindowSize(2 * w, 2 * h);
    glutInitWindowPosition(0, 0);
    glutInitDisplayMode(GLUT_RGBA | GLUT_ACCUM | GLUT_ALPHA);
    glutCreateWindow(argv[0]);
    glutDisplayFunc(draw);
    glutKeyboardFunc(keyPress);
    glutReshapeFunc(reshape);
    glutMouseFunc(button);

    /*
     * A hack to see if the color matrix is supported 
     */
    while (glGetError() != GL_NO_ERROR);
    glMatrixMode(GL_COLOR);
    if (glGetError() != GL_NO_ERROR) {
	printf("This demo requires OpenGL 1.2 or the color matrix extension.\n");
	exit(0);
    }
    glMatrixMode(GL_MODELVIEW);

    init();

    reshape(w, h);
    glutMainLoop();
    return 0;
}
开发者ID:xtmacbook,项目名称:SGI,代码行数:66,代码来源:chromakey.c


示例5: reshape

void LLCheckBoxCtrl::setLabel( const LLStringExplicit& label )
{
	mLabel->setText( label );
	reshape(getRect().getWidth(), getRect().getHeight(), FALSE);
}
开发者ID:Boy,项目名称:netbook,代码行数:5,代码来源:llcheckboxctrl.cpp


示例6: gameLoop

void gameLoop()
{
	SDL_Event event;

	/* Grab all the events off the queue. */
	while( SDL_PollEvent( &event ) )
	{
		int k = -1;

		switch( event.type )
		{
		case SDL_MOUSEMOTION:
			mouseX = event.motion.x;
			mouseY = event.motion.y;
			break;

		case SDL_MOUSEBUTTONDOWN:
			SceneManager_eventsAdd(evts, SCENEEVENT_TYPE_FINGERDOWN, 0, event.button.x, event.button.y);
			break;

		case SDL_MOUSEBUTTONUP:
			SceneManager_eventsAdd(evts, SCENEEVENT_TYPE_FINGERUP, 0, event.button.x, event.button.y);
			break;

		case SDL_VIDEORESIZE:
			reshape(event.resize.w, event.resize.h);
			break;

		case SDL_KEYDOWN:
			switch (event.key.keysym.sym)
			{
			case SDLK_UP:
				k = OS_key_up;
				break;
			case SDLK_DOWN:
				k = OS_key_down;
				break;
			case SDLK_LEFT:
				k = OS_key_left;
				break;
			case SDLK_RIGHT:
				k = OS_key_right;
				break;
			case SDLK_a:
				k = OS_key_rol;
				break;
			case SDLK_d:
				k = OS_key_ror;
				break;
			case SDLK_RETURN:
			case SDLK_KP_ENTER:
				k = OS_key_ok;
				break;
			case SDLK_ESCAPE:
				k = OS_key_cancel;
				break;
			default:
				break;
			}

			if (k != -1)
				SceneManager_eventsAdd(evts, SCENEEVENT_TYPE_KEYDOWN, k, 0, 0);
			break;

		case SDL_QUIT:
			OS_quit();
			break;

		default:
			break;
		}
	}


	timenow = getNanoTime();

	while (timenow - ltime < (frameTime))
	{
		timenow = getNanoTime();
	}

	display();
	ltime = timenow;
}
开发者ID:a-sf-mirror,项目名称:phlipple,代码行数:84,代码来源:osinterface_sdl.c


示例7: getRect

void LLMediaCtrl::draw()
{
	if ( ! mWebBrowserImage )
		return;

	if ( gRestoreGL == 1 )
	{
		LLRect r = getRect();
		reshape( r.getWidth(), r.getHeight(), FALSE );
		return;
	};

	// NOTE: optimization needed here - probably only need to do this once
	// unless tearoffs change the parent which they probably do.
	const LLUICtrl* ptr = findRootMostFocusRoot();
	if ( ptr && ptr->hasFocus() )
	{
		setFrequentUpdates( true );
	}
	else
	{
		setFrequentUpdates( false );
	};

	// alpha off for this
	LLGLSUIDefault gls_ui;
	LLGLDisable gls_alphaTest( GL_ALPHA_TEST );

	gGL.pushMatrix();
	{
		if (mIgnoreUIScale)
		{
			glLoadIdentity();
			// font system stores true screen origin, need to scale this by UI scale factor
			// to get render origin for this view (with unit scale)
			gGL.translatef(floorf(LLFontGL::sCurOrigin.mX * LLUI::sGLScaleFactor.mV[VX]), 
						floorf(LLFontGL::sCurOrigin.mY * LLUI::sGLScaleFactor.mV[VY]), 
						LLFontGL::sCurOrigin.mZ);
		}

		// scale texture to fit the space using texture coords
		gGL.getTexUnit(0)->bind(mWebBrowserImage->getTexture());
		gGL.color4fv( LLColor4::white.mV );
		F32 max_u = ( F32 )mWebBrowserImage->getMediaWidth() / ( F32 )mWebBrowserImage->getWidth();
		F32 max_v = ( F32 )mWebBrowserImage->getMediaHeight() / ( F32 )mWebBrowserImage->getHeight();

		LLRect r = getRect();
		S32 width, height;
		S32 x_offset = 0;
		S32 y_offset = 0;
		
		if(mStretchToFill)
		{
			if(mMaintainAspectRatio)
			{
				F32 media_aspect = (F32)(mWebBrowserImage->getMediaWidth()) / (F32)(mWebBrowserImage->getMediaHeight());
				F32 view_aspect = (F32)(r.getWidth()) / (F32)(r.getHeight());
				if(media_aspect > view_aspect)
				{
					// max width, adjusted height
					width = r.getWidth();
					height = llmin(llmax(S32(width / media_aspect), 0), r.getHeight());
				}
				else
				{
					// max height, adjusted width
					height = r.getHeight();
					width = llmin(llmax(S32(height * media_aspect), 0), r.getWidth());
				}
			}
			else
			{
				width = r.getWidth();
				height = r.getHeight();
			}
		}
		else
		{
			width = llmin(mWebBrowserImage->getMediaWidth(), r.getWidth());
			height = llmin(mWebBrowserImage->getMediaHeight(), r.getHeight());
		}

		x_offset = (r.getWidth() - width) / 2;
		y_offset = (r.getHeight() - height) / 2;		

		if (mIgnoreUIScale)
		{
			width = llround((F32)width * LLUI::sGLScaleFactor.mV[VX]);
			height = llround((F32)height * LLUI::sGLScaleFactor.mV[VY]);
			x_offset = llround((F32)x_offset * LLUI::sGLScaleFactor.mV[VX]);
			y_offset = llround((F32)y_offset * LLUI::sGLScaleFactor.mV[VY]);
		}

		// draw the browser
		gGL.setSceneBlendType(LLRender::BT_REPLACE);
		gGL.begin( LLRender::QUADS );
		if (! mWebBrowserImage->getTextureCoordsOpenGL())
		{
			// render using web browser reported width and height, instead of trying to invert GL scale
			gGL.texCoord2f( max_u, 0.f );
//.........这里部分代码省略.........
开发者ID:Xara,项目名称:Immortality,代码行数:101,代码来源:llmediactrl.cpp


示例8: _main

int _main(int argc, char *argv[])
{
  SDL_Surface *screen;
  int done;
  Uint8 *keys;
  int mousebutton,mouseX,mouseY;
  int grabbed=false;
  SDL_Init(SDL_INIT_VIDEO);

  screen = SDL_SetVideoMode(640, 480, 32, SDL_OPENGL|SDL_RESIZABLE);
  if ( ! screen ) {
    fprintf(stderr, "Couldn't set 300x300 GL video mode: %s\n", SDL_GetError());
    SDL_Quit();
    exit(2);
  }
  SDL_WM_SetCaption("Z64Viewer", "z64viewer");
  SDL_ShowCursor(SDL_DISABLE);
  SDL_WM_GrabInput(SDL_GRAB_ON);
  grabbed=true;
  
  init(argc, argv);
  reshape(screen->w, screen->h);
  done = 0;
  while ( ! done ) {
    SDL_Event event;

    idle();
    while ( SDL_PollEvent(&event) ) {
      switch(event.type) {
        case SDL_VIDEORESIZE:
          screen = SDL_SetVideoMode(event.resize.w, event.resize.h, 16,
                                    SDL_OPENGL|SDL_RESIZABLE);
          if ( screen ) {
            reshape(screen->w, screen->h);
          } else {
            printf("Problem...\n");
          }
          break;

        case SDL_QUIT:
          done = 1;
          break;
      }
    }
    keys = SDL_GetKeyState(NULL);

    if ( keys[SDLK_ESCAPE] ) {
      if(grabbed)
      {
          SDL_WM_GrabInput(SDL_GRAB_OFF);
          SDL_ShowCursor(SDL_ENABLE);
          grabbed=false;          
          waitTime(200); // Wait a bit so we don't exit by mistake
      }
      else
      {      
      done = 1;
      }
    }

    mousebutton=SDL_GetRelativeMouseState(&mouseX,&mouseY);
    
    GLfloat viewMatrix[16] = { 1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 };
    
    if(grabbed)
    {
        if((mousebutton&1) && (mousebutton&4))
        {
            matrixRotate(viewMatrix, mouseX/600.0f*360.0f, camera[0*4+0],camera[0*4+1],camera[0*4+2]);
            
            multM4Vect(&camera[0*4], viewMatrix, &camera[0*4]);
            multM4Vect(&camera[1*4], viewMatrix, &camera[1*4]);
            multM4Vect(&camera[2*4], viewMatrix, &camera[2*4]);
        }
        else
        {
            matrixRotate(viewMatrix, -mouseX/600.0f*360.0f, camera[2*4+0], camera[2*4+1],camera[2*4+2]);
            matrixRotate(viewMatrix, -mouseY/600.0f*360.0f, camera[1*4+0], camera[1*4+1],camera[1*4+2]);
            
            multM4Vect(&camera[0*4], viewMatrix, &camera[0*4]);
            multM4Vect(&camera[1*4], viewMatrix, &camera[1*4]);
        
            if(mousebutton&1)
            {
                camera[3*4+0]+=camera[0*4+0]*20;
                camera[3*4+1]+=camera[0*4+1]*20;
                camera[3*4+2]+=camera[0*4+2]*20;
                camera[3*4+3]+=camera[0*4+3]*20;
            }
    
          
            if(mousebutton&4)
            {
                camera[3*4+0]-=camera[0*4+0]*20;
                camera[3*4+1]-=camera[0*4+1]*20;
                camera[3*4+2]-=camera[0*4+2]*20;
                camera[3*4+3]-=camera[0*4+3]*20;
            }


//.........这里部分代码省略.........
开发者ID:wareya,项目名称:gzrt,代码行数:101,代码来源:z64viewer.c


示例9: draw_from_data

void draw_from_data ( struct Data * k )
{
  SDL_Surface *screen;
  int done;
  Uint8 *keys;
  int mousebutton,mouseX,mouseY;
  int grabbed=false;
  SDL_Init(SDL_INIT_VIDEO);

  screen = SDL_SetVideoMode(640, 480, 32, SDL_OPENGL|SDL_RESIZABLE);
  if ( ! screen ) {
    fprintf(stderr, "Couldn't set 300x300 GL video mode: %s\n", SDL_GetError());
    SDL_Quit();
    exit(2);
  }
  SDL_WM_SetCaption("Z64Viewer", "z64viewer");
  SDL_ShowCursor(SDL_DISABLE);
  SDL_WM_GrabInput(SDL_GRAB_ON);
  grabbed=true;
  
  
  GLenum err = glewInit();
  
  memset(databuffer,0, 8*1024*1024);
      
  entrypoint = k->ep;

  LoadResourceZ_bin(k->data, k->size, 0, 0);
  LoadResourceZ(
      "resources/gameplay_keep.zdata"
      
      , 1024*1024, 4);
  

    camera[0] = 1; camera[1]=0; camera[2]=0; camera[3]=0; // Forward
    camera[4] = 0; camera[5]=0; camera[6]=1; camera[7]=0; // Right
    camera[8] = 0; camera[9]=1; camera[10]=0; camera[11]=0; // Up
    camera[12] = -1000; camera[13]=0; camera[14]=0; camera[15]=0; // Position
  reshape(screen->w, screen->h);
  done = 0;
  while ( ! done ) {
    SDL_Event event;

    idle();
    while ( SDL_PollEvent(&event) ) {
      switch(event.type) {
        case SDL_VIDEORESIZE:
          screen = SDL_SetVideoMode(event.resize.w, event.resize.h, 16,
                                    SDL_OPENGL|SDL_RESIZABLE);
          if ( screen ) {
            reshape(screen->w, screen->h);
          } else {
            printf("Problem...\n");
          }
          break;
      }
    }

    keys = SDL_GetKeyState(NULL);

    if ( keys[SDLK_ESCAPE] ) {
      if(grabbed)
      {
          SDL_WM_GrabInput(SDL_GRAB_OFF);
          SDL_ShowCursor(SDL_ENABLE);
          grabbed=false;          
          waitTime(200); // Wait a bit so we don't exit by mistake
      }
      else
      {      
      done = 1;
      }
    }

    mousebutton=SDL_GetRelativeMouseState(&mouseX,&mouseY);
    
    GLfloat viewMatrix[16] = { 1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 };
    
    if(grabbed)
    {
        if((mousebutton&1) && (mousebutton&4))
        {
            matrixRotate(viewMatrix, mouseX/600.0f*360.0f, camera[0*4+0],camera[0*4+1],camera[0*4+2]);
            
            multM4Vect(&camera[0*4], viewMatrix, &camera[0*4]);
            multM4Vect(&camera[1*4], viewMatrix, &camera[1*4]);
            multM4Vect(&camera[2*4], viewMatrix, &camera[2*4]);
        }
        else
        {
            matrixRotate(viewMatrix, -mouseX/600.0f*360.0f, camera[2*4+0], camera[2*4+1],camera[2*4+2]);
            matrixRotate(viewMatrix, -mouseY/600.0f*360.0f, camera[1*4+0], camera[1*4+1],camera[1*4+2]);
            
            multM4Vect(&camera[0*4], viewMatrix, &camera[0*4]);
            multM4Vect(&camera[1*4], viewMatrix, &camera[1*4]);
        
            if(mousebutton&1)
            {
                camera[3*4+0]+=camera[0*4+0]*20;
                camera[3*4+1]+=camera[0*4+1]*20;
//.........这里部分代码省略.........
开发者ID:wareya,项目名称:gzrt,代码行数:101,代码来源:z64viewer.c


示例10: getRect

void LLWebBrowserCtrl::draw()
{
	if ( ! mWebBrowserImage )
		return;

	if ( gRestoreGL == 1 )
	{
		LLRect r = getRect();
		mMediaSource->updateMedia();
		reshape( r.getWidth(), r.getHeight(), FALSE );
		return;
	};

	// NOTE: optimization needed here - probably only need to do this once
	// unless tearoffs change the parent which they probably do.
	const LLUICtrl* ptr = findRootMostFocusRoot();
	if ( ptr && ptr->hasFocus() )
	{
		setFrequentUpdates( true );
	}
	else
	{
		setFrequentUpdates( false );
	};

	// alpha off for this
	LLGLSUIDefault gls_ui;
	LLGLDisable gls_alphaTest( GL_ALPHA_TEST );

	gGL.pushMatrix();
	{
		if (mIgnoreUIScale)
		{
			glLoadIdentity();
			// font system stores true screen origin, need to scale this by UI scale factor
			// to get render origin for this view (with unit scale)
			gGL.translatef(floorf(LLFontGL::sCurOrigin.mX * LLUI::sGLScaleFactor.mV[VX]), 
						floorf(LLFontGL::sCurOrigin.mY * LLUI::sGLScaleFactor.mV[VY]), 
						LLFontGL::sCurOrigin.mZ);
		}

		// scale texture to fit the space using texture coords
		gGL.getTexUnit(0)->bind(mWebBrowserImage->getTexture());
		gGL.color4fv( LLColor4::white.mV );
		F32 max_u = ( F32 )mWebBrowserImage->getBrowserWidth() / ( F32 )mWebBrowserImage->getWidth();
		F32 max_v = ( F32 )mWebBrowserImage->getBrowserHeight() / ( F32 )mWebBrowserImage->getHeight();

		// draw the browser
		gGL.setSceneBlendType(LLRender::BT_REPLACE);
		gGL.begin( LLRender::QUADS );
		{
			// render using web browser reported width and height, instead of trying to invert GL scale
			gGL.texCoord2f( max_u, max_v );
			gGL.vertex2i( mWebBrowserImage->getBrowserWidth(), mWebBrowserImage->getBrowserHeight() );

			gGL.texCoord2f( 0.f, max_v );
			gGL.vertex2i( 0, mWebBrowserImage->getBrowserHeight() );

			gGL.texCoord2f( 0.f, 0.f );
			gGL.vertex2i( 0, 0 );

			gGL.texCoord2f( max_u, 0.f );
			gGL.vertex2i( mWebBrowserImage->getBrowserWidth(), 0 );
		}
		gGL.end();
		gGL.setSceneBlendType(LLRender::BT_ALPHA);
	}
	gGL.popMatrix();

	// highlight if keyboard focus here. (TODO: this needs some work)
	if ( mBorder->getVisible() )
		mBorder->setKeyboardFocusHighlight( gFocusMgr.childHasKeyboardFocus( this ) );

	
	LLUICtrl::draw();
}
开发者ID:AlexRa,项目名称:Kirstens-clone,代码行数:76,代码来源:llwebbrowserctrl.cpp


示例11: event_loop

static void
event_loop(Display *dpy, struct gears *gears)
{
   int x, y;

   while (1) {
      while (XPending(dpy) > 0) {
         XEvent event;
         XNextEvent(dpy, &event);
         switch (event.type) {
	 case Expose:
            /* we'll redraw below */
	    break;
	 case ConfigureNotify:
	    reshape(gears, event.xconfigure.width, event.xconfigure.height);
	    break;
         case KeyPress:
            {
               char buffer[10];
               int code;
               code = XLookupKeysym(&event.xkey, 0);
               if (code == XK_Left) {
                  view_roty += 5.0;
               }
               else if (code == XK_Right) {
                  view_roty -= 5.0;
               }
               else if (code == XK_Up) {
                  view_rotx += 5.0;
               }
               else if (code == XK_Down) {
                  view_rotx -= 5.0;
               }
               else {
                  XLookupString(&event.xkey, buffer, sizeof(buffer),
                                NULL, NULL);
                  if (buffer[0] == 27) {
                     /* escape */
                     return;
                  }
               }
            }
         }
      }

      /* next frame */
      angle += 2.0;

      draw();
      glFinish();

      for (x = 0; x < gears->width; x += 100)
         for (y = 0; y < gears->width; y += 100)
            XCopyArea(dpy, gears->pixmap, gears->win, gears->gc,
		      50, 50, 100, 100, x, y);

      /* calc framerate */
      {
         static int t0 = -1;
         static int frames = 0;
         int t = current_time();

         if (t0 < 0)
            t0 = t;

         frames++;

         if (t - t0 >= 5.0) {
            GLfloat seconds = t - t0;
            GLfloat fps = frames / seconds;
            printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds,
                   fps);
            fflush(stdout);
            t0 = t;
            frames = 0;
         }
      }
   }
}
开发者ID:Distrotech,项目名称:mesa-demos,代码行数:79,代码来源:glxgears_pixmap.c


示例12: vec

CRSSparsity vec(const CRSSparsity& a){
  return reshape(trans(a),a.numel(),1);
}
开发者ID:tobias-verbeke,项目名称:casadi,代码行数:3,代码来源:sparsity_tools.cpp


示例13: main

// program entry
int32_t main(int32_t argc, char *argv[])
{
    GLFWwindow* window;
    int32_t width, height;

    NvAssetLoaderInit(NULL);

    sWindowIsFocused = true;
    sForcedRenderCount = 0;

    if( !glfwInit() )
    {
        fprintf( stderr, "Failed to initialize GLFW\n" );
        exit( EXIT_FAILURE );
    }

    glfwSetErrorCallback(glfwError);

    NvLinuxPlatformContext* platform = new NvLinuxPlatformContext;

    // add command line arguments
    for (int i = 1; i < argc; i++) {
        platform->m_commandLine.push_back(argv[i]);
    }

    sApp = NvAppFactory(platform);

    NvEGLConfiguration config(NvGfxAPIVersionGL4(), 8, 8, 8, 8, 16, 0);
    sApp->configurationCallback(config);

    // Does not seem to work...
/*
    if (config.api == GLAppContext::Configuration::API_ES)
        glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
    
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, config.majVer);
    //glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
    */

    NvGLLinuxAppContext* context = new NvGLLinuxAppContext(config);

    window = glfwCreateWindow( 1280, 720, "Linux SDK Application", NULL, NULL );
    if (!window)
    {
        fprintf( stderr, "Failed to open GLFW window\n" );
        glfwTerminate();
        exit( EXIT_FAILURE );
    }

    platform->setWindow(window);

    context->setWindow(window);
    sApp->setGLContext(context);

    // Set callback functions
    glfwSetFramebufferSizeCallback(window, reshape);
    glfwSetWindowFocusCallback(window, focus);
    setInputCallbacksGLFW(window);

    context->bindContext();
    glfwSwapInterval( 1 );

    glfwGetFramebufferSize(window, &width, &height);

    int32_t major = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR);
    int32_t minor = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR);
    config.apiVer = NvGfxAPIVersion(NvGfxAPI::GL, major, minor);

    glGetIntegerv(GL_RED_BITS, (GLint*)&config.redBits);
    glGetIntegerv(GL_GREEN_BITS, (GLint*)&config.greenBits);
    glGetIntegerv(GL_BLUE_BITS, (GLint*)&config.blueBits);
    glGetIntegerv(GL_ALPHA_BITS, (GLint*)&config.alphaBits);
    glGetIntegerv(GL_DEPTH_BITS, (GLint*)&config.depthBits);
    glGetIntegerv(GL_STENCIL_BITS, (GLint*)&config.stencilBits);

    context->setConfiguration(config);

#if 1
    // get extensions (need for ES2.0)
    GLenum err = glewInit();
    if (GLEW_OK != err)
    {
      /* Problem: glewInit failed, something is seriously wrong. */
      fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
      exit(-1);
    }
    fprintf(stdout, "Using GLEW %s\n", glewGetString(GLEW_VERSION));
#endif

    // Parse command-line options
    initGL(argc, argv);

    reshape(window, width, height);

    sApp->mainLoop();

    // Shut down the app before shutting down GL
    delete sApp;

//.........这里部分代码省略.........
开发者ID:James-Z,项目名称:OpenGLSamples,代码行数:101,代码来源:MainLinux.cpp


示例14: childSetCommitCallback

//-----------------------------------------------------------------------------
// postBuild()
//-----------------------------------------------------------------------------
BOOL LLFloaterAnimPreview::postBuild()
{
	LLRect r;
	LLKeyframeMotion* motionp = NULL;
	LLBVHLoader* loaderp = NULL;

	if (!LLFloaterNameDesc::postBuild())
	{
		return FALSE;
	}

	mInWorld = gSavedSettings.getBOOL("PreviewAnimInWorld");

	childSetCommitCallback("name_form", onCommitName, this);

	if (gSavedSettings.getBOOL("AscentPowerfulWizard"))
	{
		childSetMaxValue("priority", 7);
	}

	childSetLabelArg("ok_btn", "[UPLOADFEE]", gHippoGridManager->getConnectedGrid()->getUploadFee());
	childSetAction("ok_btn", onBtnOK, this);
	setDefaultBtn();

	if (mInWorld)
	{
		r = getRect();
		translate(0, 230);
		reshape(r.getWidth(), r.getHeight() - 230);
		childSetValue("bad_animation_text", getString("in_world"));
		childShow("bad_animation_text");
	}
	else
	{
		childHide("bad_animation_text");
	}

	mPreviewRect.set(PREVIEW_HPAD, 
		PREVIEW_TEXTURE_HEIGHT,
		getRect().getWidth() - PREVIEW_HPAD, 
		PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD);
	mPreviewImageRect.set(0.f, 1.f, 1.f, 0.f);

	S32 y = mPreviewRect.mTop + BTN_HEIGHT;
	S32 btn_left = PREVIEW_HPAD;

	r.set( btn_left, y, btn_left + 32, y - BTN_HEIGHT );
	mPlayButton = getChild<LLButton>( "play_btn");
	if (!mPlayButton)
	{
		mPlayButton = new LLButton(std::string("play_btn"), LLRect(0,0,0,0));
	}
	mPlayButton->setClickedCallback(onBtnPlay);
	mPlayButton->setCallbackUserData(this);

	mPlayButton->setImages(std::string("button_anim_play.tga"),
						   std::string("button_anim_play_selected.tga"));
	mPlayButton->setDisabledImages(LLStringUtil::null,LLStringUtil::null);

	mPlayButton->setScaleImage(TRUE);

	mStopButton = getChild<LLButton>( "stop_btn");
	if (!mStopButton)
	{
		mStopButton = new LLButton(std::string("stop_btn"), LLRect(0,0,0,0));
	}
	mStopButton->setClickedCallback(onBtnStop);
	mStopButton->setCallbackUserData(this);

	mStopButton->setImages(std::string("button_anim_stop.tga"),
						   std::string("button_anim_stop_selected.tga"));
	mStopButton->setDisabledImages(LLStringUtil::null,LLStringUtil::null);

	mStopButton->setScaleImage(TRUE);

	r.set(r.mRight + PREVIEW_HPAD, y, getRect().getWidth() - PREVIEW_HPAD, y - BTN_HEIGHT);
	//childSetCommitCallback("playback_slider", onSliderMove, this);

	//childSetCommitCallback("preview_base_anim", onCommitBaseAnim, this);
	//childSetValue("preview_base_anim", "Standing");

	//childSetCommitCallback("priority", onCommitPriority, this);
	//childSetCommitCallback("loop_check", onCommitLoop, this);
	//childSetCommitCallback("loop_in_point", onCommitLoopIn, this);
	//childSetValidate("loop_in_point", validateLoopIn);
	//childSetCommitCallback("loop_out_point", onCommitLoopOut, this);
	//childSetValidate("loop_out_point", validateLoopOut);

	//childSetCommitCallback("hand_pose_combo", onCommitHandPose, this);
	
	//childSetCommitCallback("emote_combo", onCommitEmote, this);
	//childSetValue("emote_combo", "[None]");

	//childSetCommitCallback("ease_in_time", onCommitEaseIn, this);
	//childSetValidate("ease_in_time", validateEaseIn);
	//childSetCommitCallback("ease_out_time", onCommitEaseOut, this);
	//childSetValidate("ease_out_time", validateEaseOut);
//.........这里部分代码省略.........
开发者ID:fractured-crystal,项目名称:SingularityViewer,代码行数:101,代码来源:llfloateranimpreview.cpp


示例15: getTextPixelWidth

void LLTextBox::reshapeToFitText()
{
	S32 width = getTextPixelWidth();
	S32 height = getTextPixelHeight();
	reshape( width + 2 * mHPad, height + 2 * mVPad );
}
开发者ID:Xara,项目名称:Luna-Viewer,代码行数:6,代码来源:lltextbox.cpp


示例16: data_size

GLPresenter::GLPresenter(DeckLinkCapture &capture, int w, int h, int hz) : 
	data_size(w*h*capture.getBytesPerPixel()),
	capture(capture), running(true), fullscreen(false), useVsync(false), rgbFull(false),
	texId(0), displayList(0), 
	initialConvert(NULL),
	buffer(NULL), buffer2(NULL),
	reqW(w), reqH(h), reqHz(hz), captureBufferW(reqW / (4 / capture.getBytesPerPixel())),
	frameIndex(0), drawnFrameIndex(0), aspect(16.0/9.0), oneToNScaleFactor(-1.0),
	frameProcTimes(300)
{
	self = this;

	sprintf(prepend, "#version 410 compatibility \n#define FRAME_WIDTH %d \n#define FRAME_HEIGHT %d \n", reqW, reqH);

	RT_ASSERT(glfwInit() == GL_TRUE, "Failed to initalize GLFW.");
	RT_ASSERT(glfwOpenWindow(w, h, 0, 0, 0, 0, 0, 0, GLFW_WINDOW) == GL_TRUE, "Failed to open GLFW window.");

	string title("PtBi ");
	title += VER_STRING;
	glfwSetWindowTitle(title.c_str());
	glfwSetWindowPos(10, 10);

	dataPointers[0] = malloc(data_size);
	dataPointers[1] = malloc(data_size);

	glewInit();
	checkExtensions();

	ilInit();

	glfwDisable(GLFW_AUTO_POLL_EVENTS);
	glfwSwapInterval(0);
	glfwSetWindowCloseCallback(closeCallback);
	glfwSetWindowSizeCallback(resizeCallback);
	glfwSetMousePosCallback(mousePosCallback);
	glfwSetKeyCallback(keyCallback);

	hdc = wglGetCurrentDC();
	hrc = wglGetCurrentContext();

	initGL();

	switch(capture.getPixelFormat()) {
	case CapturePixelFormat::YUV: 
		initialConvert = new GLFragmentProgram("shaders/uyvy_to_rgb_smooth.glsl", getShaderPrependString());
		break;
	case CapturePixelFormat::ARGB8:
		initialConvert = new GLFragmentProgram("shaders/argb_input.glsl", getShaderPrependString());
		break;
	case CapturePixelFormat::BGRA8:
		initialConvert = new GLFragmentProgram("shaders/bgra_input.glsl", getShaderPrependString());
		break;
	default:
		RT_ASSERT(false, "Unsupported pixel type.");
	}

	buffer = new GLRenderTexture(getW(), getH(), GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE);
	buffer->setFilterMode(GL_LINEAR);
	buffer2 = new GLRenderTexture(getW(), getH(), GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE);
	buffer2->setFilterMode(GL_LINEAR);

	scalingManager = new ScalingManager(*this);
	aaManager = new AAManager(*this);
	ipManager = new IPManager(*this);
	keyBinding = new KeyBinding(this);
	capture.registerDisplayListener(this);

	hwnd = GetForegroundWindow();

	RT_GL_ASSERT("Error during GL initialization.");

	reshape(reqW, reqH);
	
	graphicsReportText = std::make_shared<StaticText>("", 25.0f,440.0f);
	Console::get().add(graphicsReportText);
}
开发者ID:PeterTh,项目名称:PtBi,代码行数:76,代码来源:PtOpenGL.cpp


示例17: LLModalDialog

LLAlertDialog::LLAlertDialog( LLNotificationPtr notification, bool modal)
	:	LLModalDialog( notification->getLabel(), 100, 100, modal ),  // dummy size.  Will reshape below.
		LLInstanceTracker<LLAlertDialog, LLUUID>(notification->getID()),
		mDefaultOption( 0 ),
		mCheck(NULL),
		mCaution(notification->getPriority() >= NOTIFICATION_PRIORITY_HIGH),
		mLabel(notification->getName()),
		mLineEditor(NULL),
		mNote(notification)
{
	const LLFontGL* font = LLResMgr::getInstance()->getRes( FONT_NAME );
	const S32 LINE_HEIGHT = llfloor(font->getLineHeight() + 0.99f);
	const S32 EDITOR_HEIGHT = 20;

	LLNotificationFormPtr form = mNote->getForm();
	std::string edit_text_name;
	std::string edit_text_contents;
	bool is_password = false;

	setBackgroundVisible(TRUE);
	setBackgroundOpaque(TRUE);


	typedef std::vector<std::pair<std::string, std::string> > options_t;
	options_t supplied_options;

	// for now, get LLSD to iterator over form elements
	LLSD form_sd = form->asLLSD();

	S32 option_index = 0;
	for (LLSD::array_const_iterator it = form_sd.beginArray(); it != form_sd.endArray(); ++it)
	{
		std::string type = (*it)["type"].asString();
		if (type == "button")
		{
			if((*it)["default"])
			{
				mDefaultOption = option_index;
			}

			supplied_options.push_back(std::make_pair((*it)["name"].asString(), (*it)["text"].asString()));

			ButtonData data;
			data.mSelf = this;
			if (option_index == mNote->getURLOption())
			{
				data.mURL = mNote->getURL();
			}

			mButtonData.push_back(data);
			option_index++;
		}
		else if (type == "text")
		{
			edit_text_contents = (*it)["value"].asString();
			edit_text_name = (*it)["name"].asString();
		}
		else if (type == "password")
		{
			edit_text_contents = (*it)["value"].asString();
			edit_text_name = (*it)["name"].asString();
			is_password = true;
		}
	}

	// Buttons
	options_t options;
	if (supplied_options.empty())
	{
		options.push_back(std::make_pair(std::string("close"), std::string("Close")));

		// add data for ok button.
		ButtonData ok_button;
		ok_button.mSelf = this;
		
		mButtonData.push_back(ok_button);
		mDefaultOption = 0;
	}
	else
	{
		options = supplied_options;
	}

	S32 num_options = options.size();

	// Calc total width of buttons
	S32 button_width = 0;
	S32 sp = font->getWidth(std::string("OO"));
	for( S32 i = 0; i < num_options; i++ )
	{
		S32 w = S32(font->getWidth( options[i].second ) + 0.99f) + sp + 2 * LLBUTTON_H_PAD;
		button_width = llmax( w, button_width );
	}
	S32 btn_total_width = button_width;
	if( num_options > 1 )
	{
		btn_total_width = (num_options * button_width) + ((num_options - 1) * BTN_HPAD);
	}

	// Message: create text box using raw string, as text has been structure deliberately
//.........这里部分代码省略.........
开发者ID:9skunks,项目名称:imprudence,代码行数:101,代码来源:llalertdialog.cpp


示例18: event_loop

static void
event_loop(Display *dpy, Window win)
{
   while (1) {
      while (XPending(dpy) > 0) {
         XEvent event;
         XNextEvent(dpy, &event);
         switch (event.type) {
	 case Expose:
            /* we'll redraw below */
	    break;
	 case ConfigureNotify:
	    reshape(event.xconfigure.width, event.xconfigure.height);
	    break;
         case KeyPress:
            {
               char buffer[10];
               int r, code;
               code = XLookupKeysym(&event.xkey, 0);
               if (code == XK_Left) {
                  view_roty += 5.0;
               }
               else if (code == XK_Right) {
                  view_roty -= 5.0;
               }
               else if (code == XK_Up) {
                  view_rotx += 5.0;
               }
               else if (code == XK_Down) {
                  view_rotx -= 5.0;
               }
               else {
                  r = XLookupString(&event.xkey, buffer, sizeof(buffer),
                                    NULL, NULL);
                  if (buffer[0] == 27) {
                     /* escape */
                     return;
                  }
               }
            }
         }
      }

      /* next frame */
      angle += 2.0;

      draw();
      glXSwapBuffers(dpy, win);

      /* calc framerate */
      {
         static int t0 = -1;
         static int frames = 0;
         int t = current_time();

         if (t0 < 0)
            t0 = t;

         frames++;

         if (t - t0 >= 5.0) {
            GLfloat seconds = t - t0;
            GLfloat fps = frames / seconds;
            printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds,
                   fps);
            t0 = t;
            frames = 0;
         }
      }
   }
}
开发者ID:BackupTheBerlios,项目名称:dri-ex-svn,代码行数:71,代码来源:glxgears_fbconfig.c


示例19: switch

////////////////////////////////////////////////////////////////////////////////
// inherited from LLViewerMediaObserver
//virtual 
void LLMediaCtrl::handleMediaEvent(LLPluginClassMedia*  

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ resid函数代码示例发布时间:2022-05-30
下一篇:
C++ resethookcount函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap