texture filter and steam

Started by GrindalfGames, April 21, 2018, 19:51:59

Previous topic - Next topic

GrindalfGames

I'm using a dll(DX7DBF.dll) to disable the bilinear texture filter in my game but now I have just found out that the dll crashes when running through steam. Anyone know about this or have any ideas for a work around?

Kippykip

I remember years and years ago I got some DLL that allows me to pixelate stuff. Maybe you could try it.
To initialise it, after Graphics3D use
initPixelate(SystemProperty("Direct3D7"), SystemProperty("Direct3DDevice7"), SystemProperty("DirectDraw7"), SystemProperty("AppHWND"), SystemProperty("AppHINSTANCE"))
And when you want to enable/disable it, use
Global imageFilters = False
setPixelate(16,0,imageFilters + 1)

False being Nearest, while True is the default Bilinear

RemiD

#2
Quote
but now I have just found out that the dll crashes when running through steam
Can you give us more details ? (when this happens, and the error message)

Have you tried to run a very simple code to be sure that the crash come from the use of the functions of the dll and not some of your functions or others libraries ?

(btw, you have to make sure to copy paste the "fmod.dll" and the "DX7DBF.dll" in the same directory that your blitz3d executable is...)


One possible reason may be because this dll contains others functions which may activate / disactivate others DX functionalities that may conflict with what a steam library does. (this dll is a part of the ashadow library...)

A safer approach (that i plan to do, but not sure when) would be to hire a c/c++ coder to create a library which only allows to activate / disactivate bilinear filtering of textures in DirectX7... And only that...

GrindalfGames

thanks kippykip I will give that a try
@remiD It just mavs. removing the code that activates the dll and removing the dll means it then works but looks all blurry

col

#4
I'm not sure any of you guys are interested in building the source of Blitz3D or not ( using the VisualStudio 2017 build package, VS community is free) ?
But you can modify it and create a new flag for the texture filters command to have 1024 as a flag value for point sampling.

[EDIT]As to how this would affect being used with Steam I don't know. I know that Steam used to, and still probably does, set viewport flags but it never use to reset them. That caused an issue with BlitzMax when using the d3d9 driver.



To set up the texture filter flags with Blitz3D itself the required modifications would be

Project: gxruntime
File: gxcanvas.h
Line: 59

enum{
CANVAS_TEX_RGB= 0x0001,
CANVAS_TEX_ALPHA= 0x0002,
CANVAS_TEX_MASK= 0x0004,
CANVAS_TEX_MIPMAP= 0x0008,
CANVAS_TEX_CLAMPU= 0x0010,
CANVAS_TEX_CLAMPV= 0x0020,
CANVAS_TEX_SPHERE= 0x0040,
CANVAS_TEX_CUBE= 0x0080,
CANVAS_TEX_VIDMEM= 0x0100,
CANVAS_TEX_HICOLOR= 0x0200,
CANVAS_TEX_POINT= 0x0400,

CANVAS_TEXTURE= 0x10000,
CANVAS_NONDISPLAY= 0x20000,
CANVAS_HIGHCOLOR= 0x40000
};



Project: gxruntime
File: gxscene.cpp
Line: 142

//set addressing modes
setTSS( n,D3DTSS_ADDRESSU,(flags & gxCanvas::CANVAS_TEX_CLAMPU) ? D3DTADDRESS_CLAMP : D3DTADDRESS_WRAP );
setTSS( n,D3DTSS_ADDRESSV,(flags & gxCanvas::CANVAS_TEX_CLAMPV) ? D3DTADDRESS_CLAMP : D3DTADDRESS_WRAP );
setTSS( n,D3DTSS_MINFILTER, (flags & gxCanvas::CANVAS_TEX_POINT) ? D3DTFN_POINT : D3DTFN_LINEAR);
setTSS( n,D3DTSS_MAGFILTER, (flags & gxCanvas::CANVAS_TEX_POINT) ? D3DTFG_POINT : D3DTFG_LINEAR);
setTSS( n,D3DTSS_MIPFILTER, (flags & gxCanvas::CANVAS_TEX_POINT) ? D3DTFP_POINT : D3DTFP_LINEAR);




Then to update the docs

File: <Blitz3DSourceFolder>_release/help/commands/3d_commands/CreateTexture.htm

