Add line numbers to gl errors in es1 and es2 drivers.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@5462 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
92f42e41bf
commit
b46adf170d
|
@ -32,11 +32,11 @@ enum GUI_IDS
|
|||
class MyEventReceiver : public IEventReceiver
|
||||
{
|
||||
public:
|
||||
MyEventReceiver(android_app* app )
|
||||
MyEventReceiver(android_app* app )
|
||||
: Device(0), AndroidApp(app), SpriteToMove(0), TouchID(-1)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void Init(IrrlichtDevice *device)
|
||||
{
|
||||
Device = device;
|
||||
|
@ -60,16 +60,16 @@ public:
|
|||
fakeMouseEvent.MouseInput.Control = false;
|
||||
fakeMouseEvent.MouseInput.ButtonStates = 0;
|
||||
fakeMouseEvent.MouseInput.Event = EMIE_COUNT;
|
||||
|
||||
|
||||
switch (event.TouchInput.Event)
|
||||
{
|
||||
case ETIE_PRESSED_DOWN:
|
||||
{
|
||||
// We only work with the first for now.
|
||||
// We only work with the first for now.force opengl error
|
||||
if ( TouchID == -1 )
|
||||
{
|
||||
fakeMouseEvent.MouseInput.Event = EMIE_LMOUSE_PRESSED_DOWN;
|
||||
|
||||
|
||||
if (Device)
|
||||
{
|
||||
position2d<s32> touchPoint(event.TouchInput.X, event.TouchInput.Y);
|
||||
|
@ -93,7 +93,7 @@ public:
|
|||
|
||||
if ( SpriteToMove && TouchID == event.TouchInput.ID )
|
||||
{
|
||||
|
||||
|
||||
position2d<s32> touchPoint(event.TouchInput.X, event.TouchInput.Y);
|
||||
MoveSprite(touchPoint);
|
||||
}
|
||||
|
@ -103,20 +103,20 @@ public:
|
|||
if ( TouchID == event.TouchInput.ID )
|
||||
{
|
||||
fakeMouseEvent.MouseInput.Event = EMIE_LMOUSE_LEFT_UP;
|
||||
|
||||
|
||||
if ( SpriteToMove )
|
||||
{
|
||||
TouchID = -1;
|
||||
position2d<s32> touchPoint(event.TouchInput.X, event.TouchInput.Y);
|
||||
MoveSprite(touchPoint);
|
||||
SpriteToMove = 0;
|
||||
SpriteToMove = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ( fakeMouseEvent.MouseInput.Event != EMIE_COUNT && Device )
|
||||
{
|
||||
Device->postEventFromUser(fakeMouseEvent);
|
||||
|
@ -124,7 +124,7 @@ public:
|
|||
}
|
||||
else if ( event.EventType == EET_GUI_EVENT )
|
||||
{
|
||||
/*
|
||||
/*
|
||||
Show and hide the soft input keyboard when an edit-box get's the focus.
|
||||
*/
|
||||
switch(event.GUIEvent.EventType)
|
||||
|
@ -136,20 +136,20 @@ public:
|
|||
Device->getGUIEnvironment()->setFocus(NULL);
|
||||
android::setSoftInputVisibility(AndroidApp, false);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case EGET_ELEMENT_FOCUS_LOST:
|
||||
if ( event.GUIEvent.Caller->getType() == EGUIET_EDIT_BOX )
|
||||
{
|
||||
/* Unfortunatly this only works on some android devices.
|
||||
/* Unfortunatly this only works on some android devices.
|
||||
On other devices Android passes through touch-input events when the virtual keyboard is clicked while blocking those events in areas where the keyboard isn't.
|
||||
Very likely an Android bug as it only happens in certain cases (like Android Lollipop with landscape mode on MotoG, but also some reports from other devices).
|
||||
Or maybe Irrlicht still does something wrong.
|
||||
Or maybe Irrlicht still does something wrong.
|
||||
Can't figure it out so far - so be warned - with landscape mode you might be better off writing your own keyboard.
|
||||
*/
|
||||
android::setSoftInputVisibility(AndroidApp, false);
|
||||
}
|
||||
break;
|
||||
case EGET_ELEMENT_FOCUSED:
|
||||
break;
|
||||
case EGET_ELEMENT_FOCUSED:
|
||||
if ( event.GUIEvent.Caller->getType() == EGUIET_EDIT_BOX )
|
||||
{
|
||||
android::setSoftInputVisibility(AndroidApp, true);
|
||||
|
@ -159,16 +159,16 @@ public:
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void MoveSprite(const irr::core::position2d<irr::s32> &touchPos)
|
||||
{
|
||||
irr::core::position2d<irr::s32> move(touchPos-TouchStartPos);
|
||||
SpriteToMove->setRelativePosition(SpriteStartRect.UpperLeftCorner + move);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
IrrlichtDevice * Device;
|
||||
android_app* AndroidApp;
|
||||
|
@ -193,7 +193,7 @@ void mainloop( IrrlichtDevice *device, IGUIStaticText * infoText )
|
|||
if (device->isWindowActive())
|
||||
{
|
||||
/*
|
||||
Show FPS and some counters to show which parts of an app run
|
||||
Show FPS and some counters to show which parts of an app run
|
||||
in different app-lifecycle states.
|
||||
*/
|
||||
if ( infoText )
|
||||
|
@ -206,7 +206,7 @@ void mainloop( IrrlichtDevice *device, IGUIStaticText * infoText )
|
|||
str += loop;
|
||||
infoText->setText ( str.c_str() );
|
||||
}
|
||||
|
||||
|
||||
device->getVideoDriver()->beginScene(true, true, SColor(0,100,100,100));
|
||||
device->getSceneManager()->drawAll();
|
||||
device->getGUIEnvironment()->drawAll();
|
||||
|
@ -223,7 +223,7 @@ void android_main(android_app* app)
|
|||
{
|
||||
// Make sure glue isn't stripped.
|
||||
app_dummy();
|
||||
|
||||
|
||||
/*
|
||||
The receiver can already receive system events while createDeviceEx is called.
|
||||
So we create it first.
|
||||
|
@ -234,8 +234,8 @@ void android_main(android_app* app)
|
|||
Create the device.
|
||||
You have currently the choice between 2 drivers:
|
||||
EDT_OGLES1 is basically a opengl fixed function pipeline.
|
||||
EDT_OGLES2 is a shader pipeline. Irrlicht comes with shaders to simulate
|
||||
typical fixed function materials. For this to work the
|
||||
EDT_OGLES2 is a shader pipeline. Irrlicht comes with shaders to simulate
|
||||
typical fixed function materials. For this to work the
|
||||
corresponding shaders from the Irrlicht media/Shaders folder are
|
||||
copied to the application assets folder (done in the Makefile).
|
||||
*/
|
||||
|
@ -253,15 +253,15 @@ void android_main(android_app* app)
|
|||
application or it can fill up that file over time.
|
||||
*/
|
||||
#ifndef _DEBUG
|
||||
param.LoggingLevel = ELL_NONE;
|
||||
#endif
|
||||
|
||||
param.LoggingLevel = ELL_NONE;
|
||||
#endif
|
||||
|
||||
IrrlichtDevice *device = createDeviceEx(param);
|
||||
if (device == 0)
|
||||
return;
|
||||
|
||||
|
||||
receiver.Init(device);
|
||||
|
||||
|
||||
// ANativeActivity_setWindowFlags(app->activity, AWINDOW_FLAG_FULLSCREEN, 0);
|
||||
|
||||
IVideoDriver* driver = device->getVideoDriver();
|
||||
|
@ -269,7 +269,7 @@ void android_main(android_app* app)
|
|||
IGUIEnvironment* guienv = device->getGUIEnvironment();
|
||||
ILogger* logger = device->getLogger();
|
||||
IFileSystem * fs = device->getFileSystem();
|
||||
|
||||
|
||||
/* Access to the Android native window. You often need this when accessing NDK functions like we are doing here.
|
||||
Note that windowWidth/windowHeight have already subtracted things like the taskbar which your device might have,
|
||||
so you get the real size of your render-window.
|
||||
|
@ -277,7 +277,7 @@ void android_main(android_app* app)
|
|||
ANativeWindow* nativeWindow = static_cast<ANativeWindow*>(driver->getExposedVideoData().OGLESAndroid.Window);
|
||||
int32_t windowWidth = ANativeWindow_getWidth(app->window);
|
||||
int32_t windowHeight = ANativeWindow_getHeight(app->window);
|
||||
|
||||
|
||||
/* Get display metrics. We are accessing the Java functions of the JVM directly in this case as there is no NDK function for that yet.
|
||||
Checkout android_tools.cpp if you want to know how that is done. */
|
||||
irr::android::SDisplayMetrics displayMetrics;
|
||||
|
@ -285,7 +285,7 @@ void android_main(android_app* app)
|
|||
irr::android::getDisplayMetrics(app, displayMetrics);
|
||||
|
||||
/* For troubleshooting you can use the Irrlicht logger.
|
||||
The Irrlicht logging messages are send to the Android logging system using the tag "Irrlicht".
|
||||
The Irrlicht logging messages are send to the Android logging system using the tag "Irrlicht".
|
||||
They stay in a file there, so you can check them even after running your app.
|
||||
You can watch them with the command: "adb logcat Irrlicht:V DEBUG:V *:S"
|
||||
This means Irrlicht _V_erbose, debug messages verbose (p.E callstack on crashes) and all other messages _S_ilent.
|
||||
|
@ -295,18 +295,18 @@ void android_main(android_app* app)
|
|||
char strDisplay[1000];
|
||||
sprintf(strDisplay, "Window size:(%d/%d)\nDisplay size:(%d/%d)", windowWidth, windowHeight, displayMetrics.widthPixels, displayMetrics.heightPixels);
|
||||
logger->log(strDisplay);
|
||||
|
||||
|
||||
core::dimension2d<s32> dim(driver->getScreenSize());
|
||||
sprintf(strDisplay, "getScreenSize:(%d/%d)", dim.Width, dim.Height);
|
||||
logger->log(strDisplay);
|
||||
|
||||
|
||||
|
||||
/* Your media must be somewhere inside the assets folder. The assets folder is the root for the file system.
|
||||
This example copies the media in the Android.mk makefile. */
|
||||
stringc mediaPath = "media/";
|
||||
|
||||
|
||||
// The Android assets file-system does not know which sub-directories it has (blame google).
|
||||
// So we have to add all sub-directories in assets manually. Otherwise we could still open the files,
|
||||
// So we have to add all sub-directories in assets manually. Otherwise we could still open the files,
|
||||
// but existFile checks will fail (which are for example needed by getFont).
|
||||
for ( u32 i=0; i < fs->getFileArchiveCount(); ++i )
|
||||
{
|
||||
|
@ -333,7 +333,7 @@ void android_main(android_app* app)
|
|||
IGUIStaticText *text = guienv->addStaticText(stringw(displayMetrics.xdpi).c_str(),
|
||||
rect<s32>(5,5,635,35), false, false, 0, GUI_INFO_FPS );
|
||||
guienv->addEditBox( L"", rect<s32>(5,40,475,80));
|
||||
|
||||
|
||||
// add irrlicht logo
|
||||
IGUIImage * logo = guienv->addImage(driver->getTexture(mediaPath + "irrlichtlogo3.png"),
|
||||
core::position2d<s32>(5,85), true, 0, GUI_IRR_LOGO);
|
||||
|
@ -350,10 +350,10 @@ void android_main(android_app* app)
|
|||
logo->setRelativePosition(logoPos);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
Add a 3d model. Note that you might need to add light when using other models.
|
||||
A copy of the model and it's textures must be inside the assets folder to be installed to Android.
|
||||
In this example we do copy it to the assets folder in the Makefile jni/Android.mk
|
||||
In this example we do copy it to the assets folder in the Makefile jni/Android.mk
|
||||
*/
|
||||
IAnimatedMesh* mesh = smgr->getMesh(mediaPath + "dwarf.x");
|
||||
if (!mesh)
|
||||
|
@ -374,7 +374,7 @@ void android_main(android_app* app)
|
|||
Mainloop. Applications usually never quit themself in Android. The OS is responsible for that.
|
||||
*/
|
||||
mainloop(device, text);
|
||||
|
||||
|
||||
/* Cleanup */
|
||||
device->setEventReceiver(0);
|
||||
device->closeDevice();
|
||||
|
|
|
@ -163,7 +163,7 @@ COGLES2Driver::~COGLES2Driver()
|
|||
// This fixes problems with intermediate changes to the material during texture load.
|
||||
ResetRenderStates = true;
|
||||
|
||||
testGLError();
|
||||
testGLError(__LINE__);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -509,7 +509,7 @@ COGLES2Driver::~COGLES2Driver()
|
|||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
return (!testGLError());
|
||||
return (!testGLError(__LINE__));
|
||||
}
|
||||
|
||||
|
||||
|
@ -574,7 +574,7 @@ COGLES2Driver::~COGLES2Driver()
|
|||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
|
||||
return (!testGLError());
|
||||
return (!testGLError(__LINE__));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1095,7 +1095,7 @@ COGLES2Driver::~COGLES2Driver()
|
|||
if (clipRect)
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
|
||||
testGLError();
|
||||
testGLError(__LINE__);
|
||||
}
|
||||
|
||||
void COGLES2Driver::draw2DImage(const video::ITexture* texture, u32 layer, bool flip)
|
||||
|
@ -1395,7 +1395,7 @@ COGLES2Driver::~COGLES2Driver()
|
|||
if (clipRect)
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
|
||||
testGLError();
|
||||
testGLError(__LINE__);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1587,7 +1587,7 @@ COGLES2Driver::~COGLES2Driver()
|
|||
}
|
||||
|
||||
//! prints error if an error happened.
|
||||
bool COGLES2Driver::testGLError()
|
||||
bool COGLES2Driver::testGLError(int code)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
GLenum g = glGetError();
|
||||
|
@ -1596,16 +1596,16 @@ COGLES2Driver::~COGLES2Driver()
|
|||
case GL_NO_ERROR:
|
||||
return false;
|
||||
case GL_INVALID_ENUM:
|
||||
os::Printer::log("GL_INVALID_ENUM", ELL_ERROR);
|
||||
os::Printer::log("GL_INVALID_ENUM", core::stringc(code).c_str(), ELL_ERROR);
|
||||
break;
|
||||
case GL_INVALID_VALUE:
|
||||
os::Printer::log("GL_INVALID_VALUE", ELL_ERROR);
|
||||
os::Printer::log("GL_INVALID_VALUE", core::stringc(code).c_str(), ELL_ERROR);
|
||||
break;
|
||||
case GL_INVALID_OPERATION:
|
||||
os::Printer::log("GL_INVALID_OPERATION", ELL_ERROR);
|
||||
os::Printer::log("GL_INVALID_OPERATION", core::stringc(code).c_str(), ELL_ERROR);
|
||||
break;
|
||||
case GL_OUT_OF_MEMORY:
|
||||
os::Printer::log("GL_OUT_OF_MEMORY", ELL_ERROR);
|
||||
os::Printer::log("GL_OUT_OF_MEMORY", core::stringc(code).c_str(), ELL_ERROR);
|
||||
break;
|
||||
};
|
||||
return true;
|
||||
|
@ -2526,7 +2526,7 @@ COGLES2Driver::~COGLES2Driver()
|
|||
}
|
||||
|
||||
glReadPixels(0, 0, ScreenSize.Width, ScreenSize.Height, internalformat, type, pixels);
|
||||
testGLError();
|
||||
testGLError(__LINE__);
|
||||
|
||||
// opengl images are horizontally flipped, so we have to fix that here.
|
||||
const s32 pitch = newImage->getPitch();
|
||||
|
@ -2542,12 +2542,12 @@ COGLES2Driver::~COGLES2Driver()
|
|||
}
|
||||
delete [] tmpBuffer;
|
||||
|
||||
if (testGLError())
|
||||
if (testGLError(__LINE__))
|
||||
{
|
||||
newImage->drop();
|
||||
return 0;
|
||||
}
|
||||
testGLError();
|
||||
testGLError(__LINE__);
|
||||
return newImage;
|
||||
}
|
||||
|
||||
|
|
|
@ -279,8 +279,8 @@ namespace video
|
|||
//! Returns an image created from the last rendered frame.
|
||||
virtual IImage* createScreenShot(video::ECOLOR_FORMAT format=video::ECF_UNKNOWN, video::E_RENDER_TARGET target=video::ERT_FRAME_BUFFER) _IRR_OVERRIDE_;
|
||||
|
||||
//! checks if an OpenGL error has happened and prints it
|
||||
bool testGLError();
|
||||
//! checks if an OpenGL error has happened and prints it (+ some internal code which is usually the line number)
|
||||
bool testGLError(int code=0);
|
||||
|
||||
//! checks if an OGLES1 error has happened and prints it
|
||||
bool testEGLError();
|
||||
|
|
|
@ -150,7 +150,7 @@ bool COGLES1Driver::genericDriverInit(const core::dimension2d<u32>& screenSize,
|
|||
// This fixes problems with intermediate changes to the material during texture load.
|
||||
ResetRenderStates = true;
|
||||
|
||||
testGLError();
|
||||
testGLError(__LINE__);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ bool COGLES1Driver::updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer)
|
|||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
return (!testGLError());
|
||||
return (!testGLError(__LINE__));
|
||||
}
|
||||
|
||||
|
||||
|
@ -418,7 +418,7 @@ bool COGLES1Driver::updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer)
|
|||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
|
||||
return (!testGLError());
|
||||
return (!testGLError(__LINE__));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1437,7 +1437,7 @@ void COGLES1Driver::setMaterial(const SMaterial& material)
|
|||
|
||||
|
||||
//! prints error if an error happened.
|
||||
bool COGLES1Driver::testGLError()
|
||||
bool COGLES1Driver::testGLError(int code)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
GLenum g = glGetError();
|
||||
|
@ -1446,17 +1446,17 @@ bool COGLES1Driver::testGLError()
|
|||
case GL_NO_ERROR:
|
||||
return false;
|
||||
case GL_INVALID_ENUM:
|
||||
os::Printer::log("GL_INVALID_ENUM", ELL_ERROR); break;
|
||||
os::Printer::log("GL_INVALID_ENUM", core::stringc(code).c_str(), ELL_ERROR); break;
|
||||
case GL_INVALID_VALUE:
|
||||
os::Printer::log("GL_INVALID_VALUE", ELL_ERROR); break;
|
||||
os::Printer::log("GL_INVALID_VALUE", core::stringc(code).c_str(), ELL_ERROR); break;
|
||||
case GL_INVALID_OPERATION:
|
||||
os::Printer::log("GL_INVALID_OPERATION", ELL_ERROR); break;
|
||||
os::Printer::log("GL_INVALID_OPERATION", core::stringc(code).c_str(), ELL_ERROR); break;
|
||||
case GL_STACK_OVERFLOW:
|
||||
os::Printer::log("GL_STACK_OVERFLOW", ELL_ERROR); break;
|
||||
os::Printer::log("GL_STACK_OVERFLOW", core::stringc(code).c_str(), ELL_ERROR); break;
|
||||
case GL_STACK_UNDERFLOW:
|
||||
os::Printer::log("GL_STACK_UNDERFLOW", ELL_ERROR); break;
|
||||
os::Printer::log("GL_STACK_UNDERFLOW", core::stringc(code).c_str(), ELL_ERROR); break;
|
||||
case GL_OUT_OF_MEMORY:
|
||||
os::Printer::log("GL_OUT_OF_MEMORY", ELL_ERROR); break;
|
||||
os::Printer::log("GL_OUT_OF_MEMORY", core::stringc(code).c_str(), ELL_ERROR); break;
|
||||
};
|
||||
// _IRR_DEBUG_BREAK_IF(true);
|
||||
return true;
|
||||
|
@ -2889,7 +2889,7 @@ IImage* COGLES1Driver::createScreenShot(video::ECOLOR_FORMAT format, video::E_RE
|
|||
}
|
||||
delete [] tmpBuffer;
|
||||
|
||||
if (testGLError())
|
||||
if (testGLError(__LINE__))
|
||||
{
|
||||
newImage->drop();
|
||||
return 0;
|
||||
|
|
|
@ -262,8 +262,8 @@ namespace video
|
|||
//! Returns an image created from the last rendered frame.
|
||||
virtual IImage* createScreenShot(video::ECOLOR_FORMAT format=video::ECF_UNKNOWN, video::E_RENDER_TARGET target=video::ERT_FRAME_BUFFER) _IRR_OVERRIDE_;
|
||||
|
||||
//! checks if an OpenGL error has happened and prints it
|
||||
bool testGLError();
|
||||
//! checks if an OpenGL error has happened and prints it (+ some internal code which is usually the line number)
|
||||
bool testGLError(int code=0);
|
||||
|
||||
//! Set/unset a clipping plane.
|
||||
virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false) _IRR_OVERRIDE_;
|
||||
|
|
Loading…
Reference in New Issue