Commit Graph

493 Commits

Author SHA1 Message Date
7dc3ad2287 Fix T51889: new file or load factory settings results in broken UI.
Fix some cases that still assumed there to be a global DPI, instead of a per
window DPI that needs to be set before reading U.dpi.
2017-07-08 00:54:05 +02:00
Campbell Barton
72c9141a7a Cleanup: doxygen comments
Also remove duplicate & mismatching comments from grease-pencil header.
Keep comments close to implementation to avoid getting out of sync.
2017-06-19 10:04:30 +10:00
Dalai Felinto
6b9ab1f7a2 Unifying access to GLEW from the Blender Game Engine
Note: This is not about functionality, but about using the same stub file
we are using in Blender for the game engine in blender2.8.
2017-05-11 16:08:03 +02:00
Bastien Montagne
d68a84d1d2 Fix BGE building.
When you use typedef'ed enum, you need to define all supported values
explicitely in enum, else compiler goes grumpy...
2017-03-16 10:30:02 +01:00
Mike Erwin
33ef28068a BGE: remove calls to GLSL support query (it's always supported)
Reworked logic in the few places that still called this. Deleted the "GLSL not supported" fallbacks.

Also removed some nearby checks for ARB_multitexture and OpenGL 1.1. Blender 2.77 removed checks like this, but game engine still has some.
2016-10-10 01:19:10 -04:00
Julian Eisel
16ed49b26e UI Messages: Consistent spelling of term "data-block"
Was using a bunch of different spellings, mostly "data-block" though, so went with that one (would have been my #1 choice anyway ;) )
2016-09-19 16:50:45 +02:00
lazydodo
5c04b4fdfb Fix T49196 2016-08-29 13:33:30 -06:00
Porteries Tristan
5e5d3d6391 BGE: Call DNA_sdna_current_init when launching blenderplayer.
Don't calling DNA_sdna_current_init was creating a crash because a global uninitialized
variable was used when reading blender files.
2016-08-08 15:41:19 +00:00
lazydodo
399c978a55 fix breakage caused by D2094 / rB404f41d22de46119ee8afb409011eb1ba1840092 2016-07-18 13:09:41 -06:00
Campbell Barton
9f5621bb4a Cleanup: comment blocks 2016-07-02 10:08:33 +10:00
Ulysse Martin
dbd38e969f BGE: Display Hardware infos only in standalone.
This patch moves the PrintHardwareInfo() function in standalone only, not in embedded. Why? Because you can need this infos for debugging
purpose in "compiled" blender files but it was boring to have it displayed each time you launched embedded. So you can have this infos when you
click standalone or when you run your executable app from a console.

Reviewers: moguri, kupoman, panzergame.
2016-07-01 11:56:26 +00:00
Bastien Montagne
897e97f078 ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.

Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).

One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).

This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).

This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.

A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)

Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:53:50 +02:00
Benoit Bolsee
40f1c4f343 BGE: Various render improvements.
bge.logic.setRender(flag) to enable/disable render.
    The render pass is enabled by default but it can be disabled with
    bge.logic.setRender(False).
    Once disabled, the render pass is skipped and a new logic frame starts
    immediately. Note that VSync no longer limits the fps when render is off
    but the 'Use Frame Rate' option in the Render Properties still does.
    To run as many frames as possible, untick the option
    This function is useful when you don't need the default render, e.g.
    when doing offscreen render to an alternate device than the monitor.
    Note that without VSync, you must limit the frame rate by other means.

