go-sdl2 icon indicating copy to clipboard operation
go-sdl2 copied to clipboard

Can SDL_SetTextureScaleMode be used somehow?

Open code-qote opened this issue 2 years ago • 3 comments

Hello. I had updated package by go get, so it had v0.4.35. There was no implementation of SDL_SetTextureScaleMode. I checked the several latest commits in master and found its implementation there. I edited my go.mod and installed the latest commit but now the application freezes while Renderer.Copy(). What have I done wrong?

I need it to solve the problem with blurry font (macOS). According to that, it should help. Maybe there is an another option?

code-qote avatar Jun 21 '23 09:06 code-qote

Hi @code-qote, could you show a minimal example of the code that makes the application freeze?

veeableful avatar Jun 21 '23 12:06 veeableful

At application starting, I render all supported chars and save it in PreRenderredCharTextures. Like this:

for _, char := range supportedChars {
	for _, color := range Colors {
		fontSurface, _ := e.font.ttfFont.RenderGlyphBlended(char, hexToSdlColor(color))
		texture, _ := e.renderer.CreateTextureFromSurface(fontSurface)
		// texture.SetScaleMode(sdl.ScaleModeLinear)
		cache.PreRenderredCharTextures[char][color] = CharTexture{texture, fontSurface.W}
	}
}

Then every frame I do (freezes here):

e.renderer.Copy(e.cache.PreRenderredCharTextures[rune(c)][Colors[t]].Texture, nil, e.GetRectFromMatrix(row, col))

code-qote avatar Jun 21 '23 13:06 code-qote

Hi @code-qote, would you be able to provide a minimal example that I can run? I can't seem to reproduce it.

veeableful avatar Jun 22 '23 04:06 veeableful