Abstract
In this final chapter, we add a new editor to the Blender codebase. Doing so will help us to better understand editor implementation. It will also provide a platform for adding a simple button layout using Blender’s custom user interface (UI) API. Along the way, we will encounter the gpu module, an abstraction layer for Blender’s underlying hardware-based rendering API (i.e., OpenGL). We will also register a few non-modal operators for our editor. All of this will be done directly in the codebase’s C code.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
A discussion of OpenGL is beyond the scope of this book. A standard resource for learning OpenGL is the “OpenGL Programming Guide,” by Shreiner et al.
- 2.
Note that the regular editors provided in the Blender codebase have their header regions defined in Python. Also, their headers have a menu which allows for selection of a different region from the one that is displayed.
- 3.
This should not be confused with a wmWindow object. This refers to a part of a Blender window’s screen within an editor, instead. Recall Chapter 7’s discussion of the divisions of Blender application windows.
- 4.
IIn practice, it is better to implement such UI in the Python scripts that run at startup. This is more flexible and nearly as efficient, once registered and run from memory. However, using C in this chapter was intended as an introduction to the UI_*.
- 5.
An improved version of tutorial_main_region_draw() might use scaled offsets when the editor’s extents are smaller than the hard-coded ones. However, this would complicate the code and potentially obscure the purpose of exposing the basic mechanics of editor creation.
- 6.
The path and file information in doc/guides/interface_API.txt is incorrect and should be read with caution. There are also enums and earlier variants of functions that are no longer in the codebase.
- 7.
You will recall that we used the source/blender/editors/interface/interface_intern.h in our tutorial editor. This was to gain access to the struct uiBut, allowing us to manually assign its optype field with the wmOperatorType. Normally, you will be adding buttons via the Blender Python API, so including interface_intern.h in your editor’s source file is neither necessary or advised—in order to maintain the preferred practice of encapsulation. The Blender codebase enforces this by not placing the implementation of the struct uiBut in the UI_*.h files. When code tries to access the struct uiBut outside of editors/interface/, while not using interface_intern.h, a “dereferencing pointer to incomplete type” compile error results.
- 8.
Hint: look into [repository directory]/source/blender/makesrna/intern/rna_ui_api.c and rna_ui.c. These implement the “RNA” Data API interface to the UI_* API.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2021 The Author(s), under exclusive license to APress Media, LLC , part of Springer Nature
About this chapter
Cite this chapter
Hollister, B.E. (2021). Editor Creation. In: Core Blender Development. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-6415-7_8
Download citation
DOI: https://doi.org/10.1007/978-1-4842-6415-7_8
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-6414-0
Online ISBN: 978-1-4842-6415-7
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books