Beispiel #1
0
        /// <summary>
        /// Creates the OpenGL instance.
        /// </summary>
        /// <param name="renderContextType">Type of the render context.</param>
        /// <param name="width">The drawing context width.</param>
        /// <param name="height">The drawing context height.</param>
        /// <param name="bitDepth">The bit depth.</param>
        /// <param name="parameter">The parameter.</param>
        /// <returns></returns>
		public virtual bool Create(ref RenderContextType renderContextType, int width, int height, int bitDepth, object parameter)
		{	
            //  Return if we don't have a sensible width or height.
			if(width == 0 || height == 0 || bitDepth == 0)
				return false;
            try
            {

                //	Create an instance of the render context provider.
                switch (renderContextType)
                {
                    case RenderContextType.DIBSection:
                        renderContextProvider = new DIBSectionRenderContextProvider();
                        break;
                    case RenderContextType.NativeWindow:
                        renderContextProvider = new NativeWindowRenderContextProvider();
                        break;
                    case RenderContextType.HiddenWindow:
                        renderContextProvider = new HiddenWindowRenderContextProvider();
                        break;
                    case RenderContextType.FBO:
                        renderContextProvider = new FBORenderContextProvider();
                        break;
                }

                //	Create the render context.
                renderContextProvider.Create(this, width, height, bitDepth, parameter);
            }
            catch
            {
                //if FBO failed, try with DIBSection
                if (renderContextType==RenderContextType.FBO)
                {
                    renderContextType = RenderContextType.DIBSection;
                    renderContextProvider = null;
                    renderContextProvider = new DIBSectionRenderContextProvider();
                    //	Create the render context, second try
                    renderContextProvider.Create(this, width, height, bitDepth, parameter);
                }
            }
			
			return true;
		}
Beispiel #2
0
        /// <summary>
        /// Creates the OpenGL instance.
        /// </summary>
        /// <param name="openGLVersion">The OpenGL version requested.</param>
        /// <param name="renderContextType">Type of the render context.</param>
        /// <param name="width">The drawing context width.</param>
        /// <param name="height">The drawing context height.</param>
        /// <param name="bitDepth">The bit depth.</param>
        /// <param name="parameter">The parameter.</param>
        /// <returns></returns>
		public virtual bool Create(OpenGLVersion openGLVersion, RenderContextType renderContextType, int width, int height, int bitDepth, object parameter)
		{	
            //  Return if we don't have a sensible width or height.
			if(width == 0 || height == 0 || bitDepth == 0)
				return false;

			//	Create an instance of the render context provider.
			switch(renderContextType)
			{
			case RenderContextType.DIBSection:
				renderContextProvider = new DIBSectionRenderContextProvider();
				break;
            case RenderContextType.NativeWindow:
                renderContextProvider = new NativeWindowRenderContextProvider();
                break;
			case RenderContextType.HiddenWindow:
				renderContextProvider = new HiddenWindowRenderContextProvider();
				break;
			case RenderContextType.FBO:
				renderContextProvider = new FBORenderContextProvider();
				break;
			}

			//	Create the render context.
			renderContextProvider.Create(openGLVersion, this, width, height, bitDepth, parameter);
			
			return true;
		}