Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UPBGE: Prevent mipmapping while setting VideoFFmpeg #411

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion source/gameengine/VideoTexture/ImageBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ ImageBase::ImageBase (bool staticSrc) : m_image(nullptr), m_imgSize(0), m_intern
m_avail(false), m_scale(false), m_scaleChange(false), m_flip(false),
m_zbuff(false),
m_depth(false),
m_staticSources(staticSrc), m_pyfilter(nullptr)
m_type(IMAGE_NONE),
m_staticSources(staticSrc), m_pyfilter(NULL)
{
m_size[0] = m_size[1] = 0;
m_exports = 0;
Expand Down
9 changes: 9 additions & 0 deletions source/gameengine/VideoTexture/ImageBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ class ImageBase
/// number of buffer pointing to m_image, public because not handled by this class
int m_exports;

/// type of the image
enum {
IMAGE_RENDER,
IMAGE_VIEWPORT,
IMAGE_VIDEO,
IMAGE_MIRROR,
IMAGE_NONE
} m_type;

protected:
/// image buffer
unsigned int * m_image;
Expand Down
2 changes: 2 additions & 0 deletions source/gameengine/VideoTexture/ImageRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ ImageRender::ImageRender (KX_Scene *scene, KX_Camera * camera, unsigned int widt
m_engine = KX_GetActiveEngine();
m_rasterizer = m_engine->GetRasterizer();
m_canvas = m_engine->GetCanvas();
m_type = IMAGE_RENDER;

GPUHDRType type;
if (hdr == RAS_IRasterizer::RAS_HDR_HALF_FLOAT) {
Expand Down Expand Up @@ -878,6 +879,7 @@ ImageRender::ImageRender (KX_Scene *scene, KX_GameObject *observer, KX_GameObjec
m_mirror(mirror),
m_clip(100.f)
{
m_type = IMAGE_MIRROR;
GPUHDRType type;
if (hdr == RAS_IRasterizer::RAS_HDR_HALF_FLOAT) {
type = GPU_HDR_HALF_FLOAT;
Expand Down
1 change: 1 addition & 0 deletions source/gameengine/VideoTexture/ImageViewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ ImageViewport::ImageViewport()
m_viewportImage = new BYTE [4 * getViewportSize()[0] * getViewportSize()[1]];
// set attributes
setWhole(true);
m_type = IMAGE_VIEWPORT;
}

// constructor
Expand Down
15 changes: 12 additions & 3 deletions source/gameengine/VideoTexture/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,19 @@ int Texture::pyattr_set_mipmap(PyObjectPlus *self_v, const KX_PYATTRIBUTE_DEF *a
PyErr_SetString(PyExc_TypeError, "The value must be a bool");
return -1;
}
if (!self->m_source) {
PyErr_SetString(PyExc_ValueError, "The texture source must be set before setting mipmap");
return -1;
}
// set mipmap
self->m_mipmap = value == Py_True;
// success
return 0;
if (self->m_source->m_image &&
self->m_source->m_image->m_type != ImageBase::IMAGE_VIDEO) {
self->m_mipmap = value == Py_True;
// success
return 0;
}
PyErr_SetString(PyExc_TypeError, "Videos can't have mipmap");
return -1;
}

// get source object
Expand Down
1 change: 1 addition & 0 deletions source/gameengine/VideoTexture/VideoFFmpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ m_isThreaded(false), m_isStreaming(false), m_stopThread(false), m_cacheStarted(f
BLI_listbase_clear(&m_frameCacheBase);
BLI_listbase_clear(&m_packetCacheFree);
BLI_listbase_clear(&m_packetCacheBase);
m_type = IMAGE_VIDEO;
}

// destructor
Expand Down