<html>
<head>
<title>Blitz3D Docs</title>
<link rel=stylesheet href=../css/commands.css type=text/css>
</head>
<body>
<h1>CreateTexture ( width,height[,flags][,frames] )</h1>
<h1>Parameters</h1>
<table>
<tr>
<td>
width - width of texture
<br />
height - height of texture
<br />
<br />
flags (optional) - texture flag:
<br />
1: Color (default)
<br />
2: Alpha
<br />
4: Masked
<br />
8: Mipmapped
<br />
16: Clamp U
<br />
32: Clamp V
<br />
64: Spherical environment map
<br />
128: Cubic environment map
<br />
256: Store texture in vram
<br />
512: Force the use of high color textures
<br />
1024: Use point sampling instead of linear sampling
<br />
<br />
frames (optional) - no of frames texture will have. Defaults to 1.
</td>
</tr>
</table>
<h1>Description</h1>
<table>
<tr>
<td>
Creates a texture and returns its handle.

<br />

<br />
Width and height are the size  of the texture. Note that the actual texture size may be different from the  width and height requested, as different types of 3D hardware support different  sizes of texture.

<br />

<br />
The optional flags parameter allows you to apply certain effects to the texture.  Flags can be added to combine two or more effects, e.g. 3 (1+2) = texture with  color and alpha maps.

<br />

<br />
Here some more detailed descriptions of the flags:

<br />

<br />
1: Color - colour map, what you see is what you get.

<br />

<br />
2: Alpha - alpha map. If an image contains an alpha map, this will be used to  make certain areas of the texture transparent. Otherwise, the colour map will  be used as an alpha map. With alpha maps, the dark areas always equal high-transparency,  light areas equal low-transparency.

<br />

<br />
4: Masked - all areas of a texture coloured 0,0,0 will not be drawn to the screen.

<br />

<br />
8: Mipmapped - low detail versions of the texture will be used at high distance.  Results in a smooth, blurred look.

<br />

<br />
16: Clamp u - Any part of a texture that lies outsides the U coordinates of 0-1 will not be drawn. Prevents texture-wrapping.

<br />

<br />
32: Clamp v - Any part of a texture that lies outsides the v coordinates of 0-1 will not be drawn. Prevents texture-wrapping.

<br />

<br />
64: Spherical environment map - a form of environment mapping. This works by taking a single image, and then applying it to a 3D mesh in such a way that the image appears to be reflected. When used with a texture that contains light sources, it can give some meshes such as a teapot a shiny appearance.

<br />

<br />
128: Cubic environment map - a form of environment mapping. Cube mapping is similar to spherical mapping, except it uses six images each representing a particular 'face' of an imaginary cube, to give the appearance of an image that perfectly reflects its surroundings.

<br />

<br />
When creating cubic environment maps with the CreateTexture command, cubemap textures *must* be square 'power of 2' sizes. See the <a class=small href=../3d_commands/SetCubeFace.htm>SetCubeFace</a> command for information on how to then draw to the cubemap.

<br />

<br />
When loading cubic environments maps into Blitz using LoadTexture, all six images relating to the six faces of the cube must be contained within the one texture, and be laid out in a horizontal strip in the following order - left, forward, right, backward, up, down. The images comprising the cubemap must all be power of two sizes.

<br />

<br />
Please note that not some older graphics cards do not support cubic mapping. In order to find out if a user's graphics card can support it, use <a class=small href=../3d_commands/GfxDriverCaps3D.htm>GfxDriverCaps3D</a> .

<br />

<br />
256: Store texture in vram. In some circumstances, this makes for much faster dynamic textures - ie. when using CopyRect between two textures. When drawing to cube maps in real-time, it is preferable to use this flag.

<br />

<br />
512: Force the use of high color textures in low bit depth graphics modes. This is useful for when you are in 16-bit color mode, and wish to create/load textures with the alpha flag - it should give better results.

<br />

<br />
1024: Use point texture sampling instead of linear texture sampling. Linear texture sampling is used to blend the adjacent pixels to create a smoothed looking texture. Using point sampling doesn't blend between adjacent pixels - this creates a blocky looking texture.

<br />

<br />
Once you have created a texture, use SetBuffer TextureBuffer to draw to it. However, to display 2D graphics on a texture, it is usually quicker to draw to an image and then copy it to the texturebuffer, and to display 3D graphics on a texture, your only option is to copy from the backbuffer to the texturebuffer.
<br>
<br>
See also: <a class=small href=LoadTexture.htm>LoadTexture</a>, <a class=small href=LoadAnimTexture.htm>LoadAnimTexture</a>.
</td>
</tr>
</table>
<h1><a href=../3d_examples/CreateTexture.bb>Example</a></h1>
<table>
<tr>
<td>
; CreateTexture Example
<br />
; ---------------------
<br />

<br />
Graphics3D 640,480
<br />
SetBuffer BackBuffer()
<br />

<br />
camera=CreateCamera()
<br />

