Skip to content

OpenGL Terrain editor#59

Open
morganchristiansson wants to merge 28 commits into
Return-To-The-Roots:masterfrom
morganchristiansson:gl2-terrain
Open

OpenGL Terrain editor#59
morganchristiansson wants to merge 28 commits into
Return-To-The-Roots:masterfrom
morganchristiansson:gl2-terrain

Conversation

@morganchristiansson

Copy link
Copy Markdown
Contributor

Removes Surf_Map and renders terrain editor with OpenGL

It actaully works great as parallel branch & PR, only depends on some CFont and Texture changes from gl2-ui which have been pulled into this branch. If they are identical they shouldn't even conflict. Could extract to shared parent commit, but prob easiest to deal with any conflicts when the other/this PR is merged. There's minimal overlap.

Still working a bit on this one I didn't expect to submit it so early, but all feedback welcome even if quick and inaccurate.

@morganchristiansson

Copy link
Copy Markdown
Contributor Author

I'm wondering if I should remove the VBOs. GPU cached terrain triangles. Just re-draw them every frame there's not a huge amount of them even when zoomed out fully and diff might be a bit smaller/closer to original.
But also they're probably not handling too much.

Comment thread include/defines.h
// BEGIN: /GFX/TEXTURES/TEX5.LBM
TILESET_GREENLAND_8BPP,
TILESET_GREENLAND_32BPP,
TILESET_GREENLAND,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this break stuff? IIRC those were used as indices somewhere

@morganchristiansson morganchristiansson Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s25edit has P button to toggle 8bit/32bit terrain rendering marked experimental in F1 help window text.
Doesn't really make sense, maybe it was to add shadows. With OpenGL textures always being 32bit it really doesn't make sense to keep.
Also CFile had a pre-existing bug it would intermittently use the wrong colorkey and not have transparency on terrain edges.

@Flamefire

Copy link
Copy Markdown
Member

I'm wondering if I should remove the VBOs. GPU cached terrain triangles. Just re-draw them every frame there's not a huge amount of them even when zoomed out fully and diff might be a bit smaller/closer to original.

Seems to make sense to use them given the map is mostly static. Do the VBOs still handle animated textures correctly? That would be a reason to not use them. Or limit to positions only, but I guess that wouldn't save much work

But also they're probably not handling too much.

What do you mean by that?

@morganchristiansson

Copy link
Copy Markdown
Contributor Author

I mean relative to modern games a settlers2 map doesn't have many triangles.

Biggest gain will be getting rid of 4K penalty ~33MB/frame ~2GB/second@60fps. yeah VBO is useful, but increases diff a lot and makes review harder for probably not too much benefit. Might be better to do as follow up.

Also I just struggled to get nice diff that correctly aligns functions with all the the VBO code inserted above existing code.

@morganchristiansson

Copy link
Copy Markdown
Contributor Author

Also this PR still draws triangles to pixel positions and recalculates them on zoom. Would be better to use glScale(). But I think doesn't matter here can do in later PR, there's a lot more that could be done that would make PR bigger.

Comment thread CSurface.cpp
}

void CSurface::DrawTriangleField(SDL_Surface* display, const DisplayRectangle& displayRect, const bobMAP& myMap)
void CSurface::DrawTriangleField(const DisplayRectangle& displayRect, const bobMAP& myMap)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff for this function is unreviewable.
At least the method signature lines up in the diff now after removing VBO.
I'm going to do some more work and see if improve reviewability. I think we're mostly doing the same thing in same order so shouldn't look like this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I now consider it reviewable.

Maybe still some details left still, but reviewable.

This branch has been really crazy. Basically went too far, and finished it by going backwards.
Crazy times with AI.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also would like to merge #57 before this one cause ice floe animations don't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants