Nux

Merge lp:~unity-team/nux/nux.fix-839476 into lp:nux/2.0

Proposed by Mirco Müller
Status: Rejected
Rejected by: Mirco Müller
Proposed branch: lp:~unity-team/nux/nux.fix-839476
Merge into: lp:nux/2.0
Diff against target: 409 lines (+316/-1)
4 files modified
NuxGraphics/GraphicsEngine.h (+43/-1)
NuxGraphics/RenderingPipe.cpp (+22/-0)
NuxGraphics/RenderingPipeAsm.cpp (+112/-0)
NuxGraphics/RenderingPipeGLSL.cpp (+139/-0)
To merge this branch: bzr merge lp:~unity-team/nux/nux.fix-839476
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+94577@code.launchpad.net

Description of the change

Added an rendering-method to allow masking out portions of an image-texture using the alpha-channel of a second texture. Both textures can be modulated by a color if needed.

To post a comment you must log in.
lp:~unity-team/nux/nux.fix-839476 updated
585. By Jay Taoko

* Fix to QRP_TexMaskTexAlpha shader in GLSL.

586. By Mirco Müller

Re-merge with nux trunk

587. By Mirco Müller

Needed to update a vertex- and fragment-program definition

Revision history for this message
Mirco Müller (macslow) wrote :

Marked it as "Rejected" as we don't longer need this. A unity-only solution was found and implemented.

Unmerged revisions

587. By Mirco Müller

Needed to update a vertex- and fragment-program definition

586. By Mirco Müller

Re-merge with nux trunk

585. By Jay Taoko

* Fix to QRP_TexMaskTexAlpha shader in GLSL.

584. By Mirco Müller

Fixed stupid crash because of calling wrong shader-program. Renamed member for masking-shader.

583. By Mirco Müller

Added GLSL- and shader-assembly for QRP_TexMaskTexAlpha()

582. By Mirco Müller

Added a color-parameter to each texture for cases when you want to modulate the image-/alpha-texture

581. By Mirco Müller

