Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scaleform GFx与OpenGL的集成_Opengl_Gfx_Scaleform - Fatal编程技术网

Scaleform GFx与OpenGL的集成

Scaleform GFx与OpenGL的集成,opengl,gfx,scaleform,Opengl,Gfx,Scaleform,我在将Scaleform GFx解决方案集成到简单应用程序中时遇到问题 问题在于,在显示的场景中,假定为白色的模型显示为紫色 据我所知,颜色效果出现在我开始渲染GFx组件之前;调用FxTest::Initialize就足以引起问题 代码如下 GFx包装器: FxTest::FxTest() { is_initialized_ = false; last_play_time_ = 0; } FxTest::~FxTest() {

我在将Scaleform GFx解决方案集成到简单应用程序中时遇到问题

问题在于,在显示的场景中,假定为白色的模型显示为紫色

据我所知,颜色效果出现在我开始渲染GFx组件之前;调用FxTest::Initialize就足以引起问题

代码如下

GFx包装器:



    FxTest::FxTest() {
        is_initialized_ = false;
        last_play_time_ = 0;
    }

    FxTest::~FxTest() {
        GMemory::DetectMemoryLeaks();
    }

    void FxTest::Initialize(const char* movie_file) {
        // setup logger
        loader_.SetLog(GPtr(*new GFxPlayerLog()));

        // setup file opener
        GPtr file_opener = *new GFxFileOpener;
        loader_.SetFileOpener(file_opener);

        // setup renderer
        renderer_ = *GRendererOGL::CreateRenderer();
        if(!renderer_ || !renderer_->SetDependentVideoMode()) {
            return;
        }
        render_config_ = *new GFxRenderConfig(renderer_, GFxRenderConfig::RF_EdgeAA);
        if(!render_config_) {
            return;
        }
        loader_.SetRenderConfig(render_config_);

        // setup movie
        ui_movie_def_ = *(loader_.CreateMovie(movie_file, GFxLoader::LoadKeepBindData | GFxLoader::LoadWaitFrame1));
        if(!ui_movie_def_) {
            return;
        }
        ui_movie_ = *ui_movie_def_->CreateInstance(GFxMovieDef::MemoryParams(), true);
        if(!ui_movie_) {
            return;
        }

        ui_movie_->Advance(0.0f, 0);
        ui_movie_->SetBackgroundAlpha(0.0f);
        ui_movie_->SetViewport(1024, 768, 0, 0, 1024, 768);
        ui_movie_->SetViewScaleMode(GFxMovieView::ScaleModeType::SM_NoScale);

        is_initialized_ = true;
        last_play_time_ = timeGetTime();
    }

    void FxTest::UpdateViewport(int width, int height) {
        if (!ui_movie_) {
            return;
        }
        ui_movie_->SetViewport(width, height, 0, 0, width, height);
        last_play_time_ = timeGetTime();
    }

    void FxTest::AdvanceAndDisplay() {
        if (!ui_movie_) {
            return;
        }
        BeginDisplay();

        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

        DWORD mtime = timeGetTime();
        float deltaTime = ((float)(mtime - last_play_time_)) / 1000.0f;

        ui_movie_->Advance(deltaTime, 0);
        ui_movie_->Display();

        last_play_time_ = mtime;

        EndDisplay();
    }

    void FxTest::BeginDisplay() {
        glPushAttrib(GL_ALL_ATTRIB_BITS);
    }

    void FxTest::EndDisplay() {
        glPopAttrib();
    }

    void FxTest::OnMouse(GFxEvent::EventType event_type, UInt button, SInt x, SInt y) {
        if (!ui_movie_) {
            return;
        }
        GFxMouseEvent mouse_event(event_type, 0, x, y);
        ui_movie_->HandleEvent(mouse_event);
    }

过剩场景:



    FxTest* g_FxTest = NULL;

    void display() {
        glMatrixMode(GL_MODELVIEW);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glLoadIdentity();

        glTranslatef(0.0, 0.0, -4.5);
        glScalef(1.0, 1.0, 1.0);

        glPushMatrix();
            glutSolidTeapot(1);
        glPopMatrix();

        if (g_FxTest->IsInitialized()) {
            g_FxTest->AdvanceAndDisplay();
        }

        glFlush();
        glutSwapBuffers();
    }

    void reshapeFunc(int x, int y) {
        if (y == 0 || x == 0) {
            return;
        }

        glMatrixMode(GL_PROJECTION);  
        glLoadIdentity();

        gluPerspective(40.0, (GLdouble)x / (GLdouble)y, 0.5, 20.0);
        glViewport(0, 0, x, y);

        if (g_FxTest->IsInitialized()) {
            g_FxTest->UpdateViewport(x, y);
        }
    }

    void idleFunc(void) {
        display();
    }

    void mouseMotion(int x, int y) {
        if (g_FxTest && g_FxTest->IsInitialized()) {
            g_FxTest->OnMouse(GFxEvent::MouseMove, 0, x, y);
        }
    }

    void mouse(int button, int button_state, int x, int y) {
        if (g_FxTest && g_FxTest->IsInitialized()) {
            if (button_state == GLUT_DOWN) {
                g_FxTest->OnMouse(GFxEvent::MouseDown, button, x, y);
            } else if (button_state == GLUT_UP) {
                g_FxTest->OnMouse(GFxEvent::MouseUp, button, x, y);
            }
        }
    }

    int main(int argc, char **argv) {
        glutInit(&argc, argv);
        glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);

        glutInitWindowSize(1024, 768);
        glutCreateWindow("GFx");

        glutDisplayFunc(display);
        glutReshapeFunc(reshapeFunc);
        glutIdleFunc(idleFunc);
        glutMouseFunc(mouse);
        glutMotionFunc(mouseMotion);
        glutPassiveMotionFunc(mouseMotion);

        /*glut init*/
        glClearColor(0.5, 0.5, 0.5, 0.0);
        glEnable(GL_DEPTH_TEST);
        glEnable(GL_LIGHTING);
        glEnable(GL_LIGHT0);

        GFxSystem gfx_init;
        g_FxTest = new FxTest();
        g_FxTest->Initialize("Movie//NpcShop.swf"); // problem start here

        glutMainLoop();
        return 0;
    }


请帮助我理解我做错了什么。

好的,我发现了什么错误-在
FxTest::Initialize
茶壶从gfx获取纹理后,这意味着在大型项目中,需要在开始加载gfx后/之前获得加载的好时机或启用/禁用GL_纹理2D

glDisable(GL_TEXTURE_2D); // after initialization and all good
谢谢大家