<br />
light=CreateLight()
<br />
RotateEntity light,90,0,0
<br />

<br />
cube=CreateCube()
<br />
PositionEntity cube,0,0,5
<br />

<br />
; Create texture of size 256x256
<br />
tex=CreateTexture( 256,256 )
<br />

<br />
; Set buffer - texture buffer
<br />
SetBuffer TextureBuffer( tex )
<br />

<br />
; Clear texture buffer with background white color
<br />
ClsColor 255,255,255
<br />
Cls
<br />

<br />
; Draw text on texture
<br />
font=LoadFont( "arial",24 )
<br />
SetFont font
<br />
Color 0,0,0
<br />
Text 0,0,"This texture"
<br />
Text 0,40,"was created using" : Color 0,0,255
<br />
Text 0,80,"CreateTexture()" : Color 0,0,0
<br />
Text 0,120,"and drawn to using" : Color 0,0,255
<br />
Text 0,160,"SetBuffer TextureBuffer()"
<br />

<br />
; Texture cube with texture
<br />
EntityTexture cube,tex
<br />

<br />
; Set buffer - backbuffer
<br />
SetBuffer BackBuffer()
<br />

<br />
While Not KeyDown( 1 )
<br />

<br />
pitch#=0
<br />
yaw#=0
<br />
roll#=0
<br />

<br />
If KeyDown( 208 )=True Then pitch#=-1
<br />
If KeyDown( 200 )=True Then pitch#=1
<br />
If KeyDown( 203 )=True Then yaw#=-1
<br />
If KeyDown( 205 )=True Then yaw#=1
<br />
If KeyDown( 45 )=True Then roll#=-1
<br />
If KeyDown( 44 )=True Then roll#=1
<br />

<br />
TurnEntity cube,pitch#,yaw#,roll#
<br />

<br />
RenderWorld
<br />
Flip
<br />

<br />
Wend
<br />

<br />
End
</td>
</tr>
</table>
<br>
<a target=_top href=../index.htm>Index</a><br>
<br>
Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=CreateTexture&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
</html>



File: <Blitz3DSourceFolder>_release/help/commands/3d_commands/TextureFilter.htm

<html>
<head>
<title>Blitz3D Docs</title>
<link rel=stylesheet href=../css/commands.css type=text/css>
</head>
<body>
<h1>TextureFilter match_text$,flags</h1>
<h1>Parameters</h1>
<table>
<tr>
<td>
match_text$ - text that, if found in texture filename, will activate certain  filters
<br />
<br />
flags - filter texture flags:
<br />
1: Color
<br />
2: Alpha
<br />
4: Masked
<br />
8: Mipmapped
<br />
16: Clamp U
<br />
32: Clamp V
<br />
64: Spherical reflection map
<br />
128: <void>
<br />
256: Store texture in vram
<br />
512: Force the use of high color textures
<br />
1024: Use point sampling instead of linear sampling
</td>
</tr>
</table>
<h1>Description</h1>
<table>
<tr>
<td>
Adds a texture filter. Any textures loaded that contain the text specified  by match_text$ will have the provided flags added.

<br />

<br />
This is mostly of use when loading a mesh.

<br />

<br />
By default, the following texture filter is used:

<br />

<br />
TextureFilter "",1+8

<br />

<br />
This means that all loaded textures will have color and be mipmapped by default.
</td>
</tr>
</table>
<h1><a href=../3d_examples/TextureFilter.bb>Example</a></h1>
<table>
<tr>
<td>
; ClearTextureFilters and TextureFilter Example.
<br />
; ----------------------------------------------
<br />

<br />
Const tex_color = 1 ; Color texture
<br />
Const tex_alpha = 2 ; Alpha texture (Include alpha channel data)
<br />
Const tex_mask = 4 ; Masked texture (black is transparent)
<br />
Const tex_mipmap = 8 ; Create texture mipmaps
<br />
Const tex_clampu = 16 ; Restrict U texture coords from "bleeding over"
<br />
Const tex_clampv = 32 ; Restrict V texture coords from "bleeding over"
<br />
Const tex_envshpere = 64 ; Load texture as a spherical environment map
<br />
Const tex_vram = 256 ; Force texture graphics to vram
<br />
Const tex_highcolor = 512 ; Forces texture graphics to be 32-bits per pixel
<br />
Const tex_point     = 1024  ; Use point texture sampling instead of linear texture sampling
<br />

<br />
Graphics3D 640,480
<br />

<br />
; Removes any texture filters that might apply.
<br />

<br />
ClearTextureFilters
<br />

