bitMap screen rendering

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
skagonTheIdiot
Prole
Posts: 1
Joined: Tue Sep 13, 2022 12:51 am

bitMap screen rendering

Post by skagonTheIdiot »

i am working on a 3d rendering engine and ive come up on a problem that i cant figure out. i want to use a bitmap rendering system from a table, i would have a table or a variable that i can give a x and y of a pixle on the screen and i can tell it which colour i would like it to be, i cant find an efficient way of doing this and rendering it without dropping fps from 60 down to 3. is there anyway i can make it more efficient? there is no code since it is just a table and a for loop but i know its not the drawing of the pixles that is the issue since i ran it without rendering anything, just running the for loop and assigning the colours not rendering any pixles, and its still near 6 fps. i plan on having an entire screen filled so using a second table filled with the only pixles to render wouldnt work very well but im open to anything. ive looked everywhere on google but the only possible solutions are downloadable addons and scripts that i dont want (its a single script engine that im doing as a challange), but if you can point me in any speudo bitmap script addons that i can try and understand and copy that would be fine aswell.
User avatar
ReFreezed
Party member
Posts: 612
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: bitMap screen rendering

Post by ReFreezed »

Do you mean you want to generate an image programmatically, as opposed to creating it in a drawing program? Generate the image once at load time using love.image.newImageData and ImageData:mapPixel or ImageData:setPixel, followed by love.graphics.newImage.

Code: Select all

function love.load()
	local imageData = love.image.newImageData(100, 100)

	imageData:mapPixel(function(x,y, r,g,b,a)
		r = math.random() -- You could get the color from some table. Here we just generate random noise.
		g = math.random()
		b = math.random()
		a = 1
		return r, g, b, a
	end)

	image = love.graphics.newImage(imageData)
end

function love.draw()
	love.graphics.draw(image)
end
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
User avatar
pgimeno
Party member
Posts: 3550
Joined: Sun Oct 18, 2015 2:58 pm

Re: bitMap screen rendering

Post by pgimeno »

It appears that you're doing this every frame. If that's the case, it's unlikely you will get the performance you want, but anyway, rather than using love.graphics.newImage, use Image:replacePixels.

Also, depending on what you're trying to do, it might be better to use a shader rather than drawing the pixels on the Lua side.

Edit: Oops, I missed the part of the 3D rendering engine. You're better off using OpenGL 3D no doubt; it's designed to be fast.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 208 guests