I change UI_draw_roundbox_gl_mode to use immediate API.
The rest of the change is the call to the function.
I also make some change in UI_ThemeColor4(int colorid) for eg to make convenience to use.
I would really like to know if it's the good way to do, if yes I will make all the change in the node_daw.c after, else say me what's wrong and how to deal with color else.
Details
- Reviewers
Julian Eisel (Severin) Mike Erwin (merwin) Dalai Felinto (dfelinto) - Maniphest Tasks
- T49043: replace OpenGL immediate mode in Blender 2.8
- Commits
- rBSb613d25354cb: Blender 2.8: OpenGL: replace old GL with the new immediate API in…
rBb613d25354cb: Blender 2.8: OpenGL: replace old GL with the new immediate API in…
Diff Detail
Event Timeline
Thanks! Here are some notes:
| source/blender/editors/interface/interface_draw.c | ||
|---|---|---|
| 99 | Yes! | |
| 104 | Since color is set once for the whole roundbox, we can use GPU_SHADER_2D_UNIFORM_COLOR! Color values still need to be passed into the function like you did. Just call immUniformColor4ubv right after binding the shader program. | |
| 1523 | Suggestion: const unsigned char color[4] = { ... };
UI_draw_roundbox_gl_mode( ... , color); | |
| source/blender/editors/interface/resources.c | ||
| 1265 | Leave UI_ThemeColor functions alone for now. Lots of drawing code uses these! Use existing UI_GetThemeColor functions to fetch color values (you might need to add one or two missing functions). | |
| source/blender/gpu/gawain/immediate.c | ||
| 567 | Function owns the returned memory, so lifetime is ok... but the values are only good for a very short (undetermined) time. Calling again in the same thread or a different thread trashes the data. I don't think we don't need this function. | |
@Krantz Geoffroy (kgeogeo) I added your name on the task list so other people will know that you're working here. You can mark it as "done" later, and claim new files / functions before starting more work.
Thanks for your quick reply, it's motivating.
| source/blender/editors/interface/resources.c | ||
|---|---|---|
| 1265 | No part of blender use the return of this function, it can still be a problem?? As you say it's used a lot of time, that why i make it, it's and will be a lot easier to make all the modification with this. But you know it better than me for sure, I hope.... :-)))))) | |
| source/blender/editors/interface/interface_draw.c | ||
|---|---|---|
| 103 | Not sure why 72? I only count 32 vertices. | |
| source/blender/editors/interface/resources.c | ||
| 1265 | I'd prefer to get rid of the UI_ThemeColorXXX functions and only keep the UI_GetThemeColorXXX ones. I guess after 3.2 core profile transition they'll be useless anyway since it doesn't use color states (right?). | |
| source/blender/editors/interface/interface_draw.c | ||
|---|---|---|
| 103 | Eeeh, *36 :) | |
| source/blender/editors/interface/resources.c | ||
|---|---|---|
| 1265 | Hmm, good points... All this makes me start thinking about a better API for using theme colors! But that's not really part of the immediate mode task. UI_ThemeColor updates current OpenGL state to use a theme color. With your change it does that *and* returns a convenient pointer. I still prefer the UI_GetThemeColor functions for this, since you are just getting a color. Yes it's less convenient to call. But it's not that bad. | |
| source/blender/editors/interface/interface_draw.c | ||
|---|---|---|
| 103 | @Julian Eisel (Severin) is trying to crash us! I count 36 too. | |
| source/blender/editors/interface/resources.c | ||
| 1265 |
Right, those functions will be obsolete. After that maybe we can redo the theme color API. | |
| source/blender/editors/interface/interface_draw.c | ||
|---|---|---|
| 103 | I try it and you're right... I've made the change. | |
| source/blender/editors/interface/interface_draw.c | ||
|---|---|---|
| 103 |
Yep it's vertex count. Doesn't matter if coordinates are 2D or 3D. Also doesn't matter how many attributes each vertex has. I'll remember to explain this better in the docs. | |
| source/blender/editors/interface/interface_draw.c | ||
|---|---|---|
| 587 | OK, I think I see what you mean (I hope ;-)))) ) unsigned char color[4]; UI_draw_roundbox_corner_set(UI_CNR_ALL); it would be good, that's what you mean/want?? if yes I have to make UI_GetThemeColorShade4ubv too for eg?? | |
| source/blender/editors/interface/interface_draw.c | ||
|---|---|---|
| 587 | Yes to all of that :) | |
Almost willing to accept this, just one thing that annoys me a bit ;) Added inline comment
| source/blender/editors/animation/anim_channels_defines.c | ||
|---|---|---|
| 125 | It's a bit ugly to have float->uchar conversions everywhere, I'd suggest you solve this a bit differently:
Here, the call would simplify to this then: float color[3]; ... /* fill color array */ UI_draw_roundbox_gl_mode_fl(..., color, 1.0f); | |
Almost done
| source/blender/editors/animation/anim_channels_defines.c | ||
|---|---|---|
| 125 | I disagree here. Why should a roundbox drawing function have two or more interfaces? I think it should just take byte[4] colors (like now) or just float[4] colors and callers have to deal with it. Looks like float colors are used more often so can we use that? UI_GetThemeColorShade4fv already exists. Keep the new UI_GetThemeColorShade4ubv because it is useful. I'll add immUniformColor4fv in a minute, so "git stash" then "git pull --rebase" then "git stash pop". Sorry for the extra work @Krantz Geoffroy (kgeogeo) -- we're almost there! | |
@Krantz Geoffroy (kgeogeo) may I suggest you tackling ui_panel_category_draw_tab in interface_panel.c next? it's based on this code.
One more tiny fix then this is ready
| source/blender/editors/interface/interface_draw.c | ||
|---|---|---|
| 1791–1792 | 100/255 = 0.392... change 0.3 to 0.4 alpha | |
Oops, today I pushed a change to view3d_draw.c so "arc patch" failed. Please rebase and update this patch, then I will land it.
There might be a simple way to do all this but I don't know arcanist well.
Landed in blender2.8! I thought that would auto-close this diff...
Thanks @Krantz Geoffroy (kgeogeo) for your contribution so far.