fbo = bge.render.offScreenCreate(width,height,[,samples=0][,target=bge.render.RAS_OFS_RENDER_BUFFER])
    Use this method to create an offscreen buffer of given size, with given MSAA
    samples and targetting either a render buffer (bge.render.RAS_OFS_RENDER_BUFFER)
    or a texture (bge.render.RAS_OFS_RENDER_TEXTURE). Use the former if you want to
    retrieve the frame buffer on the host and the latter if you want to pass the render
    to another context (texture are proper OGL object, render buffers aren't)
    The object created by this function can only be used as a parameter of the
    bge.texture.ImageRender() constructor to send the the render to the FBO rather
    than to the frame buffer. This is best suited when you want to create a render
    of specific size, or if you need an image with an alpha channel.

bge.texture.<imagetype>.refresh(buffer=None, format="RGBA", ts=-1.0)
    Without arg, the refresh method of the image objects is pretty much a no-op, it
    simply invalidates the image so that on next texture refresh, the image will
    be recalculated.
    It is now possible to pass an optional buffer object to transfer the image (and
    recalculate it if it was invalid) to an external object. The object must implement
    the 'buffer protocol'. The image will be transfered as "RGBA" or "BGRA" pixels
    depending on format argument (only those 2 formats are supported) and ts is an
    optional timestamp in the image depends on it (e.g. VideoFFmpeg playing a video file).
    With this function you don't need anymore to link the image object to a Texture
    object to use: the image object is self-sufficient.

bge.texture.ImageRender(scene, camera, fbo=None)
    Render to buffer is possible by passing a FBO object (see offScreenCreate).

bge.texture.ImageRender.render()
    Allows asynchronous render: call this method to render the scene but without
    extracting the pixels yet. The function returns as soon as the render commands
    have been send to the GPU. The render will proceed asynchronously in the GPU
    while the host can perform other tasks.
    To complete the render, you can either call refresh() directly of refresh the texture
    to which this object is the source. Asynchronous render is useful to achieve optimal
    performance: call render() on frame N and refresh() on frame N+1 to give as much as
    time as possible to the GPU to render the frame while the game engine can perform other tasks.

Support negative scale on camera.
    Camera scale was previously ignored in the BGE.
    It is now injected in the modelview matrix as a vertical or horizontal flip
    of the scene (respectively if scaleY<0 and scaleX<0).
    Note that the actual value of the scale is not used, only the sign.
    This allows to flip the image produced by ImageRender() without any performance
    degradation: the flip is integrated in the render itself.

Optimized image transfer from ImageRender to buffer.
    Previously, images that were transferred to the host were always going through
    buffers in VideoTexture. It is now possible to transfer ImageRender
    images to external buffer without intermediate copy (i.e. directly from OGL to buffer)
    if the attributes of the ImageRender objects are set as follow:
       flip=False, alpha=True, scale=False, depth=False, zbuff=False.
       (if you need to flip the image, use camera negative scale)
2016-06-11 22:05:20 +02:00
Benoit Bolsee
8529b2f925 BGE: alpha on frame buffer and precedence of MSAA over swap.
A new option '-a' can be passed to the blenderplayer. It forces the
framebuffer to have an alpha channel.
This can be used in VideoTexture to return a image with alpha channel
with ImageViewport (provided alpha is set to True on the ImageViewport
object and that the background color alpha channel is 0, which is the
default).
Without the -a option, the frame buffer has no alpha channel and
ImageViewport always returns an opaque image, no matter what.
In Linux, the player window will be rendered transparently over
the desktop.
In Windows, the player window is still rendered opaque because
transparency of the window is only possible using the 'compositing'
functions of Windows. The code is there but not enabled  (look for
WIN32_COMPOSITING) because 1) it doesn't work so well 2) it requires
a DLL that is only available on Vista and up.

give precedence to AA over Swap copy:

Certain GPU (intel) will not allow MSAA together with swap copy.
Previously, swap copy had priority over MSAA: fewer AA samples would be
chosen if it was the condition to get swap copy. This patch reverse the
logic: swap copy will be abandonned if another swap method (undefined or
exchange) will provide the number of AA samples requested. If no AA
samples is requested, swap copy still has the priority of course.
2016-06-09 22:15:13 +02:00
Sergey Sharybin
e1a254d8de Attempt to fix blenplayer after recent changes 2016-05-10 16:14:24 +02:00
Sergey Sharybin
9239257806 Fix T48393: Blender player doesn't start on files saved with with cyrillic letters in path 2016-05-10 14:31:00 +02:00
Bastien Montagne
ce65fae8f3 Fix T48369: Missing suport for main '+' key.
Many keyboard layouts (italian, spanish, german...) have direct access to '+' key on main
keyboard area (not the numpad one), ans x11 has own define for this key, so use it instead
of generating an unkown key event.

