Difference between surface and texture (SDL / general)

Basically your assumption “has to do something with GPU?” is right. SDL_Surface is used in software rendering. With software rendering, as saloomi2012 correctly noticed, you are using regular RAM to store image data. Thus, in most cases you can access data buffer associated with surface directly, modifying its content, i.e. it is using CPU, hence … Read more

Layering graphical interfaces on top of each other

main.py import tkinter as tk import Mod1 import Mod2 root = tk.Tk() m1 = Mod1.Model(root) m2 = Mod2.Model(root) m1.grid(column= 0, row=0) m2.grid(column = 0 ,row=0) def callback(): m1.lift() b = tk.Button(text=”click me”, command=callback) b.grid(column=0,row=1) Mod1.py from __main__ import tk class Model(tk.Frame): def __init__(self, master): tk.Frame.__init__(self, master) self.master = master self.configure(bg=”red”, width=300, height=300) Mod2.py from __main__ … Read more

How to compute the correct width of a digit in pixels?

Small adjustments are required to make this work as intended: TextRenderingHint.ClearTypeGridFit gives a better result when rendering the Text. It’s more precise and works well with the grid-fitting nature of Graphics.DrawString. See the notes you can find in the answer linked below for more informations on this matter. StringFormat alignment in both horizontal and vertical … Read more

Animating dashed-line with java.awt.BasicStroke

Use a dashed line, a Thread (or a Swing Timer) & combine them with repaint() and some tweaking of where the dashes start and end – and there you have it. Example package test; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Shape; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import … Read more

Edges on polygon outlines not always correct

Requires Eigen as written, but the core operations should map easily to whatever vector class you’re using. // v0 and v1 are normalized // t can vary between 0 and 1 // http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/ Vector2f slerp2d( const Vector2f& v0, const Vector2f& v1, float t ) { float dot = v0.dot(v1); if( dot < -1.0f ) dot … Read more