Skip to content

Commit

Permalink
use ifdef for curved screen
Browse files Browse the repository at this point in the history
  • Loading branch information
kodenamekrak committed May 31, 2024
1 parent 223dbc4 commit 1593449
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)

# compile options used
add_compile_options(-frtti -fexceptions -fdeclspec -fvisibility=hidden -fPIE -fPIC -fms-extensions)
add_compile_options(-frtti -fexceptions -fdeclspec -fvisibility=hidden -fPIE -fPIC)

if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
add_compile_options(-O0)
Expand Down
29 changes: 24 additions & 5 deletions src/Screen/CustomVideoPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

#include "assets.hpp"

#include "assets.hpp"

using namespace UnityEngine;
using namespace UnityEngine::Video;

Expand All @@ -38,24 +36,30 @@ namespace Cinema {
screenColorOn.a = 0;

DEBUG("Creating CustomVideoPlayer");

#ifdef USE_CURVED_SCREEN
CreateScreen();
screenRenderer = screenController->GetRenderer();
screenRenderer->material = Material::New_ctor(GetShader());
screenRenderer->material->color = screenColorOff;
screenRenderer->material->enableInstancing = true;

player = gameObject->AddComponent<VideoPlayer*>();
#else
player = CreateVideoPlayer(transform);
#endif

auto set_source = RESOLVE_ICALL(set_source, void, Video::VideoSource);
set_source(player, Video::VideoSource::Url);

#ifdef USE_CURVED_SCREEN
auto set_renderMode = RESOLVE_ICALL(set_renderMode, void, Video::VideoRenderMode);
set_renderMode(player, Video::VideoRenderMode::RenderTexture);
renderTexture = screenController->CreateRenderTexture();
renderTexture->wrapMode = TextureWrapMode::Mirror;

auto set_targetTexture = RESOLVE_ICALL(set_targetTexture, void, RenderTexture*);
set_targetTexture(player, renderTexture);

#endif
auto set_playOnAwake = RESOLVE_ICALL(set_playOnAwake, void, bool);
set_playOnAwake(player, false);

Expand Down Expand Up @@ -101,7 +105,9 @@ namespace Cinema {
Mute();
// screenController->SetScreensActive(false);

#ifdef USE_CURVED_SCREEN
screenController->EnableColorBlending(true);
#endif
SetDefaultMenuPlacement();
}

Expand All @@ -114,13 +120,16 @@ namespace Cinema {

void CustomVideoPlayer::SetPlacement(Placement& placement)
{
// will add this properly soon ?
#ifdef USE_CURVED_SCREEN
screenController->SetPlacement(placement);
#endif
}

// Flat plane video player
Video::VideoPlayer* CustomVideoPlayer::CreateVideoPlayer(UnityEngine::Transform* parent)
{
INFO("Creating VideoPlayer");
INFO("Creating Flat Plane VideoPlayer");
GameObject* screenGo = GameObject::CreatePrimitive(PrimitiveType::Plane);
screenGo->get_transform()->set_parent(parent);
GameObject::DontDestroyOnLoad(screenGo);
Expand Down Expand Up @@ -205,10 +214,14 @@ namespace Cinema {

void CustomVideoPlayer::CreateScreen()
{
#ifdef USE_CURVED_SCREEN
screenController = ScreenController::New_ctor();
screenController->CreateScreen(transform);
screenController->SetScreensActive(true);
SetDefaultMenuPlacement();
#else

#endif
}

void CustomVideoPlayer::Play()
Expand Down Expand Up @@ -264,12 +277,18 @@ namespace Cinema {

Color CustomVideoPlayer::get_ScreenColor()
{
#ifdef USE_CURVED_SCREEN
return screenRenderer->get_material()->get_color();
#else
return Color::get_clear();
#endif
}

void CustomVideoPlayer::set_ScreenColor(UnityEngine::Color value)
{
#ifdef USE_CURVED_SCREEN
screenRenderer->get_material()->set_color(value);
#endif
}

float CustomVideoPlayer::get_PlaybackSpeed()
Expand Down

0 comments on commit 1593449

Please sign in to comment.