Max2D Request List

BlitzMax Forums/BlitzMax Module Tweaks/Max2D Request List

Fetze(Posted 2006) [#1]
Hi there

I think, we should post all our Max2D-Related Requests in one topic to avoid opening thousands of threads. here are my own requests and requests of other BMax-users, collected in this thread:

1. Imagebuffers / "Render2Texture" (<-- an official one!). Also with Copy2Texture from Backbuffer or another Texture.
2. DrawTexturedPoly including Vertexcolor, Vertexalpha and - if there is something like this - Vertexblending. Also, I want an official one here.
3. Automatic splitting of Images with sizes above What-the-Gfx-Card-can-handle into smaller fragments which I can still handle as one Image.
4. RotateViewport, ScaleViewport. Just turn or zoom the camera.
5. More blend modes - we have add and multiply, what about subtract, inverse, etc
6. Proper filled/unfilled primitives - rectangles, triangles, circles, ovals, polygons (should have been in right from the start!)
7. Flood fill.
8. Color conversion - RGB - HSV.
9. Draw with logical operations - and/or/xor/not etc.
10. Shaders.
11. Realtime polygon antialiased font - with texturing, hollow or filled flat.
12. Extended and more customizeable DrawPoly-Command: We need Vertexcolor and VertexAlpha!
13. Get the maximum texture size.
14. Get the amount of video memory available in the system.
15. Get the amount of video memory used by Max.
16. Get a lock on the backbuffer so you can write directly to it.
17. Line style - dotted/patterned/textured lines.
18. CopyRect from one area of the backbuffer to another.
19. Loading of images that loads into a hidden pixmap and uploads to the gfx card then deletes the hidden pixmap.
20. Lighting.
21. Proper use of single texture to store multiple sub-textures (sub images).
22. DX9 driver for Max2D
23. Ability to define pixel dataformat of backbuffer. Would be nice to render floating point pixels for HDR.
24. Ability to read out pixels directly from backbuffer
25. Commands for saving the backbuffer or parts of the backbuffer to a file (bmp|png|jpeg|gif|...or whatever)

The reason, why I want official commands / support for this is, that I can be sure, that official things will work ever. I don't have to bother keeping all modules up to date or fixing new incompatibilities. Also, official Modules are always compatible with both Mac, Linux and Windows and both OpenGL and DirectX.
So, please don't just link to any User-made-modules. I know, there are some. I want it in Max2D.


ImaginaryHuman(Posted 2006) [#2]
1. More blend modes - we have add and multiply, what about subtract, inverse, etc
2. Proper filled/unfilled primitives - rectangles, triangles, circles, ovals, polygons (should have been in right from the start!)
3. Draw Image with perspective (like Deluxe Paint functionality, or to make parallax floors/ceilings.)
4. Flood fill.
5. Color conversion - RGB - HSV.
6. `Point` command to read a pixel or pixels from the backbuffer.
7. Extension of DrawImage with different vertex colors and alpha for each corner.
8. DrawImage as an irregular polygon (i guess same as a textured poly.)
9. Draw with logical operations - and/or/xor/not etc.
10. Some way of handling vertex arrays etc for speed.
11. Shaders.
12. Textured mesh.
13. Realtime polygon antialiased font - with texturing, hollow or filled flat.
14. Gradients (even just setting vertex colors with interpolation would be useful).
15. Particle engine.
16. Get the maximum texture size.
17. Get the amount of video memory available in the system.
18. Get the amount of video memory used by Max.
19. Get a lock on the backbuffer so you can write directly to it.
20. A snap-to-grid system.
21. Line style - dotted/patterned/textured lines.
22. Textured lines as in glow lines with curved corners.
23. A tile system automatically handle spooling of tiles from memory and drawing a tilemap.
24. CopyRect from one area of the backbuffer to another.
25. CopyToTexture to copy from backbuffer to texture.
26. RenderToTexture to draw directly onto a texture.
27. Way of rendering lots of pixels/particles at once using arrays.
28. SavePixmapJPEG.
29. Loading of images that loads into a hidden pixmap and uploads to the gfx card then deletes the hidden pixmap.
30. Saving of images that spools sections of the backbuffer to a small buffer and writes it to disk.
31. Lighting.
32. Bumpmapping - reflections and refractions.
33. Proper use of single texture to store multiple sub-textures (sub images).


Curtastic(Posted 2006) [#3]
I agree, someone needs to be hired to add all this stuff, and make it official, and bug free, and always up to date, while Mark works on the compiler.


Fetze(Posted 2006) [#4]
I'll add your Points to my first post, but not all of them. Here's why:


>> 3. Draw Image with perspective (like Deluxe Paint functionality, or to make parallax floors/ceilings.)

You don't need this if you've got DrawTexturedPoly which I already requested.


>> 6. `Point` command to read a pixel or pixels from the backbuffer.

I'm not quite sure, but I think, you can grab a 1x1 Pixmap and read out the Pixel from there without a big speed-loss... well, Reading from the backbuffer is always a speed-loss in BlitzMax..


>> 7. Extension of DrawImage with different vertex colors and alpha for each corner.

DrawTexturedPoly!


>> 8. DrawImage as an irregular polygon (i guess same as a textured poly.)

Yep. DrawTexturedPoly.


>> 11. Shaders.
>> 12. Textured mesh.

These two are Max3D, I think. But Shaders in 2D would be cool and also useful.


>> 14. Gradients (even just setting vertex colors with interpolation would be useful).

I interpret this as "More customizeable DrawPoly".


>> 15. Particle engine.

I don't agree with that. A particle-Engine is something you should write yourself, because it needs to be customized for your game / your engine. Also, you can customize it for your own needs.


>> 19. Get a lock on the backbuffer so you can write directly to it.

I don't understand that, but I'll add it anyway *g*


>> 20. A snap-to-grid system.

Can't be too hard to code yourself. Also, almost not anybody needs it.


>> 22. Textured lines as in glow lines with curved corners.

Well, that's DrawTexturedPoly ^^


>> 23. A tile system automatically handle spooling of tiles from memory and drawing a tilemap.

I'm not sure what excactly you mean, but it sounds like something which is better if you code it yourself.


>> 24. CopyRect from one area of the backbuffer to another.
>> 25. CopyToTexture to copy from backbuffer to texture.

I'll add these two to Render2Texture.


>> 26. RenderToTexture to draw directly onto a texture.

Already got that.


>> 27. Way of rendering lots of pixels/particles at once using arrays.

"DoItYourself" rulez ;)


>> 30. Saving of images that spools sections of the backbuffer to a small buffer and writes it to disk.

Again, I think you can do this with existing commands.


>> 32. Bumpmapping - reflections and refractions.

Shaders.


Dreamora(Posted 2006) [#5]
I only have 2 requests:

Renderbuffers again (until then, thank you indie for your contribution)

Much more important: DX9 driver


TartanTangerine (was Indiepath)(Posted 2006) [#6]
I have most of these things already and I must add that if you don't want to use my modules or wait in vain for BRL to add something that's already available then I suggest you write your own.


ImaginaryHuman(Posted 2006) [#7]
Fetze,

3. You do need it to be in perspective though, unless you are saying that DrawTexturedPoly will accept a Z coordinate for each point.

6. Yes you can already do it with direct GL calls etc, but for beginners etc there should be a user friendly way to read backbuffer content.

15. There should be at least basic support for some kind of particles so you can create like fireworks and such, e.g. DrawParticles, GrabParticles, MoveParticles, etc.

19. Like LockImage, except it doesn't download the image to a pixmap ... you need to `lock` the backbuffer so that the o/s knows not to change the location of it in memory until you unlock it, so that you can be sure of where you are writing to. Then you can draw directly to the buffer, which for some things would be faster than using GL/DX.

22. It's a little more complex than just drawing textured poly's.

23. It should be there for beginners.

27. Of course DIY rules, but Max2D is aimed at beginners or people who don't want to get low level.

30. But not automatically.

32. Yah. :-)

I also would like to add the ability to define what format of pixel data the backbuffer is. Normally it is rgba8 or rgb5, but it'd be nice to be able to render floating point pixels for HDR.


Fetze(Posted 2006) [#8]
@AngelDaniel

3. I thought of calculating the perspective yourself, but with Z-coordinates it would work too.

6. Okay, I'll add it to the "Mainlist" above.

15. Well... I think, for a Beginner it would be more helpful to have a nice tutorial. Particles are really not that hard and also something which is fun (personal opinion ^^).

19. Ahh.. thanks :)

22. Actually, it's just one polygon, eight vertices, UV-Coordinates like this:
[0.0|0.0] [0.5|0.0] [0.5|0.0] [1.0|0.0]
[0.0|1.0] [0.5|1.0] [0.5|1.0] [1.0|1.0]
Then, you texture it with a matching Image and you have your textured-lines-with-rounded-edges ^^

23. Yeah, but... come on, a tilemap! Everybody can do a tilemap.

27. I think, the following code will do (I'm not the author. Just debugged a very very little and extended by around 2 lines):
Rem
ObjectList created by Kris Kelly (Perturbatio) Dec 2005
purpose: faster access to a list of objects with less mem usage
it's performance is comparable to a TList when using a small number of strings
but when you are using a large amount, it is much better (and uses less memory).

When invoking the create method, you can specify the StepSize, this is the amount that
the Items Array will be increased by each time it is in danger of running out of space.
It is faster to do it in large blocks than in hundreds of little ones.

Modified and debugged by Fetze March 2006
End Rem

Type TListArray
	Field Items:Object[]
	Field _Size:Int = 0 'DO NOT MANUALLY MODIFY THIS!!!
	Field StepSize:Int
	
	Method Copy:TListArray()
		Local larrTemp:TListArray = TListArray.Create(StepSize)
		larrTemp.Items = Items[..]
		larrTemp._Size = _Size
		Return larrTemp
	End Method
	
	Method AddFirst(val:Object, bSpeed:Byte = False)
		Local i:Int

		'grow Items array by 1
		'Items = Items[..Items.Length + 1]
		_Size:+1
		'resize in bulk
		If Items.Length < _Size Then Items = Items[.._Size+StepSize]
		
		If bSpeed = True Then
			'move first item
			Items[_Size - 1] = Items[0]
		Else
			'shift Items to the rightt, overwriting val
			For i = 1 To _Size-1 'Items.Length - 1
				Items[i] = Items[i - 1]
			Next
		End If
		
		Items[0] = val
		'no need to return anything here since we know it was added at 0
	End Method
	
	
	Method AddLast:Int(val:Object)
		'grow Items array by 1
		'Items = Items[..Items.Length + 1]
		_Size:+1
		'resize in bulk
		If Items.Length < _Size Then Items = Items[.._Size+StepSize]
		
		'set the last index to val
		Items[_Size-1] = val
		
		Return _Size - 1'return the index it was added at
	End Method
	
	
	'return the entire list as a concatenated string with optional delimiter
	'because base objects have ToString, cannot override with different parameters
	Method ToDelimString:String(Delim:String = "")
		Local result:String
		Local i:Int
		
		For i = 0 To _Size-2
			result:+Items[i].ToString() + Delim
		Next
		result:+ Items[_Size-1].ToString()
		
		Return result
	End Method
	
	
	Method ToString:String()
		Return ToDelimString() 'just call ToDelimString with no parameters
	End Method
	
	'You could just reference the field _Size (which is what is done throughout the code), 
	'but that could result in an unsafe type if you 
	Method Count:Int()
		Return _Size
	End Method
	
	
	'return the first index where the list contains val, else return -1
	Method Contains:Int(val:Object)
		Local i:Int
		
		For i = 0 To _Size-1
			If val = Items[i] Then Return i		
		Next
		
		Return -1
	End Method
	
	
	Function FromArray:TListArray(val:Object[])
		Local tempList:TListArray = TListArray.Create()
		
		Try
			tempList.Items = val
			tempList._Size = val.length
		Catch err:String
			RuntimeError("Error when converting from Object Array to TListArray, error: ~n"+err$)
			Return Null
		End Try
		
		Return tempList
	End Function
	
Rem	
	Function FromString:TListArray(val:String, Delim:String)
		Local tempList:TListArray = TListArray.Create()
		Local currentChar : String = ""
		Local count : Int = 0
		Local TokenStart : Int = 0
			If Delim.Length <0 Or Delim.Length > 1 Then Return Null
	
			If Len(Delim)<>1 Then Return Null
	
			val = Trim(val)
	
			For count = 0 Until Len(val)
				If val[count..count+1] = delim Then
					tempList.AddLast(val[TokenStart..Count])
					TokenStart = count + 1
				End If
			Next
			tempList.AddLast(val[TokenStart..Count])	
			
		Return tempList
	End Function
EndRem

	'if AutoAddToEnd is true then if the index specified is greater than size, use AddLast
	Method Insert:Int(val:Object, index:Int, AutoAddToEnd:Int = False, bSpeed:Byte = False)
		Local i:Int
		
		'If index is out of range, Return False
		If index < 0 Then Return False
		If index > _Size Then
			If Not AutoAddToEnd Then 
				Return False
			Else
				AddLast(val)
				Return True
			EndIf
		EndIf
		
		'if the index is equal to Size then addlast
		If index = _Size Then 
			AddLast(val)
			Return True
		EndIf

		'resize Items
		'Items = Items[..Items.Length]
		_Size:+1
		'resize in bulk
		If Items.Length < _Size Then Items = Items[.._Size + StepSize]

		If bSpeed = True Then
			'move item
			Items[_Size - 1] = Items[index]
		Else
			'shift Items to the right from index
			For i = _Size-1 To index+1 Step -1
				Items[i] = Items[i - 1]
			Next
		End If
		
		'then insert val
		Items[index] = val
		Return True
	End Method
	
	
	Method RemoveByIndex:Int(index:Int, bSpeed:Byte = False)
		If index > (_Size - 1) Then Return False
		If index < 0 Then Return False
		If _Size > 0 Then
			If bSpeed = True Then
				'overwrite
				Items[index] = Items[_Size - 1]
			Else
				'shift Items to the left, overwriting index
				Local i:Int
				For i = index To _Size - 2
					Items[i] = Items[i + 1]
				Next
			End If
			
			'shrink Items by 1
			_Size:-1
			If _Size < 0 Then _Size = 0
			'null the end one
			Items[_Size] = Null
			'if the length of items is at least (2 *StepSize) larger than Size, resize the array
			'this should help prevent the size from getting out of control but keep it reasonably fast
			If _Size < Items.Length - (StepSize * 2) Then Items = Items[.._Size]
		Else
			_Size = 0
			Items[_Size] = Null
		End If
	End Method
	
	
	Method RemoveByObject:Int(val:Object, RemoveAll:Int = False, bSpeed:Byte = False)
		Local i:Int

		i = Contains(val)
		While i > -1
			
			RemoveByIndex(i, bSpeed)
			If Not RemoveAll Then Exit
			i = Contains(val)

		Wend
		
		Return True
	End Method
	
	
	Method Clear()
		Items = Items[..0]
		_Size = 0
	End Method

	
	Method ToArray:Object[]()
		Return Items[.._Size]
	End Method
	
	
	Method AddToList(List:TList Var)
		For Local s:Object = EachIn items
			List.AddLast(s)
		Next
	End Method
	
	Method ToList:TList()
		Local listTemp:TList = New TList
		AddToList(listTemp)
		Return listTemp
	End Method
	
	
	Method GetStepSize:Int()
		Return StepSize
	End Method
	
	Method SetStepSize(val:Int)
		If val < 1 Then val = 1 'don't allow negative values
		StepSize = val
	End Method
	
	
	Method Sort(bAscending:Byte = True)
		Local iOldSize:Int
		iOldSize = Items.length
		Items = Items[.._Size]
		Items.Sort(bAscending)
		Items = Items[..iOldSize]
	End Method
	
	
	Method Free()
		TListArray.Destroy(Self)
	End Method

	'returns true if swap occurred	
	Method SwapByIndex:Int(FirstIndex:Int, SecondIndex:Int)
		If FirstIndex<0 Or FirstIndex > _Size-1 Or SecondIndex<0 Or SecondIndex > _Size-1 Then Return False 'if out of bounds then return false
		Local tempObject:Object
		
		tempObject = items[FirstIndex]
		items[FirstIndex] = items[SecondIndex]
		items[SecondIndex] = tempObject
		Return True
		
	End Method
	
	'returns true if swap occurred	
	Method SwapByVal:Int(FirstObject:Object, SecondObject:Object)
		If FirstObject = Null Or SecondObject=Null Then Return False
		Local tempObject:Object
		Local FirstIndex:Int, SecondIndex:Int
		
		FirstIndex = Contains(FirstObject)
		SecondIndex = Contains(SecondObject)
		
		If FirstIndex > -1 And SecondIndex > -1 Then
			tempObject = items[FirstIndex]
			items[FirstIndex] = items[SecondIndex]
			items[SecondIndex] = tempObject
			Return True
		EndIf
		
		Return False
	End Method

	
	Function Destroy(List:TListArray)
		List.Clear()
		List = Null
		GCCollect
	End Function
	
	
	Function Create:TListArray(StepSize:Int = 10)
		Local tempList:TListArray = New TListArray
		tempList.StepSize = StepSize
		Return tempList
	End Function
End Type


I think, it or something like that should be added as standard.


30. That's right. I'll add it.


taxlerendiosk(Posted 2006) [#9]
19. SavePixmapJPEG.

...already in there, isn't it?


kfprimm(Posted 2006) [#10]
yep


ImaginaryHuman(Posted 2006) [#11]
It is? Cool.


Grey Alien(Posted 2006) [#12]
I started a large requests thread that got lots of posts in the old Beta/Upgrades thread that got wiped out. Nice.


Fetze(Posted 2006) [#13]
>> 19. SavePixmapJPEG.

Removed. Thanks for the hint.