Author Topic: [Bmax] Is there any native stencil buffer in Bmax's blitz2d?  (Read 3295 times)

0 Members and 1 Guest are viewing this topic.

Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1382
  • Karma: 83
    • View Profile

I really REALLY *REALLY* like the look of filled vectors.

[youtube]http://www.youtube.com/watch?v=37XY28YDju4[/youtube]

Is this possible using Bmax's normal graphics library?
Challenge Trophies Won:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
If I am correct then the stencil buffer is used when you want to avoid drawing something, otherwise someone please correct me :)

The stencil vector in that demo is done using a software render, and this is why its easy to do stencil vectors. What they have done is creating a poly texture fill rutine and a buffer the size of the screen (or alternatively having the texture pointers capped to the size of the texture) and then they feed the poly texture fill with different values depending on where on the screen its drawn. Adding shading values to darken/lighten the texture can enhance the effect. I have done this effect a couple of times using BlitzPlus and a software render.

If you are looking to do a similar effect, and do not want to write a complete software render in Blitzmax, then you might be able to do something similar, if you create a texture that is applied to all polygons, and then manipulate the texture UVs. The data is there in the image type somewhere. Someone at the blitzmax forum did their own textured polygon function and there is code showing how its manipulated.

I am not at my regular computer right now, but I could take a look for something later on though.

Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1382
  • Karma: 83
    • View Profile
Ah ok.

Yes that is indeed the effect I was looking to do. I wanted to do it with raster text however and was hoping for a good way to do this. I wanted to scroll a bitmap font across the screen and have the texture be where the font normally goes. I didn't know there is a function to draw texture based on texture cords in max2d. I'll have to look.
Challenge Trophies Won:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
There is no built-in function to do it, you would have to make your own, but if all you want is to have a texture/raster in a text, then how I have done it previously is to create a font, where the transparent part is the characters. Then draw the texture, draw the text on top of that, grab it to another image, and draw that where you scroller is to be shown.

The idea is shown in this mask test I just did: http://zac-interactive.dk/temp/masktest.zip

Offline JL235

  • C= 64
  • **
  • Posts: 71
  • Karma: 9
    • View Profile
    • Play My Code
I don't use BMax but I used to use B3D. Just a guess, could you not set the bitmasked colour to say bright pink, create a new image (lets call it stencil image) and fill it with the background colour. Then you draw bright pink polygon shapes to it.

You can then draw the texture and then the stencil image to the screen, in that order. The textures should show up as replacements for the bright pink shapes.
Play My Code - build games in your browser!