Skip to main content

Editor Creation

  • Chapter
  • First Online:
Core Blender Development
  • 972 Accesses

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 49.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 64.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 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. 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. 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. 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. 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. 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. 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. 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

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2021 The Author(s), under exclusive license to APress Media, LLC , part of Springer Nature

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

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

Publish with us

Policies and ethics