예제 #1
0
        static bool arglPixelFormatGet(ARGL_CONTEXT_SETTINGS contextSettings, ref AR_PIXEL_FORMAT format, ref int size)
        {
            if (contextSettings == null)
            {
                return(false);
            }

            format = contextSettings.format;
            size   = contextSettings.pixSize;

            return(true);
        }
예제 #2
0
        static bool arglPixelFormatSet(ARGL_CONTEXT_SETTINGS contextSettings, AR_PIXEL_FORMAT format)
        {
            if (contextSettings == null)
            {
                return(false);
            }
            switch (format)
            {
            case AR_PIXEL_FORMAT.AR_PIXEL_FORMAT_Rgba:
                contextSettings.pixIntFormat = (int)All1.Rgba;
                contextSettings.pixFormat    = (int)All1.Rgba;
                contextSettings.pixType      = (int)All1.UnsignedByte;
                contextSettings.pixSize      = 4;
                break;

            case AR_PIXEL_FORMAT.AR_PIXEL_FORMAT_Bgra:      // Windows.
                contextSettings.pixIntFormat = (int)All1.Rgba;
                contextSettings.pixFormat    = (int)All1.Bgra;
                contextSettings.pixType      = (int)All1.UnsignedByte;
                contextSettings.pixSize      = 4;
                break;

            case AR_PIXEL_FORMAT.AR_PIXEL_FORMAT_ABGR:      // SGI.
                contextSettings.pixIntFormat = (int)All1.Rgba;
                contextSettings.pixFormat    = (int)All1.AbgrExt;
                contextSettings.pixType      = (int)All1.UnsignedByte;
                contextSettings.pixSize      = 4;
                break;

            case AR_PIXEL_FORMAT.AR_PIXEL_FORMAT_ARGB:      // Mac.
                contextSettings.pixIntFormat = (int)All1.Rgba;
                contextSettings.pixFormat    = (int)All1.Bgra;
                contextSettings.pixType      = (int)All1.UnsignedInt8888;
                contextSettings.pixSize      = 4;
                break;

            case AR_PIXEL_FORMAT.AR_PIXEL_FORMAT_RGB:
                contextSettings.pixIntFormat = (int)All1.Rgb;
                contextSettings.pixFormat    = (int)All1.Rgb;
                contextSettings.pixType      = (int)All1.UnsignedByte;
                contextSettings.pixSize      = 3;
                break;

            case AR_PIXEL_FORMAT.AR_PIXEL_FORMAT_BGR:
                contextSettings.pixIntFormat = (int)All1.Rgb;
                contextSettings.pixFormat    = (int)All1.Rgb;
                contextSettings.pixType      = (int)All1.UnsignedByte;
                contextSettings.pixSize      = 3;
                break;

            default:
                return(false);

                break;
            }
            contextSettings.format           = format;
            contextSettings.textureDataReady = false;

            if (!arglSetupTextureObjects(contextSettings))
            {
                return(false);
            }

            return(true);
        }
예제 #3
0
        public static ARGL_CONTEXT_SETTINGS arglSetupForCurrentContext(ARParam cparam, AR_PIXEL_FORMAT pixelFormat)
        {
            ARGL_CONTEXT_SETTINGS contextSettings;

            contextSettings         = new ARGL_CONTEXT_SETTINGS();
            contextSettings.arParam = cparam; // Copy it.
            contextSettings.zoom    = 1.0f;
            // Because of calloc used above, these are redundant.
            //contextSettings.rotate90 = contextSettings.flipH = contextSettings.flipV = false;
            //contextSettings.disableDistortionCompensation = false;
            //contextSettings.textureGeometryHasBeenSetup = false;
            //contextSettings.textureObjectsHaveBeenSetup = false;
            //contextSettings.textureDataReady = false;

            // This sets pixIntFormat, pixFormat, pixType, pixSize, and resets textureDataReady.
            arglPixelFormatSet(contextSettings, pixelFormat);

            // Set pixel buffer sizes to incoming image size, by default.
            if (!arglPixelBufferSizeSet(contextSettings, cparam.xsize, cparam.ysize))
            {
                Debug.Print("ARGL: Error setting pixel buffer size.\n");
                contextSettings = null;
                return(null);
            }

            return(contextSettings);
        }