Note that we most likely have much more missing 'specific' keycodes for non-US keyboard layout,
but think since we already had a 'minus' keyevent, supporting 'plus' one is totally consistent.
And we had a spare space in our defined values just for it even!

This keyevent is only supported/generated by x11 and cocoa Ghost backends for now,
neither SDL nor win32 seem to have matching key events...
2016-05-10 08:29:03 +02:00
Campbell Barton
beaa57d269 Refactor BKE_blender into separate headers
- BKE_blender_version.h (only version defines & versionstr).
- BKE_blender_copybuffer.h (currently only used for view3d copy/paste).
- BKE_blender_undo.h (global undo functions).
- BKE_blendfile.h (high level blend file read/write API).
2016-04-25 19:27:45 +10:00
Sergey Sharybin
5d99cde822 Remove SCons building system
While SCons building system was serving us really good for ages it's no longer
having much attention by the developers and started to become quite a difficult
task to maintain.

What's even worse -- there started to be quite serious divergence between SCons
and CMake which was only accumulating over the releases now. The fact that none
of the active developers are really using SCons and that our main studio is also
using CMake spotting bugs in the SCons builds became quite a difficult task and
we aren't always spotting them in time.

Meanwhile CMake became really mature building system which is available on every
platform we support and arguably it's also easier and more robust to use.

This commit includes:

- Removal of actual SCons building system
- Removal of SCons git submodule
- Removal of documentation which is stored in the sources and covers SCons
- Tweaks to the buildbot master to stop using SCons submodule
  (this change requires deploying to the server)
- Tweaks to the install dependencies script to skip installing or mentioning
  SCons building system
- Tweaks to various helper scripts to avoid mention of SCons folders/files
  as well

Reviewers: mont29, dingto, dfelinto, lukastoenne, lukasstockner97, brecht, Severin, merwin, aligorith, psy-fi, campbellbarton, juicyfruit

Reviewed By: campbellbarton, juicyfruit

Differential Revision: https://developer.blender.org/D1680
2016-01-04 14:20:48 +05:00
Jorge Bernal
ee59df521f BGE clean up: use float version of trigonometric functions 2015-12-16 01:53:48 +01:00
Mitchell Stokes
964107fbce BGE code cleanup: Removing RAS_GLExtensionManager.
This class did nothing but print out extensions if they were found.
Instead, the code from bge.logic.PrintGLInfo() is now printed as the
Rasterizer is initialized. This gives better information, and it removes
some GL code from KX_PythonInit.cpp (the PrintGLInfo method now calls
the Rasterizer to print the information).

Differential Revision: https://developer.blender.org/D438
2015-12-07 19:25:12 -08:00
Mitchell Stokes
fe2f3a131d OpenGL/BGE: Remove RAS_StorageIM (glBegin/glEnd rendering of mesh data)
The only use we had for RAS_StorageIM was to render derived meshes using
Blender's mesh drawing. This is now handled as a special case in
RAS_OpenGLRasterizer instead of in RAS_StorageIM.

We are now left with RAS_StorageVA and RAS_StorageVBO. At the moment
vertex arrays are still the default since our vertex array with display
lists implementation is still much faster than our VBO code in a lot of
cases. As we improve our VBO code, we can drop vertex arrays since
Blender's minimum OpenGL version is being bumped up to 2.1, which
supports VBOs.
2015-12-07 19:05:09 -08:00
Sybren A. Stüvel
31cc60e76b BGE: Save screenshots in a different thread
This patch allows the game engine to keep running while performing things like PNG compression and disk I/O.

As an example, my crowd simulation rasterizer saves a screenshot for every frame. This now takes up 13 msec per frame, which was 31 msec before this patch. Effectively, it allows the simulation to save every frame and still run at 60 FPS.

Reviewers: lordloki, moguri, panzergame

Reviewed By: moguri, panzergame

Projects: #game_engine

