示例#1
0
void ProcessThread::runGPUProcess()
{
	unsigned short *DataFramePos;
	bool initCuda = false;
	bool registeredHost = false;
	const bool startFundus = true; //Modify this value to turn en face ON or OFF when bVolumeScan==true
	const bool startVolume = false; //Modify this value to turn volume rendering ON or OFF when bVolumeScan==true
	const bool slowBscan = false;//This option is currently used only for fundus + Bscan mode, and no volume
	//Slow Bscan requires more GPU memory than without slow Bscan, so ENSURE that the GPU has enough memory for the specified volume size
	//E.G. if Volume size is 2048x512x400, ensure GPU has AT LEAST 2048x512x400xsizeof(float)= 1.6GB of memory (perhaps even more)
	float mul = float(globalOptions->IMAGEWIDTH);

	//2nd, 3rd, and 4th order corrections for interpolation
	//The values (constant) for the second – further order corrections  are based on measurements for our particular system. 
	//For display purposes, we found that it was sufficient to adjust the value of lambda rather than the correction factors, 
		//while minimizing the complexity of the user interface.
	const float SECOND_ORDER_CORRECTION = 0.0f;
	const float THIRD_ORDER_CORRECTION	= 0.0f;
	const float FOURTH_ORDER_CORRECTION = 0.0f;
	float lambda_Max= globalOptions->LambdaMin	+	(mul-1) * globalOptions->dLambda	+
					pow((mul-1.0f),2) * SECOND_ORDER_CORRECTION	+
					pow((mul-1.0f),3) * THIRD_ORDER_CORRECTION	+
					pow((mul-1.0f),4) * FOURTH_ORDER_CORRECTION;

	float dispMag = 10.0f;
	int samplingMethod = 0;
	int fftLenMult = 2;
	bool fundusStatus = startFundus;
	bool volumeStatus = startVolume;
	int framesPerBuffer = 5;

	if (!initCuda) {
		initGLVarAndPtrs(	true,				//ProcessData, ProcessData false is currently deprecated in this version of the code
							startVolume,		//VolumeRender
							startFundus,		//Fundus Render
							slowBscan,
							globalOptions->IMAGEWIDTH, 
							globalOptions->IMAGEHEIGHT, 
							framesPerBuffer, 
							globalOptions->IMAGEWIDTH * globalOptions->IMAGEHEIGHT * globalOptions->NumFramesPerVol, 
							768, //Window Width, Subwindow Width is always half of this value
							768, //Window Height, Subwindow Height is always half of this value
							samplingMethod,
							1);

/* Initialize CUDA Variables and Pointers */
		initCudaProcVar(	globalOptions->IMAGEWIDTH, 
							globalOptions->IMAGEHEIGHT, 
							framesPerBuffer, 
							globalOptions->LambdaMin,
							lambda_Max,
							dispMag,
							0, //globalOptions->a2, for dispersion, use default value of 0 instead
							0, //globalOptions->a3, for dispersion, use default value of 0 instead
							samplingMethod,
							fftLenMult);
		initGLEvent(0, 0);
		initCuda = true;
	}

    //Infinite Loop
	//Temporarily we have incorporated an infinite loop. Stop the program execution by closing the program. 
	//Threads can also be suspended and resumed via the start/stop buttons
	while (true)
	{
		DataFramePos = RawData;
		setFrameSize(globalOptions->NumFramesPerVol);
		setBufferPtr(DataFramePos);
		if (!registeredHost) {
			//Comment out the registerCudaHost if too much host memory is being allocated
			//Registering too much page-locked memory could crash the program
			registerCudaHost();
			registeredHost = true;
		}
		
		//runGLEvent executes one iteration of the CUDA code, including:
		//-Processing
		//-fundus render aka sum voxel (optional)
		//-volume render aka raycast (optional)
		//-bilateral filtering (optional)
		//-averaging (optional)
		//-Display for line-plot, B-scan, fundus, and volume
		runGLEvent();

		if (startFundus && fundusStatus != globalOptions->bVolumeScan) {
			fundusStatus = globalOptions->bVolumeScan;
			fundusSwitch();
		}

		if (startVolume && volumeStatus != globalOptions->bVolumeScan) {
			volumeStatus = globalOptions->bVolumeScan;
			volumeSwitch();
		}
	} //while (true)
}
	/// Override BaseTrafficHandler::setMRU() to set frameSize_ instead of MRU_.
	void setMRU(const size_t newVal) { setFrameSize(newVal); }	
