English 中文(简体)
如何使用GLKMatrixStack?
原标题:How to use GLKMatrixStack?

我写了一条横跨屏幕的太阳游戏,但我对定位ube有问题。

页: 1 带一英寸:

void draw_voxel(Point location, Color color, GLKMatrixStackRef stack) {
  GLKMatrixStackPush(stack);
  GLKMatrixStackTranslate(stack, location.x, location.y, location.z);

  std::array<Color, 36> triangle_colors;
  triangle_colors.fill(color);

  glEnableVertexAttribArray(GLKVertexAttribPosition);
  glVertexAttribPointer(GLKVertexAttribPosition, 3, GL_FLOAT, GL_FALSE, 0, static_cast<const GLvoid*>(triangle_vertices.data()));
  glEnableVertexAttribArray(GLKVertexAttribColor);
  glVertexAttribPointer(GLKVertexAttribColor, 4, GL_FLOAT, GL_FALSE, 0, static_cast<const GLvoid*>(triangle_colors.data()));
  glDrawArrays(GL_TRIANGLES, 0, 36);
  glDisableVertexAttribArray(GLKVertexAttribPosition);
  glDisableVertexAttribArray(GLKVertexAttribColor);

  GLKMatrixStackPop(stack);
}

我通过一个<代码>GLKMatrixStackRef,将目前的矩阵推向上并使用<代码>GLKMatrixStack Translate,以翻译最高矩阵。 然而,所有河流仍在(0、0、0)。

页: 1 类似:

[self.effect prepareToDraw];

GLKMatrixStackRef stack = GLKMatrixStackCreate(nullptr);
draw_voxel(Point(-1.0f, 0.0f, 0.0f), Color(1.0f, 0.0f, 0.0f, 1.0f), stack);
draw_voxel(Point(+0.0f, 0.0f, 0.0f), Color(0.0f, 1.0f, 0.0f, 1.0f), stack);
draw_voxel(Point(+1.0f, 0.0f, 0.0f), Color(0.0f, 0.0f, 1.0f, 1.0f), stack);
CFRelease(stack);

我无法在互联网上找到任何有用的信息,了解GLKit矩阵的摇篮,我确实 st。 我如何“应用”顶层矩阵,以翻译这些ube子?

最佳回答

While I still haven t fully grasp how to use GLKMatrixStack, looking at your code I think the problem is that you are not passing the top matrix of the stack to the shader, or, in GLKit words, you are not properly configuring the effect. Probably, at some point you should be doing something like:

self.effect.transform.modelviewMatrix = GLKMatrixStackGetMatrix4(stack);

我希望这一帮助,我也站在这个 st子上:

问题回答

暂无回答




相关问题
Asynchronous request to the server from background thread

I ve got the problem when I tried to do asynchronous requests to server from background thread. I ve never got results of those requests. Simple example which shows the problem: @protocol ...

objective-c: Calling a void function from another controller

i have a void, like -(void) doSomething in a specific controller. i can call it in this controller via [self doSomething], but i don t know how to call this void from another .m file. I want to call ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

NSUndoManager and runModalForWindow:

I have a simple Core Data app which displays a list of entities in the main window. To create or add new entities, I use a second modal window with a separate managed object context so changes can be ...

NSMutableArray values becoming "invalid"

I m trying to show a database information in a tableview and then the detailed information in a view my problem is as follow: I created a NSMutableArray: NSMutableArray *myArray = [[NSMutableArray ...

iPhone numberpad with decimal point

I am writing an iPhone application which requires the user to enter several values that may contain a decimal point (currency values, percentages etc.). The number of decimal places in the values ...

热门标签