English 中文(简体)
利用开放式GL螺ing在C++ 2D中划4D点[复制]
原标题:Using OpenGL shaders to plot 4D points in 2D in C++ [duplicate]
  • 时间:2011-09-28 16:59:40
  •  标签:
  • c++
  • opengl
This question already has answers here:
Closed 11 years ago.

Possible Duplicate:
Visualising 4D objects in OpenGL

我有一套4个层面的数据点(称为X、Y、A和B层面),我想在6个不同的2个地块(XY、XxA、XxB、YxA等)。

在前一个问题 我询问了储存和整理这一数据的适当方式。 解决办法是使用一个VBO,储存4个方面vert。 然后,我可以选择在两块土地的每一块土地上划定哪些层面。

我花了几个星期的时间来研究如何做这项工作,但我却发现一些意思。

我的问题是: 在(c++)中,我如何界定一个使我只能把设在甚远的旅店4个层面中的2个层面划归一的梯子,我是否需要为所有6个2个地块确定一个单一梯子,或者我是否需要为6个不同地块中的每一个块划线?

最后,我如何将斜线纳入阴谋法,以便开放使用。 GL?

最佳回答

由于沙板能够使用4个层面矢量和4x4矩阵,我们只能是聪明才智的,只能使用一个透镜来做trick。 这一方向需要三个投入:

  • the point data (a 4 floating vector),
  • a selection 4x4 matrix,
  • a projection 4x4 matrix.

所有的神.都是通过甄选矩阵进行的,该矩阵将绘制4座标子,以规划坐标。 请打电话到点数据<代码>v、甄选矩阵<代码>S和<代码>P。 脊椎动物的产量如下:

www.un.org/Depts/DGACM/index_spanish.htm

通过正确确定<代码>S的系数,您将能够选择<代码>v中哪一部分内容。 例如,如果你想显示<条码>YxB,则<条码>。 将:

“Smap”/

因此,我们有:

“entergraph

P是标准预测矩阵,将有助于你正确表述你的图表(折合和比额表)。

Following is an example of vertex shader implementation (not tested, may contain mistakes) for OpenGl3:

#version 130

in vec4 vin;
uniform mat4 s;
uniform mat4 p;

out vec4 vout;

void main()
{
    vec4 tmp = s * vin;

    // Depending on your projection matrix,
    // you may force the 4th component to 1.
    tmp[3] = 1;

    vout = p * tmp;
}

Notes: glUniformMatrix4fv is the function to use to define S and P.

问题回答

你们有这种投入:

in vec4 Points;

You can access to vec4 components by indexing them:

Point[0]; // Equals Point.x

您可以提供以下制服,以具体说明用于测绘的哪些组成部分:

uniform int XCoordIndex;
uniform int YCoordIndex;

gl_Position = vec4(Point[XCoordIndex], Point[YCoordIndex], 0.0, 1.0)




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签