Texture Batching | Coding a 2D Game Engine in Java #13

preview_player
Показать описание

In this tutorial, I go over how to add texture batching to our current batched renderer. This allows us to bind up to 16 different textures per draw call, which means that you can batch together a lot more quads with different textures for each quad. This is important, because in 2D games, you typically have a variety of assets coming from multiple files, and if you do not want a mega-spritesheet, then you need to enable multiple textures for your batched renderer.

---------------------------------------------------------------------

Here are some books I recommend if you want to learn about game engine development more thoroughly. I do not profit off any of these sales, these are just some books that have helped me out :)

My Recommended Game Engine Books:

My Recommended Beginning Game Programming Books:

My Recommended Java Books:

Рекомендации по теме
Комментарии
Автор

It makes me sad to see how much the viewer count decreases with each episode :| Great work.. every single video

shurablack
Автор

Hey Gabe, thanks for the great content. Just wanted to say that the problem with the Time class was because the timeStarted variable was declared as a float and System.nanoTime() returns a long so there was probably some loss of precision. If you change timeStarted to be a long everything should work fine.

vedrankovacevic
Автор

Loving these tutorials, thankyou for uploading them

Shadowblitz
Автор

31:38 might as well make our whole texture images upside-down xD

lastyhopper
Автор

Hi gabe, -i was following your beautiful tutorial on macos for a school project. Unfortunately it doesn't render anything... It's just a lonely black screen. Do you have any idea of what I can do to solve this problem?

giovanniprete
Автор

Hi Gabe I'm doing your whole tutorial right now but i'm kind of stuck atm.

i get this following message when I try to compile at the end:"0:15(27): error: sampler arrays indexed with non-constant expressions are forbidden in GLSL 1.30 and later"
If i change the integer id in the default.glsl file to a number for example 3 then the program runs but when i put in id, like you did i get the error. Do you have an idea what i should do? I saw online that people were able to get rid of the bug by updating to a newer OpenGL version, but that surely can't be the reason why it workes for you but not for me.

Best regards Henri

henribebo
Автор

I have a strange bug where I get solid color bars instead of my image. It looks like I only have like 4 points of color. I'm not sure what I'm doing wrong

aVana
Автор

Hi Gabe, loving this series of tutorials, thank you for making such helpful videos!
I've always managed to fix any bugs or errors so far, but now I really feel like I'm stumped: right around the 27:05 timestamp, when you fix the black screen and get to see the colored rectangle again, something goes horribly wrong on my pc and I can't seem to understand why.
Basically I can see the background just fine, and the rectangle is there as well, but most of it is black with the exception of smaller rectangles on the "top row", which seem to be colored just the way they should be (as if the rectangle was actually colored but most of it was then covered with black).
I checked the code on your github and it seems to be the same I have, I even rewatched this video up to this point to make sure I didn't miss anything... do you have any idea as to why this could be happening?

Edit: I've noticed that it has something to do with the Max_Batch_Size, the bigger it is the larger the portion of the rectangle that gets covered in black (for example, if I use values 1 to 5 there's no black and it renders just the way it should).
Also, if I modify the color vector of each sprite to have the blue value (the third parameter) to be 0 this issue disappears

stefanoarcaro
Автор

I get the exact same thing as you! Except... mine has black upside-down right-pointing triangles all over it

mwbgeometrydashpcaccount
Автор

You can do GL45.glBindTextureSlot(texSlot, textureID); instead of activating the slot and then binding the texture. It's just nicer in my opinion

voxelrifts
Автор

To avoid using the function. its work for me. I use these UV coordinates:

Vector2f[] textureCord = {
new Vector2f(1, 0),
new Vector2f(1, 1),
new Vector2f(0, 1),
new Vector2f(0, 0)
};

maxfreeza
Автор

Hello! I am from the future hopefully you will still see this. We pretty much have the same code but I keep getting a NullPointException error pointing to the loadVertexProperties method more specifically vertices[offset + 6] = texCords[i].x;
vertices[offset + 7] = texCords[i].y;
It's saying that is cannot load from object array because "texCords" is null. I assume that is because texCords is never intialized or it is thinking texCords is something else rather than the things defined in SpriteRenderer class. Regardless I have been trying to fix this to no avail any help will be appreciated!

mikayy
Автор

Any reason you didn't just use int texId =

LuminaryGames
welcome to shbcf.ru