<br />
; Add an alpha texture to the list of
<br />
; texture filters to apply to files
<br />
; that have "_alpha" in their filenames.
<br />

<br />
TextureFilter "_alpha",tex_color + tex_alpha + tex_mipmap
<br />

<br />
; Set appropriate texture flags for loading
<br />
; suitable skybox textures from files named
<br />
; something with "_skybox".
<br />

<br />
TextureFilter "_skybox", tex_color + tex_mipmap + tex_clampu + tex_clampv
<br />

<br />
; Set the flags for loading a spherical refletction
<br />
; map to apply to all "_refmap" files.
<br />

<br />
TextureFilter "_refmap", tex_color + tex_mipmap + tex_envshpere
<br />

<br />
; Setup a texture filter to allow faster
<br />
; (and easier) pixel manipulation on all
<br />
; loaded "_fastblit" files.
<br />

<br />
TextureFilter "_fastblit", tex_color + tex_vram + tex_highcolor
<br />

<br />
; This is where you would normally load your special
<br />
; textures.
<br />

<br />
; The next bit resets the texture filters to their
<br />
; standard settings.
<br />

<br />
ClearTextureFilters
<br />
TextureFilter "", tex_color + tex_mipmap
<br />

<br />
End
</td>
</tr>
</table>
<br>
<a target=_top href=../index.htm>Index</a><br>
<br>
Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=TextureFilter&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
</html>



File: <Blitz3DSourceFolder>_release/help/commands/3d_commands/LoadTexture.htm

<html>
<head>
<title>Blitz3D Docs</title>
<link rel=stylesheet href=../css/commands.css type=text/css>
</head>
<body>
<h1>LoadTexture ( file$[,flags] )</h1>
<h1>Parameters</h1>
<table>
<tr>
<td>
file$ - filename of image file to be used as texture
<br />

<br />
flags (optional) - texture flag:
<br />
1: Color (default)
<br />
2: Alpha
<br />
4: Masked
<br />
8: Mipmapped
<br />
16: Clamp U
<br />
32: Clamp V
<br />
64: Spherical environment map
<br />
128: Cubic environment map
<br />
256: Store texture in vram
<br />
512: Force the use of high color textures
<br />
1024: Use point sampling instead of linear sampling
</td>
</tr>
</table>
<h1>Description</h1>
<table>
<tr>
<td>
Load a texture from an image file and returns the texture's handle.  Supported file formats include: BMP, PNG, TGA and JPG.  Only PNG and TGA support alpha.
<br />

<br />

<br />
The optional flags parameter allows you to apply certain effects to the texture. Flags can be added to combine two or more effects, e.g. 3 (1+2) = texture with colour and alpha maps.
<br />

<br />

<br />
See <a class=small href=../3d_commands/CreateTexture.htm>CreateTexture</a> for more detailed descriptions of the texture flags.
<br />

<br />

<br />
Something to consider when applying texture flags to loaded textures is that the texture may have already had certain flags applied to it via the <a class=small href=../3d_commands/TextureFilter.htm>TextureFilter</a> command. The default for the <a class=small href=../3d_commands/TextureFilter.htm>TextureFilter</a> command is 9 (1+8), which is a coloured, mipmapped texture. This cannot be overridden via the flags parameter of the LoadTexture command - if you wish for the filters to be removed you will need to use the <a class=small href=../3d_commands/ClearTextureFilters.htm>ClearTextureFilters</a> command, which must be done after setting the graphics mode (setting the graphics mode restores the default texture filters).
<br>
<br>
See also: <a class=small href=CreateTexture.htm>CreateTexture</a>, <a class=small href=LoadAnimTexture.htm>LoadAnimTexture</a>.
</td>
</tr>
</table>
<h1><a href=../3d_examples/LoadTexture.bb>Example</a></h1>
<table>
<tr>
<td>
; LoadTexture Example
<br />
; -------------------
<br />

<br />
Graphics3D 640,480
<br />
SetBuffer BackBuffer()
<br />

<br />
camera=CreateCamera()
<br />

<br />
light=CreateLight()
<br />
RotateEntity light,90,0,0
<br />

<br />
cube=CreateCube()
<br />
PositionEntity cube,0,0,5
<br />

<br />
; Load texture
<br />
tex=LoadTexture( "media/b3dlogo.jpg" )
<br />

<br />
; Texture cube with texture
<br />
EntityTexture cube,tex
<br />

<br />
While Not KeyDown( 1 )
<br />

<br />
pitch#=0
<br />
yaw#=0
<br />
roll#=0
<br />

