remove temporary prototypes
[mesa.git] / src / mesa / main / arbprogram.c
index 20118d45a1fb4a6039792c0ebaec5cfa1a484b30..0b3008554c591ebde7200cdf016376871051df4f 100644 (file)
@@ -31,8 +31,9 @@
 
 #include "glheader.h"
 #include "arbprogram.h"
+#include "arbfragparse.h"
+#include "arbvertparse.h"
 #include "context.h"
-#include "hash.h"
 #include "imports.h"
 #include "macros.h"
 #include "mtypes.h"
 #include "nvvertprog.h"
 
 
-/* XXX temporary */
-static void
-_mesa_parse_arb_vertex_program(GLcontext *ctx, GLenum target,
-                               const GLubyte *string, GLsizei len,
-                               struct vertex_program *prog)
+/*
+ * Init context's program state
+ */
+void
+_mesa_init_program(GLcontext *ctx)
 {
-}
-
+   GLuint i;
+
+   ctx->Program.ErrorPos = -1;
+   ctx->Program.ErrorString = _mesa_strdup("");
+
+#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
+   ctx->VertexProgram.Enabled = GL_FALSE;
+   ctx->VertexProgram.PointSizeEnabled = GL_FALSE;
+   ctx->VertexProgram.TwoSideEnabled = GL_FALSE;
+   ctx->VertexProgram.Current = NULL;
+   ctx->VertexProgram.Current = (struct vertex_program *) ctx->Shared->DefaultVertexProgram;
+   assert(ctx->VertexProgram.Current);
+   ctx->VertexProgram.Current->Base.RefCount++;
+   for (i = 0; i < VP_NUM_PROG_REGS / 4; i++) {
+      ctx->VertexProgram.TrackMatrix[i] = GL_NONE;
+      ctx->VertexProgram.TrackMatrixTransform[i] = GL_IDENTITY_NV;
+   }
+#endif
 
-static void
-_mesa_parse_arb_fragment_program(GLcontext *ctx, GLenum target,
-                                 const GLubyte *string, GLsizei len,
-                                 struct fragment_program *prog)
-{
+#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program
+   ctx->FragmentProgram.Enabled = GL_FALSE;
+   ctx->FragmentProgram.Current = (struct fragment_program *) ctx->Shared->DefaultFragmentProgram;
+   assert(ctx->FragmentProgram.Current);
+   ctx->FragmentProgram.Current->Base.RefCount++;
+#endif
 }
 
 
-
 void
 _mesa_EnableVertexAttribArrayARB(GLuint index)
 {
@@ -304,7 +321,9 @@ _mesa_GetProgramEnvParameterfvARB(GLenum target, GLuint index,
                                   GLfloat *params)
 {
    GET_CURRENT_CONTEXT(ctx);
-   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   if (!ctx->_CurrentProgram)
+      ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    if (target == GL_FRAGMENT_PROGRAM_ARB
        && ctx->Extensions.ARB_fragment_program) {
@@ -477,7 +496,9 @@ _mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params)
 {
    struct program *prog;
    GET_CURRENT_CONTEXT(ctx);
-   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   if (!ctx->_CurrentProgram)
+      ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    if (target == GL_VERTEX_PROGRAM_ARB
        && ctx->Extensions.ARB_vertex_program) {
@@ -682,7 +703,9 @@ _mesa_GetProgramStringARB(GLenum target, GLenum pname, GLvoid *string)
 {
    struct program *prog;
    GET_CURRENT_CONTEXT(ctx);
-   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   if (!ctx->_CurrentProgram)
+      ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    if (target == GL_VERTEX_PROGRAM_ARB) {
       prog = &(ctx->VertexProgram.Current->Base);
@@ -741,7 +764,7 @@ _mesa_ProgramCallbackMESA(GLenum target, GLprogramcallbackMESA callback,
          break;
       case GL_VERTEX_PROGRAM_ARB: /* == GL_VERTEX_PROGRAM_NV */
          if (!ctx->Extensions.ARB_vertex_program &&
-             !ctx->Extensions.ARB_vertex_program) {
+             !ctx->Extensions.NV_vertex_program) {
             _mesa_error(ctx, GL_INVALID_ENUM, "glProgramCallbackMESA(target)");
             return;
          }
@@ -815,7 +838,10 @@ _mesa_GetProgramRegisterfvMESA(GLenum target,
             GLint i;
             for (i = 0; i < ctx->Const.MaxVertexProgramAttribs; i++) {
                const char *name = _mesa_nv_vertex_input_register_name(i);
-               if (_mesa_strncmp(reg + 2, name, 4) == 0) {
+               char number[10];
+               sprintf(number, "%d", i);
+               if (_mesa_strncmp(reg + 2, name, 4) == 0 ||
+                   _mesa_strncmp(reg + 2, number, _mesa_strlen(number)) == 0) {
                   COPY_4V(v, ctx->VertexProgram.Machine.Registers
                           [VP_INPUT_REG_START + i]);
                   return;