小编Rea*_*ion的帖子

OpenGL/Glut按钮和键

我正在学习使用这Pearson, Computer Graphics with OpenGL本书.

我目前正在努力做一个简单的方形移动,但在我超越自己之前,我需要确定我理解Glut中内置了哪些键.

我知道以下键:

  • GLUT_KEY_F1, GLUT_KEY_F2, ..., GLUT_KEY_F12 - F1至F12键
  • GLUT_KEY_PAGE_UP, GLUT_KEY_PAGE_DOWN - Page Up和Page Down键
  • GLUT_KEY_HOME, GLUT_KEY_END - 家庭和结束键
  • GLUT_KEY_LEFT, GLUT_KEY_RIGHT, GLUT_KEY_UP, GLUT_KEY_DOWN - 方向键
  • GLUT_KEY_INSERT - 插入键

我要么在我的书中找到它们,要么在另一篇文章中的Stackoverflow上找到它们.

但还有吗?例如,对于键盘和鼠标上的所有键?

谢谢.

c++ keyboard glut input

4
推荐指数
2
解决办法
2万
查看次数

Matlab - Double类型的输入参数的未定义错误

我想写做什么的功能conv2(h1,h2,A)conv2(...'shape')确实不使用内置的功能.(速度目前不是问题).如下定义:http://www.mathworks.co.uk/help/matlab/ref/conv2.html

这些是我的命令:

    imgC = imread('camerman.tif');
    imgC = double(imgC);

    sigma = 1;
    inp = (-1 .*2.5 .*sigma):1:(2.5 .* sigma);                                  
    gauss1d = (1/(sigma .* sqrt(2*pi))).*exp(-(inp.^2/(2.*sigma.*sigma)));      
    gaussprime = diff(gauss1d);       

    x = conv2fft(gaussprime,1,imgC , 'same');   
    y = conv2fft(1,gaussprime.',imgC , 'same'); 
    blur = conv2fft (gauss1d, gauss1d, imgC );
Run Code Online (Sandbox Code Playgroud)

这是我的错误:

    Undefined function 'convfft' for input arguments of type 'double'.
    Error in conv2fft (line 81) `if size(convfft(a(1,:),r),1)==1`
Run Code Online (Sandbox Code Playgroud)

如果我运行相同的命令但使用该conv2功能:

    imgC = imread('camerman.tif');
    imgC = double(imgC);

    sigma = 1;
    inp …
Run Code Online (Sandbox Code Playgroud)

double matlab runtime-error undefined

3
推荐指数
1
解决办法
6万
查看次数

AppStore 短 URL - 开发人员单一 URL

我一直在阅读一些关于缩短 App Store URL 的文章,因此您可以喜欢:AppStore.com/MyAppOrMyCompanyName

我在这里发现了这种类型的 url ,并且有几种方法可以直接在旧版 iOS 中链接到开发页面...

我希望使用Appstore.com/orappsto.re/方案使 URL 看起来更好、更具可读性,并删除 safari 的重定向并从我的社交媒体(以及在我的游戏中按按钮)。

这里有一些关于缩短 URL 的讨论,但我不知道如何将其用于开发人员页面(因此它显示所有应用程序)而不是单个应用程序。

我在哪里可以找到这个/如何获得我的公司网址?

url itunes app-store ios

3
推荐指数
1
解决办法
3885
查看次数

UIAlertController 自 iOS 13 起消失

我有以下功能会弹出一个 UIAlert,允许用户更新他们的触觉反馈设置:

- (void)requestHapticSetting{
    UIWindow *alertWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    alertWindow.rootViewController = [[UIViewController alloc] init];
    alertWindow.windowLevel = UIWindowLevelAlert + 1;
    [alertWindow makeKeyAndVisible];

    if(isHapticOn){
        hapticMessage = @"Haptic feedback is currently\nturned ON.\nPlease update preference.";
    }
    else {
        hapticMessage = @"Haptic feedback is currently\nturned OFF.\nPlease update preference.";
    }

    UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Haptic Setting"
                                                                   message:hapticMessage
                                                            preferredStyle:UIAlertControllerStyleAlert];

    UIAlertAction* onAction = [UIAlertAction actionWithTitle:@"TURN ON" style:UIAlertActionStyleDefault
                                                     handler:^(UIAlertAction * action) {
                                                         [self saveHapticSettingOn];
                                                     }];

    UIAlertAction* offAction = [UIAlertAction actionWithTitle:@"TURN OFF" style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction * action) {
                                                          [self …
Run Code Online (Sandbox Code Playgroud)

objective-c uialertview uialertcontroller ios13

3
推荐指数
1
解决办法
4101
查看次数

Xcode - 实现一个方法,也可以由它的主类实现

我正在使用Xcode 4.5.在我最新的Xcode项目中,当我构建/编译我的程序时,我会弹出这个警告:

Category is implementing a method which will also be implemented by its primary class

这是导致错误的代码:

 @implementation NSApplication (SDLApplication)
 - (void)terminate:(id)sender {
    SDL_Event event;
    event.type = SDL_QUIT;
    SDL_PushEvent(&event); }
 @end
Run Code Online (Sandbox Code Playgroud)

我已经这样做了,所以编译器忽略(或跳过)使用的警告生成pragma code.

所以我的代码现在看起来像这样:

 @implementation NSApplication (SDLApplication)

 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"
 - (void)terminate:(id)sender{
   SDL_Event event;
   event.type = SDL_QUIT;
   SDL_PushEvent(&event);}
 #pragma clang diagnostic pop
 @end
Run Code Online (Sandbox Code Playgroud)

显然它完成了这项工作,一旦构建/编译,就不会产生任何警告.

我的问题是,这是一种以这种方式抑制或忽略警告的安全/可靠方式吗?

我在一些线程上读到使用子类是有利的,但是有很多人以这种方式反对使用它们...我很感激你的想法:)

objective-c pragma

2
推荐指数
1
解决办法
4467
查看次数

在 3D 空间中使用 GLSL 绘制 2D 网格

我希望使用 OpenGL 4.0 在 X 轴上的有限空间内绘制 2D 网格。

我希望使用 GLSL 使用 vert/frag 着色器等来渲染光线(使它们出现)。

它可以使用较旧的 OpenGL 2.0 方法通过最简单的代码来完成,但当然它不使用照明/着色器来为它们着色:

    void Draw_Grid()
    {
     for(float i = -500; i <= 500; i += 5)
        {
         glBegin(GL_LINES);
            glColor3ub(150, 190, 150);
            glVertex3f(-500, 0, i);
            glVertex3f(500, 0, i);
            glVertex3f(i, 0,-500);
            glVertex3f(i, 0, 500);
         glEnd();
        }
    }
Run Code Online (Sandbox Code Playgroud)

但除了这个教程之外,我找不到任何教程,因为我不太理解这些教程,无法将图形转换为 3D 空间中的简单 2D 网格。

opengl glsl

2
推荐指数
1
解决办法
7716
查看次数

如何输入哈希键?

在 中R,您可以使用 来发表评论#

我在 MacBook Pro 上使用 Windows 8,因此键盘没有指定的#键,并且 Apple 键盘的该#键的快捷方式(即Alt+ 3)不起作用。

macos comments r

2
推荐指数
2
解决办法
2万
查看次数

添加填充到图像 - Matlab

我有一个89x56px大小和RGB 的小图像.

我正在尝试在图像周围添加填充,直到(x,y)都大于64px.

我通过阅读这个问题尝试过这个问题:但没有运气:

  img = subImage{1};              %small image 89x56
  new(size(subImage{1},1),64)=0;  %zero matrix for padding
  size(new);
  merged = img;                   %also tried adding img to new
  imshow(merged)
Run Code Online (Sandbox Code Playgroud)

理想情况下,我甚至想要填充图像的每一面.例如64 - 56 = 8; 所以每侧有4列0(如果太难,则只有8列.)

任何帮助将是欣赏.提前致谢.

matlab padding

2
推荐指数
1
解决办法
2520
查看次数

在GameScene中显示UIAlertController(SpriteKit/Swift)

在swift中显示UIAlertView的简单方法是:

let alert = UIAlertView()
alert.title = "Alert!"
alert.message = "A wise message"
alert.addButtonWithTitle("Ok, thank you")
alert.show()
Run Code Online (Sandbox Code Playgroud)

但现在这在iOS 9中已经过折旧,建议使用UIAlertController:

let myAlert: UIAlertController = UIAlertController(title: "Alert!", message: "Oh! Fancy", preferredStyle: .Alert)
myAlert.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil))
self.presentViewController(myAlert, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

哪个好,但我在使用SpriteKit并在GameScene中,这给出了一个错误Value of type 'GameScene' has no member 'presentViewController'...

我是否需要切换回我的ViewController来呈现这个或者有没有办法从GameScene中调用它.

我找到了这个答案,但它是Objective-C.

uialertview ios sprite-kit swift uialertcontroller

2
推荐指数
1
解决办法
3614
查看次数

淡入和淡出SKLabelNodes的最佳方法

我正在做一个小的SpriteKit游戏。

我在主屏幕上有一个“提示”部分,我想输入和输出,每次显示不同的提示。

我写了一个自己写的方法,但是它很杂乱,我相信有更好的方法可以完成。我希望有人可以向我展示一种我可能错过的方式(或者在做某事时走了很长一段路)。

这是我目前的做法:

func createTipsLabels(){
    //create SKLabelNodes
    //add properties to Labels

    //tip1Label... etc
    //tip2Label... etc
    //tip3Label... etc

    //now animate (or pulse) in tips label, one at a time...
    let tSeq = SKAction.sequence([
        SKAction.runBlock(self.fadeTip1In),
        SKAction.waitForDuration(5),
        SKAction.runBlock(self.fadeTip1Out),
        SKAction.waitForDuration(2),
        SKAction.runBlock(self.fadeTip2In),
        SKAction.waitForDuration(5),
        SKAction.runBlock(self.fadeTip2Out),
        SKAction.waitForDuration(2),
        SKAction.runBlock(self.fadeTip3In),
        SKAction.waitForDuration(5),
        SKAction.runBlock(self.fadeTip3Out),
        SKAction.waitForDuration(2),
    ])

    runAction(SKAction.repeatActionForever(tSeq))  //...the repeat forever

}

//put in separate methods to allow to be called in runBlocks above
func fadeTip1In() { tip1Label.alpha = 0; tip1Label.runAction(SKAction.fadeInWithDuration(1)) ;  print("1") }
func fadeTip1Out(){ tip1Label.alpha = 1; tip1Label.runAction(SKAction.fadeOutWithDuration(1));  print("2") …
Run Code Online (Sandbox Code Playgroud)

optimization sprite-kit sklabelnode swift

2
推荐指数
1
解决办法
550
查看次数