wined3d: Allow vertex shaders to generate GLSL shaders
Jason Green
jave27 at gmail.com
Thu May 18 00:34:07 CDT 2006
This patch allows vertex shaders to generate GLSL shaders instead of /
in addition to ARB_vertex_program's.
Please let me know if any of these patches conflict with Ivan's recent
patches, and I can re-submit if necessary.
-------------- next part --------------
diff --git a/dlls/wined3d/vertexshader.c b/dlls/wined3d/vertexshader.c
index 4321693..f38a3c9 100644
--- a/dlls/wined3d/vertexshader.c
+++ b/dlls/wined3d/vertexshader.c
@@ -5,6 +5,7 @@
* Copyright 2002-2003 Raphael Junqueira
* Copyright 2005 Oliver Stieber
* Copyright 2006 Ivan Gyurdiev
+ * Copyright 2006 Jason Green
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1063,8 +1064,31 @@ inline static VOID IWineD3DVertexShaderI
buffer.bsize = 0;
buffer.lineNo = 0;
- /* TODO: Optionally, generate the GLSL shader instead */
- if (GL_SUPPORT(ARB_VERTEX_PROGRAM)) {
+ if (USING_GLSL) {
+ /* Create the hw GLSL shader program */
+ GLhandleARB shader, program;
+
+ /* Create the uniforms (aka constants) */
+ shader_addline(&buffer, "uniform vec4 C[%u];\n", This->baseShader.limits.constant_float);
+ /* TODO - Add varyings, attributes, etc. */
+
+ /* Generate the bulk of the shader code */
+ generate_base_shader( (IWineD3DBaseShader*) This, &buffer, pFunction);
+
+ shader_addline(&buffer, "}\n\0");
+
+ /* Create the GLSL shader object */
+ shader = GL_EXTCALL(glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB));
+ GL_EXTCALL(glShaderSourceARB(shader, 1, (const char**)&buffer.buffer, NULL));
+ GL_EXTCALL(glCompileShaderARB(shader));
+ /* Create the shader program and bind the object to it */
+ program = GL_EXTCALL(glCreateProgramObjectARB());
+ GL_EXTCALL(glAttachObjectARB(program, shader));
+ GL_EXTCALL(glLinkProgramARB(program));
+ This->baseShader.prgId = program;
+ /* We will check for errors later when we try to use the program */
+
+ } else if (GL_SUPPORT(ARB_VERTEX_PROGRAM)) {
/* Create the hw ARB shader */
shader_addline(&buffer, "!!ARBvp1.0\n");
More information about the wine-patches
mailing list