示例#3
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();
    if(!glview) {
        glview = GLView::create("My Game");
        director->setOpenGLView(glview);
    }

    // turn on display FPS
    director->setDisplayStats(false);

    // set FPS. the default value is 1.0/60 if you don't call this
    director->setAnimationInterval(1.0 / 60);

	//屏幕大小
	//auto screenSize=glview->getFrameSize();
	glview->setFrameSize(320,480);
	auto screenSize=Size(640,960);
	//设计分辨率
	auto designSize=Size(320,480);


	//资源大小
	auto resourceSize=Size(640,960);

	std::vector<std::string> SearchPaths;

	/*if(screenSize.height>960)
	{
		designSize=Size(320,568);
		resourceSize=Size(640,1136);
		SearchPaths.push_back("hd5"); ////////////////////////
	}*/
	if(screenSize.height>960)
	{
		designSize=Size(320,568);
		SearchPaths.push_back("hd");
	}
	else if(screenSize.height>480)
	{
		resourceSize=Size(640,960);
		SearchPaths.push_back("hd");
	}
	else
	{
		SearchPaths.push_back("sd");
	}

	director->setContentScaleFactor(resourceSize.width/designSize.width);

	FileUtils::getInstance()->setSearchPaths(SearchPaths);

	glview->setDesignResolutionSize(designSize.width,designSize.height,ResolutionPolicy::FIXED_WIDTH);


    // create a scene. it's an autorelease object
    auto scene = HelloWorld::createScene();

    // run
    director->runWithScene(scene);

    return true;
}
示例#4
0
文件: CCEGLView.cpp 项目: Gamex/GameX
bool EGLView::initGL()
{
    EGLint eglConfigCount;
    EGLConfig config;

    // Hard-coded to 32-bit/OpenGL ES 2.0.
    const EGLint eglConfigAttrs[] =
    {
        EGL_RED_SIZE,           8,
        EGL_GREEN_SIZE,         8,
        EGL_BLUE_SIZE,          8,
        EGL_ALPHA_SIZE,         8,
        EGL_DEPTH_SIZE,         24,
        EGL_STENCIL_SIZE,       8,
        EGL_SURFACE_TYPE,       EGL_WINDOW_BIT,
        EGL_RENDERABLE_TYPE,    EGL_OPENGL_ES2_BIT,
        EGL_NONE
    };

    const EGLint eglContextAttrs[] =
    {
        EGL_CONTEXT_CLIENT_VERSION,    2,
        EGL_NONE
    };

    const EGLint eglSurfaceAttrs[] =
    {
        EGL_RENDER_BUFFER,    EGL_BACK_BUFFER,
        EGL_NONE
    };

    // Get the EGL display and initialize.
    _eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    if (_eglDisplay == EGL_NO_DISPLAY)
    {
        perror("eglGetDisplay");
        return false;
    }

    if (eglInitialize(_eglDisplay, NULL, NULL) != EGL_TRUE)
    {
        perror("eglInitialize");
        return false;
    }

    if (eglChooseConfig(_eglDisplay, eglConfigAttrs, &config, 1, &eglConfigCount) != EGL_TRUE || eglConfigCount == 0)
    {
        checkErrorEGL("eglChooseConfig");
        return false;
    }

    _eglContext = eglCreateContext(_eglDisplay, config, EGL_NO_CONTEXT, eglContextAttrs);
    if (_eglContext == EGL_NO_CONTEXT)
    {
        checkErrorEGL("eglCreateContext");
        return false;
    }

    _eglSurface = eglCreateWindowSurface(_eglDisplay, config, NULL, eglSurfaceAttrs);
    if (_eglSurface == EGL_NO_SURFACE)
    {
        checkErrorEGL("eglCreateWindowSurface");
        return false;
    }

    if (eglMakeCurrent(_eglDisplay, _eglSurface, _eglSurface, _eglContext) != EGL_TRUE)
    {
        checkErrorEGL("eglMakeCurrent");
        return false;
    }

    // FIXME: Get the actual canvas size somehow.
    EGLint width;
    EGLint height;

    if ((_eglDisplay == EGL_NO_DISPLAY) || (_eglSurface == EGL_NO_SURFACE) )
    	return EXIT_FAILURE;

	eglQuerySurface(_eglDisplay, _eglSurface, EGL_WIDTH, &width);
    eglQuerySurface(_eglDisplay, _eglSurface, EGL_HEIGHT, &height);

    _screenSize.width = width;
    _screenSize.height = height;

    glViewport(0, 0, width, height);

    // Default the frame size to be the whole canvas. In general we want to be
    // setting the size of the viewport by adjusting the canvas size (so
    // there's no weird letterboxing).
    setFrameSize(width, height);

    return true;
}
bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float frameZoomFactor, bool resizable)
{
    setViewName(viewName);

    _frameZoomFactor = frameZoomFactor;

    glfwWindowHint(GLFW_RESIZABLE, resizable ? GL_TRUE : GL_FALSE);
    glfwWindowHint(GLFW_RED_BITS,_glContextAttrs.redBits);
    glfwWindowHint(GLFW_GREEN_BITS,_glContextAttrs.greenBits);
    glfwWindowHint(GLFW_BLUE_BITS,_glContextAttrs.blueBits);
    glfwWindowHint(GLFW_ALPHA_BITS,_glContextAttrs.alphaBits);
    glfwWindowHint(GLFW_DEPTH_BITS,_glContextAttrs.depthBits);
    glfwWindowHint(GLFW_STENCIL_BITS,_glContextAttrs.stencilBits);

    int needWidth = rect.size.width * _frameZoomFactor;
    int neeHeight = rect.size.height * _frameZoomFactor;

    _mainWindow = glfwCreateWindow(needWidth, neeHeight, _viewName.c_str(), _monitor, nullptr);

    if (_mainWindow == nullptr)
    {
        std::string message = "Can't create window";
        if (!_glfwError.empty())
        {
            message.append("\nMore info: \n");
            message.append(_glfwError);
        }

        MessageBox(message.c_str(), "Error launch application");
        return false;
    }

    /*
    *  Note that the created window and context may differ from what you requested,
    *  as not all parameters and hints are
    *  [hard constraints](@ref window_hints_hard).  This includes the size of the
    *  window, especially for full screen windows.  To retrieve the actual
    *  attributes of the created window and context, use queries like @ref
    *  glfwGetWindowAttrib and @ref glfwGetWindowSize.
    *
    *  see declaration glfwCreateWindow
    */
    int realW = 0, realH = 0;
    glfwGetWindowSize(_mainWindow, &realW, &realH);
    if (realW != needWidth)
    {
        rect.size.width = realW / _frameZoomFactor;
    }
    if (realH != neeHeight)
    {
        rect.size.height = realH / _frameZoomFactor;
    }

    glfwMakeContextCurrent(_mainWindow);

    glfwSetMouseButtonCallback(_mainWindow, GLFWEventHandler::onGLFWMouseCallBack);
    glfwSetCursorPosCallback(_mainWindow, GLFWEventHandler::onGLFWMouseMoveCallBack);
    glfwSetScrollCallback(_mainWindow, GLFWEventHandler::onGLFWMouseScrollCallback);
    glfwSetCharCallback(_mainWindow, GLFWEventHandler::onGLFWCharCallback);
    glfwSetKeyCallback(_mainWindow, GLFWEventHandler::onGLFWKeyCallback);
    glfwSetWindowPosCallback(_mainWindow, GLFWEventHandler::onGLFWWindowPosCallback);
    glfwSetFramebufferSizeCallback(_mainWindow, GLFWEventHandler::onGLFWframebuffersize);
    glfwSetWindowSizeCallback(_mainWindow, GLFWEventHandler::onGLFWWindowSizeFunCallback);
    glfwSetWindowIconifyCallback(_mainWindow, GLFWEventHandler::onGLFWWindowIconifyCallback);

    setFrameSize(rect.size.width, rect.size.height);

    // check OpenGL version at first
    const GLubyte* glVersion = glGetString(GL_VERSION);

    if ( utils::atof((const char*)glVersion) < 1.5 )
    {
        char strComplain[256] = {0};
        sprintf(strComplain,
                "OpenGL 1.5 or higher is required (your version is %s). Please upgrade the driver of your video card.",
                glVersion);
        MessageBox(strComplain, "OpenGL version too old");
        return false;
    }

    initGlew();

    // Enable point size by default.
    glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);

    return true;
}
示例#6
0
DropDown::DropDown(gcn::ListModel *listModel, gcn::ActionListener* listener,
                   std::string eventId):
    gcn::DropDown::DropDown(listModel,
                            new ScrollArea,
                            new ListBox(listModel))
{
    setFrameSize(2);

    // Initialize graphics
    if (instances == 0)
    {
        // Load the background skin

        // Get the button skin
        buttons[1][0] = Theme::getImageFromTheme("vscroll_up_default.png");
        buttons[0][0] = Theme::getImageFromTheme("vscroll_down_default.png");
        buttons[1][1] = Theme::getImageFromTheme("vscroll_up_pressed.png");
        buttons[0][1] = Theme::getImageFromTheme("vscroll_down_pressed.png");

        if (buttons[0][0])
            buttons[0][0]->setAlpha(mAlpha);
        if (buttons[0][1])
            buttons[0][1]->setAlpha(mAlpha);
        if (buttons[1][0])
            buttons[1][0]->setAlpha(mAlpha);
        if (buttons[1][1])
            buttons[1][1]->setAlpha(mAlpha);

        // get the border skin
        Image *boxBorder = Theme::getImageFromTheme("deepbox.png");
        if (boxBorder)
        {
            int gridx[4] = {0, 3, 28, 31};
            int gridy[4] = {0, 3, 28, 31};
            int a = 0, x, y;

            for (y = 0; y < 3; y++)
            {
                for (x = 0; x < 3; x++)
                {
                    skin.grid[a] = boxBorder->getSubImage(gridx[x], gridy[y],
                                                          gridx[x + 1] -
                                                          gridx[x] + 1,
                                                          gridy[y + 1] -
                                                          gridy[y] + 1);
                    if (skin.grid[a])
                        skin.grid[a]->setAlpha(mAlpha);
                    a++;
                }
            }

            boxBorder->decRef();
        }
    }

    instances++;

    mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
    mShadowColor = Theme::getThemeColor(Theme::DROPDOWN_SHADOW);
    setForegroundColor(Theme::getThemeColor(Theme::TEXT));

    if (!eventId.empty())
        setActionEventId(eventId);

    if (listener)
        addActionListener(listener);
}
示例#7
0
bool EGLView::init(const char* viewName, float width, float height, float frameZoomFactor)
{
    if(nullptr != _mainWindow) return true;

    setViewName(viewName);
    setFrameSize(width, height);
    setFrameZoomFactor(frameZoomFactor);

    glfwWindowHint(GLFW_RESIZABLE,GL_FALSE);
   _mainWindow = glfwCreateWindow(_screenSize.width * _frameZoomFactor, _screenSize.height * _frameZoomFactor, _viewName, nullptr, nullptr);
    glfwMakeContextCurrent(_mainWindow);
    
    glfwGetFramebufferSize(_mainWindow, &_frameBufferSize[0], &_frameBufferSize[1]);
    
    glfwSetMouseButtonCallback(_mainWindow,EGLViewEventHandler::OnGLFWMouseCallBack);
    glfwSetCursorPosCallback(_mainWindow,EGLViewEventHandler::OnGLFWMouseMoveCallBack);
    glfwSetCharCallback(_mainWindow, EGLViewEventHandler::OnGLFWCharCallback);
    glfwSetKeyCallback(_mainWindow, EGLViewEventHandler::OnGLFWKeyCallback);
    glfwSetWindowPosCallback(_mainWindow, EGLViewEventHandler::OnGLFWWindowPosCallback);

    // check OpenGL version at first
    const GLubyte* glVersion = glGetString(GL_VERSION);
    CCLOG("OpenGL version = %s", glVersion);
    
    if ( atof((const char*)glVersion) < 1.5 )
    {
        char strComplain[256] = {0};
        sprintf(strComplain,
                "OpenGL 1.5 or higher is required (your version is %s). Please upgrade the driver of your video card.",
                glVersion);
        MessageBox(strComplain, "OpenGL version too old");
        return false;
    }
    
    GLenum GlewInitResult = glewInit();
    if (GLEW_OK != GlewInitResult)
    {
        MessageBox((char *)glewGetErrorString(GlewInitResult), "OpenGL error");
        return false;
    }
    
    if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader)
    {
        log("Ready for GLSL");
    }
    else
    {
        log("Not totally ready :(");
    }
    
    if (glewIsSupported("GL_VERSION_2_0"))
    {
       log("Ready for OpenGL 2.0");
    }
    else
    {
        log("OpenGL 2.0 not supported");
    }
    