Differential Revision: https://developer.blender.org/D1507
2015-11-24 09:15:15 +01:00
Antony Riakiotakis
db1f0e3616 Error out on Windows if driver does not support OpenGL 2.1 with an error
messagebox.
2015-11-22 20:53:57 +01:00
Campbell Barton
a5e631171b BLI_path api, minor changes to CWD handling
- BLI_current_working_dir's return value must be checked, since it may fail.
- BLI_current_working_dir now behaves like getcwd, where a too-small target will return failure.
- avoid buffer overrun with BLI_path_cwd, by taking a maxlen arg.
2015-10-08 15:05:58 +11:00
Porteries Tristan
8444f7ba2b BGE: Fix T42679: Python physics environment not setted for python control script. 2015-08-23 14:34:04 +02:00
Campbell Barton
2e2dc9b9e3 Refactor translation code out of blenfont
- Add blentranslation `BLT_*` module.
- moved & split `BLF_translation.h` into (`BLT_translation.h`, `BLT_lang.h`).
- moved `BLF_*_unifont` functions from `blf_translation.c` to new source file `blf_font_i18n.c`.
2015-08-18 07:01:26 +10:00
Sergey Sharybin
dfc672f8bb SCons: Fix for really nasty bug with polluting configuration environment
The issue was caused by the following construction:

  def = env['SOMETHING']
  defs.append('SOMETHING_MORE')

Since first assignment was actually referencing environment option it was totally
polluted hawing weird and wonderful side effects on all other areas of Blender.
2015-08-04 18:06:28 +02:00
Jörg Müller
a0cbebf404 Audaspace: fixing problems for the merge to master suggested by Campbell and Sergey.
- rename WITH_EXTERNAL_AUDASPACE to WITH_SYSTEM_AUDASPACE.
- rename C/PYAUDASPACE to AUDASPACE_C/PY
- simplifying cmake defines and includes.
- fixing include paths and enabling WITH_SYSTEM_AUDASPACE for windows.
- fixing scons building.
- other minor build system fixes.
2015-07-28 14:01:53 +02:00
Jörg Müller
f700c1f3a8 Audaspace: name fixes and external library update. 2015-07-28 14:01:52 +02:00
Jörg Müller
733073550f Audaspace: use standalone library.
- Added the cmake configuration option WITH_EXTERNAL_AUDASPACE.
- Fixes to build without standalone library as well.
2015-07-28 14:01:52 +02:00
Jörg Müller
96dd213e7e Audaspace: preparing to use standalone library.
- Renamed some functions.
- Using C API instead of C++ in the game engine, as the standalone is C++11.
2015-07-28 14:01:52 +02:00
Campbell Barton
a837797740 Cleanup: quiet warning 2015-07-09 19:33:02 +10:00
Porteries Tristan
2da9a39418 BGE : Fix black material on meshes without materials in blenderplayer.
Blenderplayer forgot to initialize the default material (defmaterail) with function init_def_material().
This reverts also the plumber commit 2fa4a48bcef05671890fafc3fe50a8fa619f0259.

Reviewers: campbellbarton
2015-05-24 11:46:57 +02:00
Sergey Sharybin
23a79c42b5 BGE Player: Fix compilation error after cleanup commit da8a62a 2015-05-04 14:39:12 +05:00
Thomas Szepe
e36b0cb8f3 BGE: New API method getDisplayDimensions
This patch adds a new API function to get the actual display dimensions in pixels.

Reviewers: dfelinto, sybren, lordloki, moguri

Reviewed By: lordloki, moguri

Differential Revision: https://developer.blender.org/D648
2015-04-07 18:32:25 +02:00
Antony Riakiotakis
828c85a1bf sound module: Append functions with BKE (makes it easier to make them
out from local functions)
2015-03-26 11:35:41 +01:00
Bastien Montagne
d9fa9bffd5 Grmll, sorry for the noise, fix stupi cpoypaste typo in previous commit. 2015-02-26 11:46:05 +01:00
Bastien Montagne
ac26a61385 Attempt to fix BGE build on windows.
Caused by rBb5b359b48f7f35a79b3eec, better to try a full build before pushing that type of commit. :/
2015-02-26 11:42:22 +01:00
Antony Riakiotakis
b5b359b48f Warning messagebox for windows when an unsupported implementation of
OpenGL is detected:

Hoping to decrease the frequency of by far one of the most frequent bug
reports by windows users.

There is some reorganization of the GHOST API to allow easy addition of
further OpenGL options in the future. The change is not propagated too
deep to keep the size of the patch managable. We might reorganize things
here later.

For OpenGL we do two checks here:
One is a combination of GDI generic renderer or vendor microsoft
corporation and OpenGL version 1.1. This means the system does not
use GPU acceleration at all. We warn user to install a graphics
driver and of cases where this might happen (remote connection, using
blender through virtual machine)

The other one just checks if OpenGL version is less than 1.4 (we can
easily change that in the future of course) and warns that it is
deprecated.

Both cases will still let blender startup correctly but users should now
have a clear idea of the system being unsupported.

A user preference flag is provided to turn the warning off.

Now stop posting those bug reports without installing a driver first -
please?
2015-02-25 13:51:53 +01:00
HG1
f1a65a9fab makeScreenshot - adding frame number to the filename 2015-02-21 12:16:20 +00:00
Bastien Montagne
31219415d6 Fix BGE compilation after recent renames in BKE_image (tsst...). 2015-01-24 14:57:57 +01:00
Campbell Barton
29d2c71117 Fix for bool flag use 2015-01-07 12:08:55 +11:00
Jens Verwiebe
c1f54bcdcc OSX: revive GHOST_HACK_getFirstFile cause it breaks things on older OSX versions.
Dunno exactly why this was done earlier, but propose not to remove code not understood.
2014-12-25 15:12:56 +01:00
Campbell Barton
43fa4baa6c Refactor: BLI_path_util (part 2)
Use BKE_appdir/tempdir naming prefix for functions extracted from BLI_path_util
2014-11-23 18:55:52 +01:00
Campbell Barton
6308c16675 Refactor: BLI_path_util (split out app directory access)
This module is intended for path manipulation functions
but had utility functions added to access various directories.
2014-11-23 18:42:18 +01:00
Sergey Sharybin
80d1d624d3 Support dynamic loading of SDL libraries
This is mainly to address old issue when one need to have SDL library installed
in order to use our official builds. Some hip distros already installs SDL,
but it's not quite the same across all the variety of the distros.

We also now switching to SDL-2.0, most of the distros have it in repositories
already, so it shouldn't be huge deal to install it if needed.

Reviewers: campbellbarton

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D878
2014-11-17 17:43:18 +05:00
Jason Wilkins
8d084e8c8f Ghost Context Refactor
https://developer.blender.org/D643
Separates graphics context creation from window code in Ghost so that they can vary separately.
2014-10-07 15:47:32 -05:00
Campbell Barton
2e840e56cf CMake: correct include dirs 2014-07-01 09:36:28 +10:00
Bastien Montagne
414c70435d T39690: Modifications to Blender's 'temp dir' system.
Current temporary data of Blender suffers one major issue - default 'temp' dir on Windows is never
automatically cleaned up, and can end being quite big when used by Blender, especially when we have
to store per-process data (using getpid() in file names).

To address this, this patch:
* Divides tempdir paths in two, one for 'base' temp dir (the same as previous unique tempdir path),
  the other is a mkdtemp-generated sub-dir, specific to each Blender instance.
* Only uses base tempdir when we need some shallow persistance accross Blender sessions - and we always
  reuse the same filename (quit.blend...) or generate small file (crash reports...).
* Uses temp sub-dir for heavy files like pointcache or renderEXRs (Save Buffer option).
* Erases temp sub-dir on quit or crash.

To get this working it also adds a working 'recursive delete' to BLI_delete() under Windows.

Note that, as in current code, the 'recover render result' hack-feature that was possible
with SaveBuffer option is still removed. A real renderresult cache feature will be added
soon, though.

Reviewers: campbellbarton, brecht, sergey

Reviewed By: campbellbarton, sergey

CC: sergey

Differential Revision: https://developer.blender.org/D531
2014-06-23 13:42:54 +02:00