将uint传递给着色器会更改其值(Passing a uint to shader changes its value)
我试图将一个uint传递给我的着色器,但我必须做错了,因为在着色器中值为3212836864而不是4294967295。
我有一个Vertex数组,我存储每个顶点,然后使用
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vertex) * 4 * vertexBufferArrayInserts, vertexBufferArray);
将它们发送到着色器glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vertex) * 4 * vertexBufferArrayInserts, vertexBufferArray);
这些是我的
glVertexAttribPointer
调用:shaderPosAttrib = glGetAttribLocation(shaderProgram, "position"); glVertexAttribPointer(shaderPosAttrib, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, position)); glEnableVertexAttribArray(shaderPosAttrib); shaderTexCoordAttrib = glGetAttribLocation(shaderProgram, "texCoord"); glVertexAttribPointer(shaderTexCoordAttrib, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, texCoords)); glEnableVertexAttribArray(shaderTexCoordAttrib); shaderColorAttrib = glGetAttribLocation(shaderProgram, "color"); glVertexAttribPointer(shaderColorAttrib, 1, GL_UNSIGNED_INT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, color)); glEnableVertexAttribArray(shaderColorAttrib);
这是Vertex结构
struct Vertex { Vector2<GLfloat> position; Vector2<GLfloat> texCoords; GLuint color; Vertex() { } Vertex(Vector2<GLfloat> position, Vector2<GLfloat> texCoords, GLuint color) { this->position = position; this->texCoords = texCoords; this->color = color; } };
顶点着色器:
#version 150 in vec2 position; in vec2 texCoord; in uint color; out vec2 TexCoord; out uint Color; uniform mat4 projMat; void main() { TexCoord = texCoord; Color = color; gl_Position = projMat * vec4(position, 0.0, 1.0); }
片段着色器:
#version 150 in vec2 TexCoord; in uint Color; out vec4 outColor; uniform sampler2D tex; void main() { float colorr = 0; if(Color == 3212836864) colorr = 1; outColor = texture(tex, TexCoord) * vec4(colorr, colorr, colorr, 1.0); }
显然我在某处做错了但我却看不到它...非常感谢帮助!
I'm trying to pass a uint to my shader but I must be doing something wrong because in the shader the value is 3212836864 and not 4294967295.
I have a Vertex array that I store each vertex in before sending them to the shader using
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vertex) * 4 * vertexBufferArrayInserts, vertexBufferArray);
These are my
glVertexAttribPointer
calls:shaderPosAttrib = glGetAttribLocation(shaderProgram, "position"); glVertexAttribPointer(shaderPosAttrib, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, position)); glEnableVertexAttribArray(shaderPosAttrib); shaderTexCoordAttrib = glGetAttribLocation(shaderProgram, "texCoord"); glVertexAttribPointer(shaderTexCoordAttrib, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, texCoords)); glEnableVertexAttribArray(shaderTexCoordAttrib); shaderColorAttrib = glGetAttribLocation(shaderProgram, "color"); glVertexAttribPointer(shaderColorAttrib, 1, GL_UNSIGNED_INT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, color)); glEnableVertexAttribArray(shaderColorAttrib);
And this is the Vertex struct
struct Vertex { Vector2<GLfloat> position; Vector2<GLfloat> texCoords; GLuint color; Vertex() { } Vertex(Vector2<GLfloat> position, Vector2<GLfloat> texCoords, GLuint color) { this->position = position; this->texCoords = texCoords; this->color = color; } };
Vertex shader:
#version 150 in vec2 position; in vec2 texCoord; in uint color; out vec2 TexCoord; out uint Color; uniform mat4 projMat; void main() { TexCoord = texCoord; Color = color; gl_Position = projMat * vec4(position, 0.0, 1.0); }
Fragment shader:
#version 150 in vec2 TexCoord; in uint Color; out vec4 outColor; uniform sampler2D tex; void main() { float colorr = 0; if(Color == 3212836864) colorr = 1; outColor = texture(tex, TexCoord) * vec4(colorr, colorr, colorr, 1.0); }
Obviously I'm doing something wrong somewhere but I just can't see it... Help is very much appreciated!
原文:https://stackoverflow.com/questions/17260493
最满意答案
您可能希望重新考虑日期时间字段上的分组,如果您希望它与第二个字段区分开来; 多个记录共享完全相同的日期时间字段的可能性通常非常低,否定了分组的有用性。
出于这个原因,CR可能已经冒昧地假设您只想按日期而不是完整的日期时间值进行分组。 您可以通过执行以下步骤进行检查:从CR工具栏中选择“报告”→“组专家”→在右侧选择您的组并点击“选项”→在“公共”选项卡底部会有一个标有下拉列表的下拉列表“该部分将被打印”。 验证它是否显示“For each second”而不是“For each day”或其他值。
从这里开始,您可以控制希望CR为您的日期时间值分组的网络的大小。
You may want to rethink grouping on a datetime field if you want it distinct down to the second; the chance that multiple records share the exact same datetime field are usually extremely low, negating the usefulness of grouping.
For this reason, CR may have taken the liberty of assuming you only wanted to group by the date instead of the full datetime value. You can check by performing the following steps: Select "Report" from the CR toolbar → "Group Expert" → Select your group on the right and hit "Options" → At the bottom of the "Common" tab there will be a dropdown labeled "The section will be printed". Verify that it says "For each second" instead of "For each day" or some other value.
It's from here that you can control how small or large of a net you want CR to group for your datetime values.
相关问答
更多-
水晶报告中的日期格式(date format in crystal reports)[2024-04-12]
这是你应该做的 SELECT * FROM clock_time WHERE DATE_FORMAT(clock_time,'%d/%m/%Y %H:%i')='10/09/2014 11:17'; this is what you should do SELECT * FROM clock_time WHERE DATE_FORMAT(clock_time,'%d/%m/%Y %H:%i')='10/09/2014 11:17'; -
如何仅将日期时间类型的日期显示为datetime对象(How to display date only from datetime type into datetime object)[2021-10-30]
像这样使用 string[] strArray = new string[] { "Mahesh Chand", "Mike Gold", "Raj Beniwal", "Praveen Kumar", "7/10/1974 7:10:24 AM" }; DateTime dateFromString = Convert.ToDateTime(strArray[4]); string dt= DateTime.ParseExact(dateTimeString, "dd/M ... -
请尝试: IF {TBM_Report_qry.DiF}<={TBM_Report_qry.tbm} then RGB(234,234,234) else ( IF {TBM_Report_qry.inproduction_DiF}<={TBM_Report_qry.Reqired} then RGB(234,234,234) else ( IF {TBM_Report_qry.DiF_Close}<={TBM_Report_qry.clse_Diff} ...
-
你在代码中出错了,试试这个 if (ReportName == "Bill Receipt") { Report.RecordSelectionFormula = String.Format("{0} = {1} AND {2}={3} ", "{BILLH.Bh_no}", BillNo, "{BILL.B_no}", BillNo); } you are going wrong in code ,try this if ...
-
仅显示日期和时间(Display only date and no time)[2021-11-10]
如果列类型是SQL中的DateTime,那么它将存储一个或多个通过的时间。 最好保存日期正确: model.ReturnDate = DateTime.Now; 然后在需要显示时格式化它: @Html.Label(Model.ReturnDate.ToShortDateString()) 或者如果您使用EditorFor: @Html.EditorFor(model => model.ReturnDate.ToShortDateString()) 要么 @Html.EditorFor(model => ... -
我认为最好的方法就是转换数据服务器端,只是返回你想要的日期格式,但你也可以 { "aTargets": [3], "bSearchable": false, "sType": 'date', "fnRender": function ( oObj ) { var javascriptDate = new Date(oObj.aData[0]); javascriptDate = javascriptDate.getDate()+ ...
-
水晶报告参数不正确(crystal report parameter incorrect)[2023-10-03]
如果您有部分代码,请更改 ReportDocument rDoc = new ReportDocument()) 就像你在其他部分一样 I can solved this by add new CrystalReportViewer control protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { if (rd.SelectedValue == "1") ... -
您可以将列的类型更改为Date如下所示: ALTER TABLE YOURTable ALTER COLUMN YOURCOLUMN DATE; 那么你不需要转换它。 或者你可以在水晶报告中使用日期值函数,例如: DateValue({myTable.strDate}) You can change the type of your column to Date as folow : ALTER TABLE YOURTable ALTER COLUMN YOURCOLUMN DATE; Then ...
-
您可能希望重新考虑日期时间字段上的分组,如果您希望它与第二个字段区分开来; 多个记录共享完全相同的日期时间字段的可能性通常非常低,否定了分组的有用性。 出于这个原因,CR可能已经冒昧地假设您只想按日期而不是完整的日期时间值进行分组。 您可以通过执行以下步骤进行检查:从CR工具栏中选择“报告”→“组专家”→在右侧选择您的组并点击“选项”→在“公共”选项卡底部会有一个标有下拉列表的下拉列表“该部分将被打印”。 验证它是否显示“For each second”而不是“For each day”或其他值。 从这里开 ...
-
如何在Crystal Reports中显示当前的日期和时间?(How do you display the current date and time in Crystal Reports?)[2023-10-18]
创建一个新公式并使用: CurrentDateTime 这将显示以下内容: 18.05.2015 2:28:46 PM 然后你可以使用ToText格式化它: ToText(CurrentDateTime, "dd/MM/yyyy HH:mm:ss") 哪个会显示(与第一个例子的日期时间相同): 18/05/2015 14:28:46 Create a new formula and use: CurrentDateTime This would display the following: 18.05 ...