Trying to implement new drawing method for rendering an image-textures masked by an alpha-texture

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NuxGraphics/GraphicsEngine.h'
2--- NuxGraphics/GraphicsEngine.h 2012-03-13 02:50:57 +0000
3+++ NuxGraphics/GraphicsEngine.h 2012-03-27 15:45:29 +0000
4@@ -194,6 +194,14 @@
5 void QRP_ColorModTexAlpha(int x, int y, int width, int height,
6 ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm& texxform0, const Color& color);
7
8+ void QRP_TexMaskTexAlpha (int x, int y, int width, int height,
9+ ObjectPtr<IOpenGLBaseTexture> ImageTexture,
10+ TexCoordXForm& texxformImage,
11+ const Color& colorImage,
12+ ObjectPtr<IOpenGLBaseTexture> AlphaTexture,
13+ TexCoordXForm& texxformAlpha,
14+ const Color& colorAlpha);
15+
16 void QRP_2Tex(int x, int y, int width, int height,
17 ObjectPtr<IOpenGLBaseTexture> DeviceTexture0, TexCoordXForm& texxform0, const Color& color0,
18 ObjectPtr<IOpenGLBaseTexture> DeviceTexture1, TexCoordXForm& texxform1, const Color& color1);
19@@ -267,6 +275,18 @@
20 void QRP_ASM_ColorModTexAlpha(int x, int y, int width, int height,
21 ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm& texxform0, const Color& color);
22
23+ //! Mask a texture with another texture's alpha.
24+ void QRP_ASM_TexMaskTexAlpha(int x,
25+ int y,
26+ int width,
27+ int height,
28+ ObjectPtr<IOpenGLBaseTexture> imageTexture,
29+ TexCoordXForm& texxformImage,
30+ const Color& colorImage,
31+ ObjectPtr<IOpenGLBaseTexture> alphaTexture,
32+ TexCoordXForm& texxformAlpha,
33+ const Color& colorAlpha);
34+
35 void QRP_ASM_2Tex(int x, int y, int width, int height,
36 ObjectPtr<IOpenGLBaseTexture> DeviceTexture0, TexCoordXForm& texxform0, const Color& color0,
37 ObjectPtr<IOpenGLBaseTexture> DeviceTexture1, TexCoordXForm& texxform1, const Color& color1);
38@@ -385,6 +405,18 @@
39 void QRP_GLSL_Color(int x, int y, int width, int height, const Color& c0, const Color& c1, const Color& c2, const Color& c3);
40 void QRP_GLSL_ColorModTexAlpha(int x, int y, int width, int height,
41 ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm& texxform0, const Color& color);
42+
43+ //! Mask a texture with another texture's alpha.
44+ void QRP_GLSL_TexMaskTexAlpha(int x,
45+ int y,
46+ int width,
47+ int height,
48+ ObjectPtr<IOpenGLBaseTexture> imageTexture,
49+ TexCoordXForm& texxformImage,
50+ const Color& colorImage,
51+ ObjectPtr<IOpenGLBaseTexture> alphaTexture,
52+ TexCoordXForm& texxformAlpha,
53+ const Color& colorAlpha);
54
55 void QRP_GLSL_2Tex(int x, int y, int width, int height,
56 ObjectPtr<IOpenGLBaseTexture> DeviceTexture0, TexCoordXForm& texxform0, const Color& color0,
57@@ -829,6 +861,12 @@
58 ObjectPtr<IOpenGLAsmShaderProgram> m_AsmColorModTexMaskAlpha;
59 ObjectPtr<IOpenGLAsmShaderProgram> m_AsmColorModTexRectMaskAlpha;
60
61+ //! Shader function: Mask a texture with another texture's alpha.
62+ void InitAsmTexMaskTexAlpha();
63+ //! Render polygons with an image-texture, which is masked out by an
64+ //! alpha-texture, with each texture being modulated by a color.
65+ ObjectPtr<IOpenGLAsmShaderProgram> m_AsmTexMaskTexAlpha;
66+
67 void InitAsm2TextureAdd();
68 //! Render polygons with 2 textures, each modulated by a color, and added together.
69 ObjectPtr<IOpenGLAsmShaderProgram> m_Asm2TextureAdd;
70@@ -905,6 +943,11 @@
71 ObjectPtr<IOpenGLShaderProgram> m_SlColorModTexMaskAlpha;
72 ObjectPtr<IOpenGLShaderProgram> m_SlColorModTexRectMaskAlpha;
73
74+ void InitSlTextureMasking();
75+ //! Render polygons with 1 image-texture, masked by 1 alpha-texture, each texture modulated by a color.
76+ //! result = (image*col0)*(alpha.a*col1)
77+ ObjectPtr<IOpenGLShaderProgram> m_SlTextureMasking;
78+
79 void InitSl2TextureAdd();
80 //! Render polygons with 2 textures, each modulated by a color, and added together.
81 //! result = (tex0*color0)+(tex1*color1)
82@@ -915,7 +958,6 @@
83 //! result = (tex1(coord1.xy + tex0.xy)*color1)
84 ObjectPtr<IOpenGLShaderProgram> m_Sl2TextureDepRead;
85
86-
87 void InitSl2TextureMod();
88 //! Render polygons with 2 textures, each modulated by a color, and then multiplied together.
89 //! result = (tex0*color0)*(tex1*color1)
90
91=== modified file 'NuxGraphics/RenderingPipe.cpp'
92--- NuxGraphics/RenderingPipe.cpp 2012-03-21 20:37:17 +0000
93+++ NuxGraphics/RenderingPipe.cpp 2012-03-27 15:45:29 +0000
94@@ -395,6 +395,28 @@
95 #endif
96 }
97
98+ // Render the image-texture masked by the alpha-texture.
99+ void GraphicsEngine::QRP_TexMaskTexAlpha (int x,
100+ int y,
101+ int width,
102+ int height,
103+ ObjectPtr<IOpenGLBaseTexture> imageTexture,
104+ TexCoordXForm& texxformImage,
105+ const Color &colorImage,
106+ ObjectPtr<IOpenGLBaseTexture> alphaTexture,
107+ TexCoordXForm& texxformAlpha,
108+ const Color &colorAlpha)
109+ {
110+#ifndef NUX_OPENGLES_20
111+ if (UsingGLSLCodePath())
112+ QRP_GLSL_TexMaskTexAlpha (x, y, width, height, imageTexture, texxformImage, colorImage, alphaTexture, texxformAlpha, colorAlpha);
113+ else
114+ QRP_ASM_TexMaskTexAlpha (x, y, width, height, imageTexture, texxformImage, colorImage, alphaTexture, texxformAlpha, colorAlpha);
115+#else
116+ QRP_GLSL_TexMaskTexAlpha (x, y, width, height, imageTexture, texxformImage, colorImage, alphaTexture, texxformAlpha, colorAlpha);
117+#endif
118+ }
119+
120 // Blend 2 textures together
121 void GraphicsEngine::QRP_2Tex(int x, int y, int width, int height,
122 ObjectPtr<IOpenGLBaseTexture> DeviceTexture0, TexCoordXForm &texxform0, const Color &color0,
123
124=== modified file 'NuxGraphics/RenderingPipeAsm.cpp'
125--- NuxGraphics/RenderingPipeAsm.cpp 2011-10-19 20:32:38 +0000
126+++ NuxGraphics/RenderingPipeAsm.cpp 2012-03-27 15:45:29 +0000
127@@ -219,6 +219,43 @@
128 m_AsmColorModTexRectMaskAlpha->Link();
129 }
130
131+ void GraphicsEngine::InitAsmTexMaskTexAlpha()
132+ {
133+ NString AsmVtx =
134+ "!!ARBvp1.0 \n\
135+ ATTRIB iPos = vertex.position; \n\
136+ OUTPUT oPos = result.position; \n\
137+ OUTPUT oTexCoord0 = result.texcoord[0]; \n\
138+ OUTPUT oTexCoord1 = result.texcoord[1]; \n\
139+ # Transform the vertex to clip coordinates. \n\
140+ DP4 oPos.x, state.matrix.mvp.row[0], vertex.position; \n\
141+ DP4 oPos.y, state.matrix.mvp.row[1], vertex.position; \n\
142+ DP4 oPos.z, state.matrix.mvp.row[2], vertex.position; \n\
143+ DP4 oPos.w, state.matrix.mvp.row[3], vertex.position; \n\
144+ MOV oTexCoord0, vertex.attrib[8]; \n\
145+ MOV oTexCoord1, vertex.attrib[9]; \n\
146+ END";
147+
148+ NString AsmFrg =
149+ "!!ARBfp1.0 \n\
150+ PARAM color0 = program.local[0]; \n\
151+ PARAM color1 = program.local[1]; \n\
152+ TEMP tex0; \n\
153+ TEMP tex1; \n\
154+ TEMP temp; \n\
155+ TEX tex0, fragment.texcoord[0], texture[0], 2D; \n\
156+ MUL temp, color0, tex0; \n\
157+ TEX tex1, fragment.texcoord[1], texture[1], 2D; \n\
158+ MAD temp, color1, tex1, temp; \n\
159+ MOV result.color, temp; \n\
160+ END";
161+
162+ m_AsmTexMaskTexAlpha = GetGraphicsDisplay()->GetGpuDevice()->CreateAsmShaderProgram();
163+ m_AsmTexMaskTexAlpha->LoadVertexShader(AsmVtx.GetTCharPtr());
164+ m_AsmTexMaskTexAlpha->LoadPixelShader(AsmFrg.GetTCharPtr());
165+ m_AsmTexMaskTexAlpha->Link();
166+ }
167+
168 void GraphicsEngine::InitAsm2TextureAdd()
169 {
170 NString AsmVtx =
171@@ -746,6 +783,81 @@
172 shader_program->End();
173 }
174
175+ // Render the image-texture masked by the alpha-texture.
176+ void GraphicsEngine::QRP_ASM_TexMaskTexAlpha (int x,
177+ int y,
178+ int width,
179+ int height,
180+ ObjectPtr<IOpenGLBaseTexture> imageTexture,
181+ TexCoordXForm& texxformImage,
182+ const Color &colorImage,
183+ ObjectPtr<IOpenGLBaseTexture> alphaTexture,
184+ TexCoordXForm& texxformAlpha,
185+ const Color &colorAlpha)
186+ {
187+ QRP_Compute_Texture_Coord(width, height, imageTexture, texxformImage);
188+ QRP_Compute_Texture_Coord(width, height, alphaTexture, texxformAlpha);
189+
190+ /*float fx = x, fy = y;
191+ float VtxBuffer[] =
192+ {
193+ fx, fy, 0.0f, 1.0f, texxformImage.u0, texxformImage.v0, 0.0f, 1.0f, texxformAlpha.u0, texxformAlpha.v0, 0.0f, 1.0f,
194+ fx, fy + height, 0.0f, 1.0f, texxformImage.u0, texxformImage.v1, 0.0f, 1.0f, texxformAlpha.u0, texxformAlpha.v1, 0.0f, 1.0f,
195+ fx + width, fy + height, 0.0f, 1.0f, texxformImage.u1, texxformImage.v1, 0.0f, 1.0f, texxformAlpha.u1, texxformAlpha.v1, 0.0f, 1.0f,
196+ fx + width, fy, 0.0f, 1.0f, texxformImage.u1, texxformImage.v0, 0.0f, 1.0f, texxformAlpha.u1, texxformAlpha.v0, 0.0f, 1.0f,
197+ };
198+
199+ CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0));
200+ CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
201+
202+ ObjectPtr<IOpenGLAsmShaderProgram> shader_program = m_AsmTexMaskTexAlpha;
203+ shader_program->Begin();
204+
205+ SetTexture(GL_TEXTURE0, imageTexture);
206+ SetTexture(GL_TEXTURE1, alphaTexture);
207+
208+ CHECKGL(glMatrixMode(GL_MODELVIEW));
209+ CHECKGL(glLoadIdentity());
210+ CHECKGL(glLoadMatrixf((FLOAT *) GetOpenGLModelViewMatrix().m));
211+ CHECKGL(glMatrixMode(GL_PROJECTION));
212+ CHECKGL(glLoadIdentity());
213+ CHECKGL(glLoadMatrixf((FLOAT *) GetOpenGLProjectionMatrix().m));
214+
215+ int VertexLocation = VTXATTRIB_POSITION;
216+ int TextureCoord0Location = VTXATTRIB_TEXCOORD0;
217+ int TextureCoord1Location = VTXATTRIB_TEXCOORD1;
218+
219+ CHECKGL(glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, colorImage.red, colorImage.green, colorImage.blue, colorImage.alpha ));
220+ CHECKGL(glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, colorAlpha.red, colorAlpha.green, colorAlpha.blue, colorAlpha.alpha ));
221+
222+ CHECKGL(glEnableVertexAttribArrayARB(VertexLocation));
223+ CHECKGL(glVertexAttribPointerARB((GLuint) VertexLocation, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer));
224+
225+ if (TextureCoord0Location != -1)
226+ {
227+ CHECKGL(glEnableVertexAttribArrayARB(TextureCoord0Location));
228+ CHECKGL(glVertexAttribPointerARB((GLuint) TextureCoord0Location, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer + 4));
229+ }
230+
231+ if (TextureCoord1Location != -1)
232+ {
233+ CHECKGL(glEnableVertexAttribArrayARB(TextureCoord1Location));
234+ CHECKGL(glVertexAttribPointerARB((GLuint) TextureCoord1Location, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer + 8));
235+ }
236+
237+ CHECKGL(glDrawArrays(GL_TRIANGLE_FAN, 0, 4));
238+
239+ CHECKGL(glDisableVertexAttribArrayARB(VertexLocation));
240+
241+ if (TextureCoord0Location != -1)
242+ CHECKGL(glDisableVertexAttribArrayARB(TextureCoord0Location));
243+
244+ if (TextureCoord1Location != -1)
245+ CHECKGL(glDisableVertexAttribArrayARB(TextureCoord1Location));
246+
247+ shader_program->End();*/
248+ }
249+
250 void GraphicsEngine::QRP_ASM_2Tex(int x, int y, int width, int height,
251 ObjectPtr<IOpenGLBaseTexture> device_texture0, TexCoordXForm &texxform0, const Color &color0,
252 ObjectPtr<IOpenGLBaseTexture> device_texture1, TexCoordXForm &texxform1, const Color &color1)
253
254=== modified file 'NuxGraphics/RenderingPipeGLSL.cpp'
255--- NuxGraphics/RenderingPipeGLSL.cpp 2012-03-10 00:16:40 +0000
256+++ NuxGraphics/RenderingPipeGLSL.cpp 2012-03-27 15:45:29 +0000
257@@ -166,6 +166,61 @@
258 m_SlColorModTexMaskAlpha->Link();
259 }
260
261+ void GraphicsEngine::InitSlTextureMasking()
262+ {
263+ ObjectPtr<IOpenGLVertexShader> VS = _graphics_display.m_DeviceFactory->CreateVertexShader();
264+ ObjectPtr<IOpenGLPixelShader> PS = _graphics_display.m_DeviceFactory->CreatePixelShader();
265+ NString VSString;
266+ NString PSString;
267+
268+ // For some strange reason, make sure that the attribute holding the vertex
269+ // position has a name that comes first in alphabetic order before all other
270+ // attributes. Otherwise you get a bug on NVidia! Why is that???
271+
272+ ////////////////////////////////////////////////////////////////////////////////////////////////////
273+ VSString = NUX_VERTEX_SHADER_HEADER
274+ "uniform mat4 ViewProjectionMatrix; \n\
275+ attribute vec4 AVertex; \n\
276+ attribute vec4 imageTextureCoord; \n\
277+ attribute vec4 alphaTextureCoord; \n\
278+ varying vec4 varyImageTexCoord; \n\
279+ varying vec4 varyAlphaTexCoord; \n\
280+ void main() \n\
281+ { \n\
282+ varyImageTexCoord = imageTextureCoord; \n\
283+ varyAlphaTexCoord = alphaTextureCoord; \n\
284+ gl_Position = ViewProjectionMatrix * (AVertex); \n\
285+ }";
286+
287+ PSString = NUX_FRAGMENT_SHADER_HEADER
288+ "varying vec4 varyImageTexCoord; \n\
289+ varying vec4 varyAlphaTexCoord; \n\
290+ uniform vec4 colorImage; \n\
291+ uniform vec4 colorAlpha; \n\
292+ uniform sampler2D imageTexture; \n\
293+ uniform sampler2D alphaTexture; \n\
294+ vec4 SampleTexture(sampler2D TexObject, vec4 TexCoord) \n\
295+ { \n\
296+ return texture2D(TexObject, TexCoord.st); \n\
297+ } \n\
298+ void main() \n\
299+ { \n\
300+ vec4 image = colorImage*SampleTexture(imageTexture, varyImageTexCoord); \n\
301+ vec4 alpha = colorAlpha*SampleTexture(alphaTexture, varyAlphaTexCoord); \n\
302+ gl_FragColor = vec4(image.rgb, alpha.a); \n\
303+ }";
304+
305+ m_SlTextureMasking = _graphics_display.m_DeviceFactory->CreateShaderProgram();
306+ VS->SetShaderCode(TCHAR_TO_ANSI(*VSString));
307+ PS->SetShaderCode(TCHAR_TO_ANSI(*PSString), "");
308+
309+ m_SlTextureMasking->ClearShaderObjects();
310+ m_SlTextureMasking->AddShaderObject(VS);
311+ m_SlTextureMasking->AddShaderObject(PS);
312+ CHECKGL(glBindAttribLocation(m_SlTextureMasking->GetOpenGLID(), 0, "AVertex"));
313+ m_SlTextureMasking->Link();
314+ }
315+
316 void GraphicsEngine::InitSl2TextureAdd()
317 {
318 ObjectPtr<IOpenGLVertexShader> VS = _graphics_display.m_DeviceFactory->CreateVertexShader();
319@@ -1060,6 +1115,90 @@
320 ShaderProg->End();
321 }
322
323+ // Render the image-texture masked by the alpha-texture.
324+ void GraphicsEngine::QRP_GLSL_TexMaskTexAlpha (int x,
325+ int y,
326+ int width,
327+ int height,
328+ ObjectPtr<IOpenGLBaseTexture> imageTexture,
329+ TexCoordXForm& texxformImage,
330+ const Color &colorImage,
331+ ObjectPtr<IOpenGLBaseTexture> alphaTexture,
332+ TexCoordXForm& texxformAlpha,
333+ const Color &colorAlpha)
334+ {
335+ if (!m_SlTextureMasking.IsValid())
336+ InitSlTextureMasking();
337+
338+ ObjectPtr<IOpenGLShaderProgram> ShaderProg;
339+ ShaderProg = m_SlTextureMasking;
340+
341+ QRP_Compute_Texture_Coord(width, height, imageTexture, texxformImage);
342+ QRP_Compute_Texture_Coord(width, height, alphaTexture, texxformAlpha);
343+
344+ float fx = x, fy = y;
345+ float VtxBuffer[] =
346+ {
347+ fx, fy, 0.0f, 1.0f, texxformImage.u0, texxformImage.v0, 0.0f, 1.0f, texxformAlpha.u0, texxformAlpha.v0, 0.0f, 1.0f,
348+ fx, fy + height, 0.0f, 1.0f, texxformImage.u0, texxformImage.v1, 0.0f, 1.0f, texxformAlpha.u0, texxformAlpha.v1, 0.0f, 1.0f,
349+ fx + width, fy + height, 0.0f, 1.0f, texxformImage.u1, texxformImage.v1, 0.0f, 1.0f, texxformAlpha.u1, texxformAlpha.v1, 0.0f, 1.0f,
350+ fx + width, fy, 0.0f, 1.0f, texxformImage.u1, texxformImage.v0, 0.0f, 1.0f, texxformAlpha.u1, texxformAlpha.v0, 0.0f, 1.0f,
351+ };
352+
353+ CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0));
354+ CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
355+ ShaderProg->Begin();
356+
357+ int imageTextureLoc = ShaderProg->GetUniformLocationARB("imageTexture");
358+ int alphaTextureLoc = ShaderProg->GetUniformLocationARB("alphaTexture");
359+ int VertexLocation = ShaderProg->GetAttributeLocation("AVertex");
360+ int imageTextureCoordLoc = ShaderProg->GetAttributeLocation("imageTextureCoord");
361+ int alphaTextureCoordLoc = ShaderProg->GetAttributeLocation("alphaTextureCoord");
362+
363+ int imageTextureCoefLoc = ShaderProg->GetUniformLocationARB("colorImage");
364+ int alphaTextureCoefLoc = ShaderProg->GetUniformLocationARB("colorAlpha");
365+
366+ SetTexture(GL_TEXTURE0, imageTexture);
367+ SetTexture(GL_TEXTURE1, alphaTexture);
368+
369+ CHECKGL(glUniform1iARB(imageTextureLoc, 0));
370+ CHECKGL(glUniform1iARB(alphaTextureLoc, 1));
371+
372+ CHECKGL(glUniform4fARB(imageTextureCoefLoc, colorImage.red, colorImage.green, colorImage.blue, colorImage.alpha ));
373+ CHECKGL(glUniform4fARB(alphaTextureCoefLoc, colorAlpha.red, colorAlpha.green, colorAlpha.blue, colorAlpha.alpha ));
374+
375+ int VPMatrixLocation = ShaderProg->GetUniformLocationARB("ViewProjectionMatrix");
376+ Matrix4 MVPMatrix = GetOpenGLModelViewProjectionMatrix();
377+ ShaderProg->SetUniformLocMatrix4fv((GLint) VPMatrixLocation, 1, false, (GLfloat *) & (MVPMatrix.m));
378+
379+ CHECKGL(glEnableVertexAttribArrayARB(VertexLocation));
380+ CHECKGL(glVertexAttribPointerARB((GLuint) VertexLocation, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer));
381+
382+ if (imageTextureCoordLoc != -1)
383+ {
384+ CHECKGL(glEnableVertexAttribArrayARB(imageTextureCoordLoc));
385+ CHECKGL(glVertexAttribPointerARB((GLuint) imageTextureCoordLoc, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer + 4));
386+ }
387+
388+ if (alphaTextureCoordLoc != -1)
389+ {
390+ CHECKGL(glEnableVertexAttribArrayARB(alphaTextureCoordLoc));
391+ CHECKGL(glVertexAttribPointerARB((GLuint) alphaTextureCoordLoc, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer + 8));
392+ }
393+
394+ CHECKGL(glDrawArrays(GL_TRIANGLE_FAN, 0, 4));
395+
396+ CHECKGL(glDisableVertexAttribArrayARB(VertexLocation));
397+
398+ if (imageTextureCoordLoc != -1)
399+ CHECKGL(glDisableVertexAttribArrayARB(imageTextureCoordLoc));
400+
401+ if (alphaTextureCoordLoc != -1)
402+ CHECKGL(glDisableVertexAttribArrayARB(alphaTextureCoordLoc));
403+
404+ ShaderProg->End();
405+ }
406+
407 // Blend 2 textures together
408 void GraphicsEngine::QRP_GLSL_2Tex(int x, int y, int width, int height,
409 ObjectPtr<IOpenGLBaseTexture> DeviceTexture0, TexCoordXForm &texxform0, const Color &color0,

Subscribers

People subscribed via source and target branches

to all changes: