<commit_before>package rnd

import (
	"github.com/go-gl/gl"
	glfw "github.com/go-gl/glfw3"
	"github.com/tedsta/fission/core"
	"github.com/tedsta/gosfml"
)

const Ptu = 32.0

type RenderSystem struct {
	Window *glfw.Window
	Target *sf.RenderTarget
	View   *sf.View
}

func NewRenderSystem(sizeX, sizeY int, winTitle string) *RenderSystem {
	if !glfw.Init() {
		panic("Can't init glfw!")
	}
	gl.Init()

	w, err := glfw.CreateWindow(sizeX, sizeY, winTitle, nil, nil)
	if err != nil {
		panic(err)
	}
	w.MakeContextCurrent()

	rt := sf.NewRenderTarget(sf.Vector2{float32(sizeX), float32(sizeY)})
	view := rt.DefaultView()
	r := &RenderSystem{w, rt, &view}

	w.SetFramebufferSizeCallback(r.onResize)

	return r
}

func (r *RenderSystem) Begin(dt float32) {
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
	r.Target.SetView(*r.View)
}

func (r *RenderSystem) ProcessEntity(e *core.Entity, dt float32) {
	trans := e.Component(TransformComponentType).(*TransformComponent)

	rs := sf.RenderStates{sf.BlendAlpha, trans.T.Transform(), nil}

	renderCmpnts := e.Components(RenderComponentType)
	for _, cmpnt := range renderCmpnts {
		render := cmpnt.(*RenderComponent).Render
		if render != nil {
			render(r.Target, rs)
		}
	}
}

func (r *RenderSystem) End(dt float32) {
	r.Window.SwapBuffers()
}
<commit_msg>RenderSystem background color<commit_after>package rnd

import (
	"github.com/go-gl/gl"
	glfw "github.com/go-gl/glfw3"
	"github.com/tedsta/fission/core"
	"github.com/tedsta/gosfml"
)

const Ptu = 32.0

type RenderSystem struct {
	Window  *glfw.Window
	Target  *sf.RenderTarget
	View    *sf.View
	BgColor sf.Color // Background color
}

func NewRenderSystem(sizeX, sizeY int, winTitle string) *RenderSystem {
	if !glfw.Init() {
		panic("Can't init glfw!")
	}
	gl.Init()

	w, err := glfw.CreateWindow(sizeX, sizeY, winTitle, nil, nil)
	if err != nil {
		panic(err)
	}
	w.MakeContextCurrent()

	rt := sf.NewRenderTarget(sf.Vector2{float32(sizeX), float32(sizeY)})
	view := rt.DefaultView()
	r := &RenderSystem{w, rt, &view, sf.Color{0, 0, 0, 0}}

	w.SetFramebufferSizeCallback(r.onResize)

	return r
}

func (r *RenderSystem) Begin(dt float32) {
	r.Target.Clear(r.BgColor)
	r.Target.SetView(*r.View)
}

func (r *RenderSystem) ProcessEntity(e *core.Entity, dt float32) {
	trans := e.Component(TransformComponentType).(*TransformComponent)

	rs := sf.RenderStates{sf.BlendAlpha, trans.T.Transform(), nil}

	renderCmpnts := e.Components(RenderComponentType)
	for _, cmpnt := range renderCmpnts {
		render := cmpnt.(*RenderComponent).Render
		if render != nil {
			render(r.Target, rs)
		}
	}
}

func (r *RenderSystem) End(dt float32) {
	r.Window.SwapBuffers()
}

{'fraction_non_alphanumeric': 0.15005641218503196, 'fraction_numerical': 0.012786761940579166, 'mean_word_length': 4.4958677685950414, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4119081', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1033, 'n_words': 203}