//    if(glew_dynamic_binding() == false)
//    {
//        MessageBox("No OpenGL framebuffer support. Please upgrade the driver of your video card.", "OpenGL error");
//        return false;
//    }
//    
    // Enable point size by default on windows.
    glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
    
    return true;
}
示例#8
0
void SpritePlus::setFrameSize(sf::Vector2f size)
{
	setFrameSize(size.x, size.y);
}
void ProjectConfig::parseCommandLine(const vector<string> &args)
{
    auto it = args.begin();
    while (it != args.end())
    {
        string arg = *it;

        if (arg.compare("-workdir") == 0)
        {
            ++it;
            if (it == args.end()) break;
            setProjectDir(*it);
            if (_writablePath.length() == 0) setWritablePath(*it);
        }
        else if (arg.compare("-writable-path") == 0)
        {
            ++it;
            if (it == args.end()) break;
            setWritablePath(*it);
        }
        else if (arg.compare("-entry") == 0)
        {
            ++it;
            if (it == args.end()) break;
            setScriptFile(*it);
        }
        else if (arg.compare("-landscape") == 0)
        {
            setFrameSize(cocos2d::Size(DEFAULT_HEIGHT, DEFAULT_WIDTH));
        }
        else if (arg.compare("-portrait") == 0)
        {
            setFrameSize(cocos2d::Size(DEFAULT_WIDTH, DEFAULT_HEIGHT));
        }
        else if (arg.compare("-resolution") == 0)
        {
            ++it;
            if (it == args.end()) break;
            const string& sizeStr(*it);
            size_t pos = sizeStr.find('x');
            int width = 0;
            int height = 0;
            if (pos != sizeStr.npos && pos > 0)
            {
                string widthStr, heightStr;
                widthStr.assign(sizeStr, 0, pos);
                heightStr.assign(sizeStr, pos + 1, sizeStr.length() - pos);
                width = atoi(widthStr.c_str());
                height = atoi(heightStr.c_str());
                setFrameSize(cocos2d::Size(width, height));
            }
        }
        else if (arg.compare("-scale") == 0)
        {
            ++it;
            if (it == args.end()) break;
            float scale = atof((*it).c_str());
            setFrameScale(scale);
        }
        else if (arg.compare("-write-debug-log") == 0)
        {
            ++it;
            if (it == args.end()) break;
            setDebugLogFilePath((*it));
            setWriteDebugLogToFile(true);
        }
        else if (arg.compare("-console") == 0)
        {
            ++it;
            if (it == args.end()) break;
            if ((*it).compare("enable") == 0)
            {
                setShowConsole(true);
            }
            else
            {
                setShowConsole(false);
            }
        }
        else if (arg.compare("-position") == 0)
        {
            ++it;
            if (it == args.end()) break;
            const string& posStr(*it);
            size_t pos = posStr.find(',');
            int x = 0;
            int y = 0;
            if (pos != posStr.npos && pos > 0)
            {
                string xStr, yStr;
                xStr.assign(posStr, 0, pos);
                yStr.assign(posStr, pos + 1, posStr.length() - pos);
                x = atoi(xStr.c_str());
                y = atoi(yStr.c_str());
                setWindowOffset(cocos2d::Vec2(x, y));
            }
        }
        else if (arg.compare("-debugger") == 0)
        {
            ++it;
            if (it == args.end()) break;
            if ((*it).compare("codeide") == 0)
            {
                setDebuggerType(kCCRuntimeDebuggerCodeIDE);
            }
            else if ((*it).compare("studio") == 0)
            {
                setDebuggerType(kCCRuntimeDebuggerStudio);
            }
        }
        else if (arg.compare("-app-menu") == 0)
        {
            _isAppMenu = true;
        }
        else if (arg.compare("-resize-window") == 0)
        {
            _isResizeWindow = true;
        }
        else if (arg.compare("-retina-display") == 0)
        {
            _isRetinaDisplay = true;
        }
        else if (arg.compare("-port") == 0)
        {
            CCLOG("TODO:");
        }
        else if (arg.compare("-listen") == 0)
        {
            ++it;
            setBindAddress((*it));
        }
        else if (arg.compare("-search-path") == 0)
        {
            ++it;
            vector<string> pathes = split((*it), ';');
            setSearchPath(pathes);
        }

        ++it;
    }
}
示例#10
0
void ScrollArea::setOpaque(bool opaque)
{
    mOpaque = opaque;
    setFrameSize(mOpaque ? 2 : 0);
}