<br />
If KeyDown( 208 )=True Then pitch#=-1
<br />
If KeyDown( 200 )=True Then pitch#=1
<br />
If KeyDown( 203 )=True Then yaw#=-1
<br />
If KeyDown( 205 )=True Then yaw#=1
<br />
If KeyDown( 45 )=True Then roll#=-1
<br />
If KeyDown( 44 )=True Then roll#=1
<br />

<br />
TurnEntity cube,pitch#,yaw#,roll#
<br />

<br />
RenderWorld
<br />
Flip
<br />

<br />
Wend
<br />

<br />
End
</td>
</tr>
</table>
<br>
<a target=_top href=../index.htm>Index</a><br>
<br>
Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=LoadTexture&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
</html>



File: <Blitz3DSourceFolder>_release/help/commands/3d_commands/LoadAnimTexture.htm

<html>
<head>
<title>Blitz3D Docs</title>
<link rel=stylesheet href=../css/commands.css type=text/css>
</head>
<body>
<h1>LoadAnimTexture ( file$,flags,frame_width,frame_height,first_frame,frame_count )</h1>
<h1>Parameters</h1>
<table>
<tr>
<td>
file$ - name of image file with animation frames laid out in left-right,  top-to-bottom order
<br />
<br />
flags (optional) - texture flag:
<br />
1: Color (default)
<br />
2: Alpha
<br />
4: Masked
<br />
8: Mipmapped
<br />
16: Clamp U
<br />
32: Clamp V
<br />
64: Spherical reflection map
<br />
128: Cubic environment map
<br />
256: Store texture in vram
<br />
512: Force the use of high color textures
<br />
1024: Use point sampling instead of linear sampling
<br />
<br />
frame_width - width of each animation frame
<br />
frame_height - height of each animation frame
<br />
first_frame - the first frame to be used as an animation frame
<br />
frame_count - the amount of frames to be used
</td>
</tr>
</table>
<h1>Description</h1>
<table>
<tr>
<td>
Loads an animated texture from an image file and returns the texture's handle.

<br />

<br />
The flags parameter allows you to apply certain effects to the texture. Flags  can be added to combine two or more effects, e.g. 3 (1+2) = texture with colour  and alpha maps.

<br />

<br />
See <a class=small href=../3d_commands/CreateTexture.htm>CreateTexture</a> for more detailed descriptions of the texture flags.

<br />

<br />
The frame_width, frame_height, first_frame and frame_count parameters determine how Blitz will separate the image file into individual animation frames.
<br>
<br>
See also: <a class=small href=CreateTexture.htm>CreateTexture</a>, <a class=small href=LoadTexture.htm>LoadTexture</a>.
</td>
</tr>
</table>
<h1><a href=../3d_examples/LoadAnimTexture.bb>Example</a></h1>
<table>
<tr>
<td>
; LoadAnimTexture Example
<br />
; -----------------------
<br />

<br />
Graphics3D 640,480
<br />
SetBuffer BackBuffer()
<br />

<br />
camera=CreateCamera()
<br />

<br />
light=CreateLight()
<br />
RotateEntity light,90,0,0
<br />

<br />
cube=CreateCube()
<br />
PositionEntity cube,0,0,5
<br />

<br />
; Load anim texture
<br />
anim_tex=LoadAnimTexture( "media/boomstrip.bmp",49,64,64,0,39 )
<br />

<br />
While Not KeyDown( 1 )
<br />

<br />
; Cycle through anim frame values. 100 represents delay, 39 represents no. of  anim frames
<br />
frame=MilliSecs()/100 Mod 39
<br />

<br />
; Texture cube with anim texture frame
<br />
EntityTexture cube,anim_tex,frame
<br />

<br />
pitch#=0
<br />
yaw#=0
<br />
roll#=0
<br />

<br />
If KeyDown( 208 )=True Then pitch#=-1
<br />
If KeyDown( 200 )=True Then pitch#=1
<br />
If KeyDown( 203 )=True Then yaw#=-1
<br />
If KeyDown( 205 )=True Then yaw#=1
<br />
If KeyDown( 45 )=True Then roll#=-1
<br />
If KeyDown( 44 )=True Then roll#=1
<br />

<br />
TurnEntity cube,pitch#,yaw#,roll#
<br />

<br />
RenderWorld
<br />
Flip
<br />

<br />
Wend
<br />

<br />
End
</td>
</tr>
</table>
<br>
<a target=_top href=../index.htm>Index</a><br>
<br>
Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=LoadAnimTexture&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
</html>
https://github.com/davecamp

"When you observe the world through social media, you lose your faith in it."

RemiD

@col>>
youtube.com/watch?v=iZtbASCE7ZY&t=9s  :)