47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
using SDL2;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Xml.Linq;
|
|
using testdrid.SdlWrapper;
|
|
|
|
namespace SDL2Demo.Screenhacks
|
|
{
|
|
[ScreenHackId(1)]
|
|
internal class PixelTest : ScreenHack
|
|
{
|
|
private Texture _texture;
|
|
private byte[] buffer;
|
|
|
|
protected override void Setup()
|
|
{
|
|
_texture = Texture.Create(renderer, SDL.SDL_TextureAccess.SDL_TEXTUREACCESS_STREAMING, windowRectangle.Width, windowRectangle.Height);
|
|
_texture.SetDrawBlendMode(SDL.SDL_BlendMode.SDL_BLENDMODE_BLEND);
|
|
buffer = new byte[3];
|
|
}
|
|
|
|
public override void MousePressed()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public override void Dispose()
|
|
{
|
|
_texture.Dispose();
|
|
}
|
|
|
|
public override void Render()
|
|
{
|
|
int x = rng.Next(windowRectangle.Width);
|
|
int y = rng.Next(windowRectangle.Height);
|
|
rng.NextBytes(buffer);
|
|
_texture.Lock();
|
|
_texture.SetPixel(x, y, 255, buffer[0], buffer[1], buffer[2]);
|
|
_texture.Unlock();
|
|
renderer.Copy(_texture, topLeft);
|
|
}
|
|
}
|
|
}
|