对于Windows,Mac和iOS,以下代码编译时没有警告:
class MyClass {
SomeOtherClass * m_object;
void (SomeOtherClass::*m_callback)();
public:
MyClass(SomeOtherClass * _object,void (SomeOtherClass::*_callback)()=NULL) :
m_object(_object),m_callback(_callback) {}
void DoStuff() {
//generates warning: NULL used in arithmetic when compiling with the Android NDK
if (NULL==m_callback) {
m_object->DoNormalCallback();
} else {
(m_object->*m_callback)();
}
}
};
Run Code Online (Sandbox Code Playgroud)
为什么会产生警告,我该怎么办呢?
当我旋转设备并收到我的应用程序时APP_CMD_CONFIG_CHANGED,我尝试使用以下内容更新我的OpenGL视口:
EGLint width;
EGLint height;
eglQuerySurface(display,surface,EGL_WIDTH,&width);
eglQuerySurface(display,surface,EGL_HEIGHT,&height);
glViewport(0,0,width,height);
MY_LOG_MACRO2("New window size: %d x %d",width,height);
Run Code Online (Sandbox Code Playgroud)
这大约占20%的时间.另外80%的时间宽度和高度是先前的值.换句话说,大多数情况下,当我将设备转为横向模式时,会记录纵向尺寸.当我回到肖像时,会记录景观大小.
从ANativeWindow两者中获得尺寸我都没有太多运气.
旋转后,我应该怎么做才能获得正确的窗口尺寸?
更新:
通过等待几帧后APP_CMD_CONFIG_CHANGED,大小始终是正确的.每帧都查询大小而不考虑APP_CMD_CONFIG_CHANGED,并检查它是否已经改变似乎也能正常工作但感觉不对.
以下两行在Visual Studio 2005中执行相同的操作:
myString.insert(myString.size(),1,myNewChar);
Run Code Online (Sandbox Code Playgroud)
和
myString.append(1,myNewChar);
Run Code Online (Sandbox Code Playgroud)
是第一个应该抛出out_of_range异常还是这是正确的行为?
有没有办法从UIAlertView获取NSAlert runModal行为?或者从UIActionSheet?
我打算只在调试版本中使用,所以我不关心它的外观或是否使用未记录的功能.
编辑:
NSAlert是OS X SDK的一部分,类似于Win32中的MessageBox.它允许您同步提示用户输入某些内容.这是一个例子:
NSAlert * myAlert=[[NSAlert alloc] init];
[myAlert setMessgeText:@"This is my alert"];
[myAlert addButtonWithTitle:@"button 1"];
[myAlert addButtonWithTitle:@"button 2"];
switch ([myAlert runModal]) {
case NSAlertFirstButtonReturn:
//handle first button
break;
case NSAlertSecondButtonReturn:
//handle second button
break;
}
Run Code Online (Sandbox Code Playgroud)
runModal是一个同步函数,它显示警报并等待用户响应.在内部,它正在运行一个有限版本的消息循环,但就我的应用程序的其余部分而言,世界已经停止; 没有消息,没有事件,没有.
当我打开DirectX控制面板并打开Direct3D 9选项卡并设置“使用Direct3D 9的调试版本”并单击“确定”或“应用”时,没有错误。如果再次打开控制面板,它将返回到“使用Direct3D 9的零售版”。尝试调试应用程序时,没有从Direct3D获得任何输出。
几个月前我上一次这样做时,一切正常,并且得到了调试输出。
以管理员身份运行控制面板似乎没有什么不同,这里提到的注册表项http://www.gamedev.net/topic/514529-cant-use-debug-version-of-direct3d/设置为一个。
我还能尝试什么?
我正在使用此代码启动我的程序
int _tmain(int argc, _TCHAR* argv[])
{
STARTUPINFO cif;
ZeroMemory(&cif,sizeof(STARTUPINFO));
PROCESS_INFORMATION pi;
if (CreateProcess(L"C:\\test\\test.exe",NULL,
NULL,NULL,FALSE,CREATE_UNICODE_ENVIRONMENT,NULL,NULL,&cif,&pi)==TRUE)
{
cout << "process" << endl;
cout << "handle " << pi.hProcess << endl;
}
system("pause");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
程序正常启动,但立即失败(没有响应并失败).CreateProcess返回true.当我从代码启动test.exe时,它可以正常工作.
c++ ×3
android-ndk ×2
debugging ×1
directx ×1
directx-9 ×1
ios ×1
opengl-es ×1
uialertview ×1
winapi ×1