Beispiel #1
0
        public override void BufferSubData(
            OpenGLDevice device,
            OpenGLDevice.GLenum buffer, bool discard,
            OpenGLDevice.IOpenGLBuffer handle,
            int elementSizeInBytes, int offsetInBytes,
            Array data, int startIndex, int elementCount
            )
        {
            if (discard)
            {
                device.glBufferData(
                    OpenGLDevice.GLenum.GL_ELEMENT_ARRAY_BUFFER,
                    (IntPtr)handle.BufferSize,
                    IntPtr.Zero,
                    handle.Dynamic
                    );
            }

            GCHandle dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned);

            device.glBufferSubData(
                OpenGLDevice.GLenum.GL_ELEMENT_ARRAY_BUFFER,
                offsetInBytes,
                elementSizeInBytes * elementCount,
                (IntPtr)(dataHandle.AddrOfPinnedObject().ToInt64() + startIndex * elementSizeInBytes)
                );

            dataHandle.Free();
        }
Beispiel #2
0
 public abstract void BufferSubData(
     OpenGLDevice device,
     OpenGLDevice.GLenum buffer, bool discard,
     OpenGLDevice.IOpenGLBuffer bufferHandle,
     int elementSizeInBytes, int offsetInBytes,
     Array data, int startIndex, int elementCount
     );
Beispiel #3
0
 public override void glUniform4fv(
     OpenGLDevice openGLDevice, int _location, byte[] _buffer
     )
 {
     fixed(byte *pBuffer = _buffer)
     {
         openGLDevice.glUniform4fv(
             _location, _buffer.Length / 16,
             (float *)pBuffer
             );
     }
 }
Beispiel #4
0
 public override void glUniform4fv(
     OpenGLDevice openGLDevice, int _location, float[] _buffer
     )
 {
     fixed(float *pBuffer = _buffer)
     {
         openGLDevice.glUniform4fv(
             _location, _buffer.Length / 4,
             pBuffer
             );
     }
 }
Beispiel #5
0
        private void _glUniform4fv(
            OpenGLDevice openGLDevice, int _location, Array _buffer
            )
        {
            var lengthBytes = Buffer.ByteLength(_buffer);

            // FIXME: Blech, copy into the emscripten heap
            using (var packed = new NativePackedArray <float>("sdl2.dll", lengthBytes / 4))
                fixed(float *pPacked = packed.Array)
                {
                    Buffer.BlockCopy(_buffer, 0, packed.Array, 0, lengthBytes);
                    openGLDevice.glUniform4fv(_location, packed.Length / 4, pPacked);
                }
        }
Beispiel #6
0
        public override void BufferSubData(
            OpenGLDevice device,
            OpenGLDevice.GLenum buffer, bool discard,
            OpenGLDevice.IOpenGLBuffer handle,
            int elementSizeInBytes, int offsetInBytes,
            Array data, int startIndex, int elementCount
            )
        {
            var gl = GetWebGLContext();

            if (discard)
            {
                gl.bufferData(
                    (int)buffer,
                    handle.BufferSize,
                    (int)handle.Dynamic
                    );
            }

            var view = Verbatim.Expression("new Uint8Array($0.buffer, $1, $2)", data, offsetInBytes, elementSizeInBytes * elementCount);

            gl.bufferSubData((int)buffer, startIndex, view);
        }
		private OpenGL20Geometry(GeometryCreationData creationData, OpenGLDevice device)
			: base(creationData)
		{
			this.device = device;
		}
		protected OpenGL20Geometry(string contentName, OpenGLDevice device)
			: base(contentName)
		{
			this.device = device;
		}
