To be honest ive not had a problem drawing sprites and then using get image to get the backbuffer. Its always seemed to work ok so I cant really comment on the issues your having.
Quote: "Except that's not the case, as it seems AppGameKit either Automatically Clears the Screen at some point during the Swap( ) to the Clear Colour.
Although why this isn't forced as a Manual thing is weird. "
It is documented though....
https://www.appgamekit.com/documentation/Reference/Core/EnableClearColor.htm
AGK does clear the backbuffer automatically as standard in the swap() and sync() but you can disable it if you want to manually do it so you can keep the previous contents. There's an example that comes with agk that uses the technique of continually modifying the previous back buffer. Its the same with the depth buffer too as most people just want it to be cleared but you can disable it if wanted.
The command describes using a renderimage to continually control your own backbuffer or buffer chain that you can use. A render image might really be exactly what your after.
If you could provide code and an explanation of what your trying to acheive but that isnt working as expected then im sure people could actually help.
EDIT:
Im not sure what you were trying to achieve with your code above but ive edited it to make it work and at least display the correct pixel color. You were doing a number of things that were preventing you from getting correct values. Rather then actually list them all....I will just list the code.
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Physically Based Rendering - Bens Modified version" )
SetWindowSize( 1280, 720, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1280, 720 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 60, 0 ) // You want to save Mobile Battery, make a 2D Game :p
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
SetPrintSize( 20 ) // let's use a more REASONABLE size
#Constant KEY_ESCAPE 27
FluentInitialise() // Intialise UX
//SetClearColor( GetColorRed( 0xFFD47800 ), GetColorGreen( 0xFFD47800 ), GetColorBlue( 0xFFD47800 ) )
// Make the pixel colour box a sprite
ColBox = CreateSprite(0)
SetSpriteSize(ColBox,40,40)
SetSpritePosition(ColBox,620,340)
Global SpriteSet As Integer[6]
For Index = 0 To 6
SpriteSet[Index] = CreateSprite(0)
SetSpriteScale( SpriteSet[Index], 7.7, 62.0 )
Next
SetSpriteColor( SpriteSet[0], GetColorRed(FluentAccentColor.Light[1]), GetColorGreen(FluentAccentColor.Light[1]), GetColorBlue(FluentAccentColor.Light[1]), FluentColorAlpha(FluentAccentColor.Light[1]) )
SetSpriteColor( SpriteSet[1], GetColorRed(FluentAccentColor.Light[2]), GetColorGreen(FluentAccentColor.Light[2]), GetColorBlue(FluentAccentColor.Light[2]), FluentColorAlpha(FluentAccentColor.Light[2]) )
SetSpriteColor( SpriteSet[2], GetColorRed(FluentAccentColor.Light[3]), GetColorGreen(FluentAccentColor.Light[3]), GetColorBlue(FluentAccentColor.Light[3]), FluentColorAlpha(FluentAccentColor.Light[3]) )
SetSpriteColor( SpriteSet[3], GetColorRed(FluentAccentColor.Base), GetColorGreen(FluentAccentColor.Base), GetColorBlue(FluentAccentColor.Base), FluentColorAlpha(FluentAccentColor.Base) )
SetSpriteColor( SpriteSet[4], GetColorRed(FluentAccentColor.Dark[1]), GetColorGreen(FluentAccentColor.Dark[1]), GetColorBlue(FluentAccentColor.Dark[1]), FluentColorAlpha(FluentAccentColor.Dark[1]) )
SetSpriteColor( SpriteSet[5], GetColorRed(FluentAccentColor.Dark[2]), GetColorGreen(FluentAccentColor.Dark[2]), GetColorBlue(FluentAccentColor.Dark[2]), FluentColorAlpha(FluentAccentColor.Dark[2]) )
SetSpriteColor( SpriteSet[6], GetColorRed(FluentAccentColor.Dark[3]), GetColorGreen(FluentAccentColor.Dark[3]), GetColorBlue(FluentAccentColor.Dark[3]), FluentColorAlpha(FluentAccentColor.Dark[3]) )
SetClearColor( 255, 255, 255 )
// Create the light background (ive made them a sprite so they dont have to be manually drawn)
back1 = CreateSprite(0)
SetSpritePosition(back1,0,0)
SetSpriteSize(back1,GetVirtualWidth() / 2,GetVirtualHeight())
SetSpriteDepth(back1,1000)
SetSpriteColor(back1,0xE1,0xE1,0xE1,255)
//ColorA = FluentColorFromHex( 0xFFE1E1E1 )
//DrawBox( 0, 0, GetScreenBoundsRight() / 2, GetScreenBoundsBottom(), ColorA, ColorA, ColorA, ColorA, 1 )
// Create the black background (ive made them a sprite so they dont have to be manually drawn)
back2 = CreateSprite(0)
SetSpritePosition(back2,GetVirtualWidth() / 2,0)
SetSpriteSize(back2,GetVirtualWidth() / 2,GetVirtualHeight())
SetSpriteDepth(back2,1000)
SetSpriteColor(back2,0x00,0x00,0x00,255)
//ColorB = FluentColorFromHex( 0xFF000000 )
//DrawBox( GetScreenBoundsRight() / 2, 0, GetScreenBoundsRight(), GetScreenBoundsBottom(), ColorB, ColorB, ColorB, ColorB, 1 )
// global for color storage
global BensColour
Do
Print( "Accent Base: " + Str(FluentAccentColor.Base && 0xFF) + " , " + Str(FluentAccentColor.Base >> 8 && 0xFF) + " , " + Str(FluentAccentColor.Base >> 16 && 0xFF) + " , " + Str(FluentAccentColor.Base >> 24 && 0xFF) )
If GetPointerPressed()
bFlipTheme = Not bFlipTheme
EndIf
If bFlipTheme
For Index = 0 To 6
SetSpritePosition( SpriteSet[Index], 50.0 + (Index * 77), 50.0 )
Next
Else
For Index = 0 To 6
SetSpritePosition( SpriteSet[Index], 690.0 + (Index * 77), 50.0 )
Next
EndIf
// print out the colour at the mouse location
Print( "X,Y Color: " + Str(GetColorRed(BensColour)) + " , " + Str(GetColorGreen(BensColour)) + " , " + Str(GetColorBlue(BensColour)))
// Do the rendering
Render()
// This has to be called here after the sprites have been rendered by Render() above
BensColour = ColorGet(GetPointerX(),GetPointerY())
SetSpriteColor(ColBox,GetColorRed(BensColour),GetColorGReen(BensColour),GetColorBlue(BensColour),(BensColour>>24))
// Swap the backbuffer
Swap()
If GetRawKeyPressed(KEY_ESCAPE) Then Exit
Loop
// Fluent UX System
// Version 1.00
Type FluentAccentColor_Type
Base As Integer
Light As Integer[3]
Dark As Integer[3]
EndType
Global FluentAccentColor As FluentAccentColor_Type
Type FluentThemeCore_Type
Low As Integer // 20% Opacity
MediumLow As Integer // 40% Opacity
Medium As Integer // 60% Opacity
MediumHigh As Integer // 80% Opacity
High As Integer // 100% Opacity
EndType
Type FluentThemeAccent_Type
Low As Integer
Medium As Integer
AccentLow As Integer
AccentMedium As Integer
AccentHigh As Integer
EndType
Function FluentInitialise( )
FluentAccentColorSet( 0xFFD47800, FluentAccentColor ) // Default Windows 10 Base Accent
EndFunction
// Convert Standard Hex Colours to AGK Colour Format
Function FluentColorFromHex( HexColor As Integer )
Local Color As Integer
Color = FluentColor( (HexColor && 0xFF), (HexColor >> 8 && 0xFF), (HexColor >> 16 && 0xFF), (HexColor >> 24 && 0xFF) )
EndFunction Color
// This is useful for HTML Colours
Function FluentColorToHex( Color As Integer )
Local Red, Green, Blue, Alpha As Integer
Local HexColor As String
HexColor = "0x"
HexColor = Hex( Color >> 24 && 0xFF ) + Hex( Color && 0xFF ) + Hex( Color >> 8 && 0xFF ) + Hex( Color >> 16 && 0xFF )
EndFunction HexColor
// AGK Colour Format, I know "CreateColor" exists but it doesn't support Alpha Channel :\
// Remember Standard is ( Red, Green, Blue, Alpha ) ., AGK is ( Blue, Green, Red, Alpha )
Function FluentColor( Red As Integer, Green As Integer, Blue As Integer, Alpha As Integer )
Local Color As Integer
Color = (Blue || (Green << 8) || (Red << 16) || (Alpha << 24))
EndFunction Color
// R,G,B,A Component Returns ... again same as AGK GetColorRed/Green/Blue but added Alpha
Function FluentColorRed( Color As Integer )
EndFunction ( Color >> 16 && 0xFF )
Function FluentColorGreen( Color As Integer )
EndFunction ( Color >> 8 && 0xFF )
Function FluentColorBlue( Color As Integer )
EndFunction ( Color && 0xFF )
Function FluentColorAlpha( Color As Integer )
EndFunction ( Color >> 24 && 0xFF )
Function FluentAccentColorSet( Color As Integer, Palette Ref As FluentAccentColor_Type )
Local ImageCache As Integer
Local ClearColor As Integer
Palette.Light[0] = Color
Palette.Light[1] = FluentColor( FluentColorRed(Color), FluentColorGreen(Color), FluentColorBlue(Color), 0x66 )
Palette.Light[2] = FluentColor( FluentColorRed(Color), FluentColorGreen(Color), FluentColorBlue(Color), 0x99 )
Palette.Light[3] = FluentColor( FluentColorRed(Color), FluentColorGreen(Color), FluentColorBlue(Color), 0xB2 )
Palette.Dark[0] = Color
Palette.Dark[1] = FluentColor( FluentColorRed(Color), FluentColorGreen(Color), FluentColorBlue(Color), 0x99 )
Palette.Dark[2] = FluentColor( FluentColorRed(Color), FluentColorGreen(Color), FluentColorBlue(Color), 0xCC )
Palette.Dark[3] = FluentColor( FluentColorRed(Color), FluentColorGreen(Color), FluentColorBlue(Color), 0xE5 )
Palette.Base = Color
EndFunction
Function FluentColorGet( X As Float, Y As Float )
Local Color, Red, Green, Blue As Integer
Local BackBuffer, Pitch, ImageCache As Integer
BackBuffer = CreateRenderImage( GetVirtualWidth(), GetVirtualHeight(), 0, 0 )
Pitch = GetVirtualWidth() * 4
SetRenderToImage(BackBuffer, 0)
ClearScreen()
Render()
ImageCache = CreateMemblockFromImage(BackBuffer)
Address = (Y * Pitch) + (X * 4)
Blue = GetMemblockByte(ImageCache, Address + 0 )
Green = GetMemblockByte(ImageCache, Address + 1 )
Red = GetMemblockByte(ImageCache, Address + 2 )
SetRenderToScreen()
DeleteImage(BackBuffer)
DeleteMemblock(ImageCache)
Color = FluentColor( Red, Green, Blue, 0xFF )
EndFunction Color
// New Pixel get function that actually works properly
Function ColorGet( X As Float, Y As Float )
Local BackBuffer, ImageCache As Integer
Backbuffer = GetImage(x,y,1,1)
ImageCache = CreateMemblockFromImage(BackBuffer)
Col = GetMemblockInt(ImageCache,12)
DeleteImage(BackBuffer)
DeleteMemblock(ImageCache)
EndFunction Col
Lastly, just for reference...for some reason you have listed in you code that AppGameKit stores RGBA in an integer in some weird colour order
// AppGameKit Colour Format, I know "CreateColor" exists but it doesn't support Alpha Channel :\
// Remember Standard is ( Red, Green, Blue, Alpha ) ., AppGameKit is ( Blue, Green, Red, Alpha )
Thats not correct, AppGameKit stores as Red,Green,Blue,Alpha .. same as standard
bits 0-7 Red
bits 8-15 Green
bits 16-23 Blue
bits 24-31 Alpha
I havent bothered correcting that section of your code