【发布时间】:2015-10-13 16:11:11
【问题描述】:
我正在使用 opengl 为 android-ndk 开发一个小型 2d 游戏引擎。 我在如何改变水平方面面临困难,例如。从菜单到游戏画面。 由于使用 glGenTextures 为游戏屏幕加载新纹理时纹理 ID 不起作用,因此 glGenTextures 不断返回重复的 ID。
// class to bind ndk with java
Renderer.java
void onSurfaceChanged(gl, width, height){
nativeSurfaceChanged();
}
void onDrawFrame(){
nativeDrawFrame();
}
// c++ code
Game.cpp
Screen *screen;
void SetScreen(Screen *scrn){
screen = scrn;
// load textures and create openGL objects (mesh and textures)
screen->Initialize();
}
void Update(){
screen->Update();
screen->Render();
}
NDKActivity.cpp
Game *game;
void nativeSurfaceChanged(){
// initlizes stuff like audio engine, rendering engine
game->Initialize();
// set current screen to main menu
game->SetScreen(new MainMenu());
}
void nativeDrawFrame(){
game->Update();
}
MainMenu.cpp
void Update(){
// if some button is clicked
game->SetScreen(new GameScreen());
}
现在初始化菜单时,一切正常。但是在加载 GameScreen 时,textue id 都搞混了
我基本上是从我使用 GLUT 来创建 OpenGL 上下文的 Windows 应用程序中移植它,并且它工作正常。
如果需要更多信息,请告诉我
【问题讨论】:
-
如果没有一小段代码,这有点难以回答!试着给我们一个简单的例子,说明你如何尝试改变你的关卡以及你如何处理你的纹理。
-
@MartinHennig 描述够了吗??
标签: opengl-es android-ndk