Beispiel #9
0
        public SDL2_GamePlatform(Game game) : base(game, SDL.SDL_GetPlatform())
        {
            /* SDL2 might complain if an OS that uses SDL_main has not actually
             * used SDL_main by the time you initialize SDL2.
             * The only platform that is affected is Windows, but we can skip
             * their WinMain. This was only added to prevent iOS from exploding.
             * -flibit
             */
            SDL.SDL_SetMainReady();

            // This _should_ be the first real SDL call we make...
            SDL.SDL_Init(
                SDL.SDL_INIT_VIDEO |
                SDL.SDL_INIT_JOYSTICK |
                SDL.SDL_INIT_GAMECONTROLLER |
                SDL.SDL_INIT_HAPTIC
                );

            // Set and initialize the SDL2 window
            Window = new SDL2_GameWindow();

            // Disable the screensaver.
            SDL.SDL_DisableScreenSaver();

            // We hide the mouse cursor by default.
            if (IsMouseVisible)
            {
                IsMouseVisible = false;
            }
            else
            {
                /* Since IsMouseVisible is already false, OnMouseVisibleChanged
                 * will NOT be called! So we get to do it ourselves.
                 * -flibit
                 */
                SDL.SDL_ShowCursor(0);
            }

            // OSX has some fancy fullscreen features, let's use them!
            if (OSVersion.Equals("Mac OS X"))
            {
                string hint = SDL.SDL_GetHint(SDL.SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES);
                INTERNAL_useFullscreenSpaces = (String.IsNullOrEmpty(hint) || hint.Equals("1"));
            }
            else
            {
                INTERNAL_useFullscreenSpaces = false;
            }

            // Create OpenGL context
            INTERNAL_GLContext = SDL.SDL_GL_CreateContext(Window.Handle);
            OpenTK.Graphics.GraphicsContext.CurrentContext = INTERNAL_GLContext;

#if THREADED_GL
            // Create a background context
            SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
            Threading.WindowInfo        = Window.Handle;
            Threading.BackgroundContext = new GL_ContextHandle()
            {
                context = SDL.SDL_GL_CreateContext(Window.Handle)
            };

            // Make the foreground context current.
            SDL.SDL_GL_MakeCurrent(Window.Handle, INTERNAL_GLContext);
#endif

            // Set up the OpenGL Device. Loads entry points.
            OpenGLDevice.Initialize();

            // Create the OpenAL device
            OpenALDevice.Initialize();

            // Initialize Active Key List
            keys = new List <Keys>();

            // Setup Text Input Control Character Arrays (Only 4 control keys supported at this time)
            INTERNAL_TextInputControlDown   = new bool[4];
            INTERNAL_TextInputControlRepeat = new int[4];

            // Assume we will have focus.
            IsActive = true;

            // Ready to run the loop!
            INTERNAL_runApplication = true;

#if WIIU_GAMEPAD
            wiiuStream = DRC.drc_new_streamer();
            if (wiiuStream == IntPtr.Zero)
            {
                System.Console.WriteLine("Failed to alloc GamePad stream!");
                return;
            }
            if (DRC.drc_start_streamer(wiiuStream) < 1)             // ???
            {
                System.Console.WriteLine("Failed to start GamePad stream!");
                DRC.drc_delete_streamer(wiiuStream);
                wiiuStream = IntPtr.Zero;
                return;
            }
            DRC.drc_enable_system_input_feeder(wiiuStream);
            wiiuPixelData = new byte[
                OpenGLDevice.Instance.Backbuffer.Width *
                OpenGLDevice.Instance.Backbuffer.Height *
                4
                            ];
#endif
        }
Beispiel #10
0
 public override void glUniform4fv(OpenGLDevice openGLDevice, int _location, float[] _buffer)
 {
     _glUniform4fv(openGLDevice, _location, _buffer);
 }
		public OpenGL20ScreenshotCapturer(Device device, Window window)
		{
			this.device = (OpenGLDevice)device;
			this.window = window;
		}
Beispiel #12
0
 public abstract void glUniform4fv(
     OpenGLDevice openGLDevice, int _location, float[] _buffer
     );
Beispiel #13
0
		protected OpenGL20Image(string contentName, OpenGLDevice device)
			: base(contentName)
		{
			this.device = device;
			CreateHandleAndSetDefaultSamplerState();
		}
Beispiel #14
0
		public OpenGLShader(ShaderCreationData data, OpenGLDevice device)
			: base(data)
		{
			this.device = device;
			TryCreateShader();
		}
Beispiel #15
0
		public OpenGLShader(ShaderWithFormatCreationData creationData, OpenGLDevice device)
			: this((ShaderCreationData)creationData, device) {}
Beispiel #16
0
 private static void Initialize()
 {
     device          = new OpenGLDevice(Window.window);
     Window.Resized += OnWindowResized;
 }
Beispiel #17
0
		private OpenGL20Image(ImageCreationData data, OpenGLDevice device)
			: base(data)
		{
			this.device = device;
			CreateHandleAndSetDefaultSamplerState();
		}