#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 "nvprogram.h"
+#include "nvfragparse.h"
#include "nvfragprog.h"
+#include "nvvertparse.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)
-{
-}
-
-
-static void
-_mesa_parse_arb_fragment_program(GLcontext *ctx, GLenum target,
- const GLubyte *string, GLsizei len,
- struct fragment_program *prog)
-{
-}
-
-
-
-void
+void GLAPIENTRY
_mesa_EnableVertexAttribArrayARB(GLuint index)
{
GET_CURRENT_CONTEXT(ctx);
return;
}
+ FLUSH_VERTICES(ctx, _NEW_ARRAY);
ctx->Array.VertexAttrib[index].Enabled = GL_TRUE;
ctx->Array._Enabled |= _NEW_ARRAY_ATTRIB(index);
ctx->Array.NewState |= _NEW_ARRAY_ATTRIB(index);
}
-void
+void GLAPIENTRY
_mesa_DisableVertexAttribArrayARB(GLuint index)
{
GET_CURRENT_CONTEXT(ctx);
return;
}
+ FLUSH_VERTICES(ctx, _NEW_ARRAY);
ctx->Array.VertexAttrib[index].Enabled = GL_FALSE;
ctx->Array._Enabled &= ~_NEW_ARRAY_ATTRIB(index);
ctx->Array.NewState |= _NEW_ARRAY_ATTRIB(index);
}
-void
+void GLAPIENTRY
_mesa_GetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble *params)
{
GLfloat fparams[4];
}
-void
+void GLAPIENTRY
_mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params)
{
GET_CURRENT_CONTEXT(ctx);
switch (pname) {
case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB:
- params[0] = ctx->Array.VertexAttrib[index].Enabled;
+ params[0] = (GLfloat) ctx->Array.VertexAttrib[index].Enabled;
break;
case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB:
- params[0] = ctx->Array.VertexAttrib[index].Size;
+ params[0] = (GLfloat) ctx->Array.VertexAttrib[index].Size;
break;
case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB:
- params[0] = ctx->Array.VertexAttrib[index].Stride;
+ params[0] = (GLfloat) ctx->Array.VertexAttrib[index].Stride;
break;
case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB:
- params[0] = ctx->Array.VertexAttrib[index].Type;
+ params[0] = (GLfloat) ctx->Array.VertexAttrib[index].Type;
break;
case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB:
params[0] = ctx->Array.VertexAttrib[index].Normalized;
FLUSH_CURRENT(ctx, 0);
COPY_4V(params, ctx->Current.Attrib[index]);
break;
+ case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB:
+ if (!ctx->Extensions.ARB_vertex_buffer_object) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribfvARB(pname)");
+ return;
+ }
+ params[0] = (GLfloat) ctx->Array.VertexAttrib[index].BufferObj->Name;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribfvARB(pname)");
return;
}
-void
+void GLAPIENTRY
_mesa_GetVertexAttribivARB(GLuint index, GLenum pname, GLint *params)
{
GLfloat fparams[4];
_mesa_GetVertexAttribfvARB(index, pname, fparams);
if (ctx->ErrorValue == GL_NO_ERROR) {
if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) {
- COPY_4V(params, fparams); /* float to int */
+ COPY_4V_CAST(params, fparams, GLint); /* float to int */
}
else {
- params[0] = fparams[0];
+ params[0] = (GLint) fparams[0];
}
}
}
-void
+void GLAPIENTRY
_mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer)
{
GET_CURRENT_CONTEXT(ctx);
return;
}
- *pointer = ctx->Array.VertexAttrib[index].Ptr;;
+ *pointer = (GLvoid *) ctx->Array.VertexAttrib[index].Ptr;;
}
-void
+void GLAPIENTRY
_mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
const GLvoid *string)
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+
if (target == GL_VERTEX_PROGRAM_ARB
&& ctx->Extensions.ARB_vertex_program) {
struct vertex_program *prog = ctx->VertexProgram.Current;
_mesa_error(ctx, GL_INVALID_ENUM, "glProgramStringARB(format)");
return;
}
- _mesa_parse_arb_vertex_program(ctx, target, string, len, prog);
+ _mesa_parse_arb_vertex_program(ctx, target, (const GLubyte *) string,
+ len, prog);
}
else if (target == GL_FRAGMENT_PROGRAM_ARB
&& ctx->Extensions.ARB_fragment_program) {
_mesa_error(ctx, GL_INVALID_ENUM, "glProgramStringARB(format)");
return;
}
- _mesa_parse_arb_fragment_program(ctx, target, string, len, prog);
+ _mesa_parse_arb_fragment_program(ctx, target, (const GLubyte *) string,
+ len, prog);
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glProgramStringARB(target)");
}
-void
+void GLAPIENTRY
_mesa_ProgramEnvParameter4dARB(GLenum target, GLuint index,
GLdouble x, GLdouble y, GLdouble z, GLdouble w)
{
- _mesa_ProgramEnvParameter4fARB(target, index, x, y, z, w);
+ _mesa_ProgramEnvParameter4fARB(target, index, (GLfloat) x, (GLfloat) y,
+ (GLfloat) z, (GLfloat) w);
}
-void
+void GLAPIENTRY
_mesa_ProgramEnvParameter4dvARB(GLenum target, GLuint index,
const GLdouble *params)
{
- _mesa_ProgramEnvParameter4fARB(target, index, params[0], params[1],
- params[2], params[3]);
+ _mesa_ProgramEnvParameter4fARB(target, index, (GLfloat) params[0],
+ (GLfloat) params[1], (GLfloat) params[2],
+ (GLfloat) params[3]);
}
-void
+void GLAPIENTRY
_mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index,
GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+
if (target == GL_FRAGMENT_PROGRAM_ARB
&& ctx->Extensions.ARB_fragment_program) {
if (index >= ctx->Const.MaxFragmentProgramEnvParams) {
_mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter(index)");
return;
}
- index += FP_PROG_REG_START;
- ASSIGN_4V(ctx->FragmentProgram.Machine.Registers[index], x, y, z, w);
+ ASSIGN_4V(ctx->FragmentProgram.Parameters[index], x, y, z, w);
}
if (target == GL_VERTEX_PROGRAM_ARB
&& ctx->Extensions.ARB_vertex_program) {
_mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter(index)");
return;
}
- index += VP_PROG_REG_START;
- ASSIGN_4V(ctx->VertexProgram.Machine.Registers[index], x, y, z, w);
+ ASSIGN_4V(ctx->VertexProgram.Parameters[index], x, y, z, w);
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glProgramEnvParameter(target)");
}
-void
+void GLAPIENTRY
_mesa_ProgramEnvParameter4fvARB(GLenum target, GLuint index,
const GLfloat *params)
{
}
-void
+void GLAPIENTRY
_mesa_GetProgramEnvParameterdvARB(GLenum target, GLuint index,
GLdouble *params)
{
}
-void
+void GLAPIENTRY
_mesa_GetProgramEnvParameterfvARB(GLenum target, GLuint index,
GLfloat *params)
{
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+
+ if (!ctx->_CurrentProgram)
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
if (target == GL_FRAGMENT_PROGRAM_ARB
&& ctx->Extensions.ARB_fragment_program) {
_mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramEnvParameter(index)");
return;
}
- index += FP_PROG_REG_START;
- COPY_4V(params, ctx->FragmentProgram.Machine.Registers[index]);
+ COPY_4V(params, ctx->FragmentProgram.Parameters[index]);
}
if (target == GL_VERTEX_PROGRAM_ARB
&& ctx->Extensions.ARB_vertex_program) {
_mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramEnvParameter(index)");
return;
}
- index += VP_PROG_REG_START;
- COPY_4V(params, ctx->VertexProgram.Machine.Registers[index]);
+ COPY_4V(params, ctx->VertexProgram.Parameters[index]);
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramEnvParameter(target)");
/**
* Note, this function is also used by the GL_NV_fragment_program extension.
*/
-void
+void GLAPIENTRY
_mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index,
GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
struct program *prog;
ASSERT_OUTSIDE_BEGIN_END(ctx);
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+
if ((target == GL_FRAGMENT_PROGRAM_NV
&& ctx->Extensions.NV_fragment_program) ||
(target == GL_FRAGMENT_PROGRAM_ARB
/**
* Note, this function is also used by the GL_NV_fragment_program extension.
*/
-void
+void GLAPIENTRY
_mesa_ProgramLocalParameter4fvARB(GLenum target, GLuint index,
const GLfloat *params)
{
/**
* Note, this function is also used by the GL_NV_fragment_program extension.
*/
-void
+void GLAPIENTRY
_mesa_ProgramLocalParameter4dARB(GLenum target, GLuint index,
GLdouble x, GLdouble y,
GLdouble z, GLdouble w)
/**
* Note, this function is also used by the GL_NV_fragment_program extension.
*/
-void
+void GLAPIENTRY
_mesa_ProgramLocalParameter4dvARB(GLenum target, GLuint index,
const GLdouble *params)
{
/**
* Note, this function is also used by the GL_NV_fragment_program extension.
*/
-void
+void GLAPIENTRY
_mesa_GetProgramLocalParameterfvARB(GLenum target, GLuint index,
GLfloat *params)
{
/**
* Note, this function is also used by the GL_NV_fragment_program extension.
*/
-void
+void GLAPIENTRY
_mesa_GetProgramLocalParameterdvARB(GLenum target, GLuint index,
GLdouble *params)
{
}
-void
+void GLAPIENTRY
_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) {
prog = &(ctx->VertexProgram.Current->Base);
}
else if (target == GL_FRAGMENT_PROGRAM_ARB
- && ctx->Extensions.ARB_vertex_program) {
+ && ctx->Extensions.ARB_fragment_program) {
prog = &(ctx->FragmentProgram.Current->Base);
}
else {
}
-void
+void GLAPIENTRY
_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);
MEMCPY(string, prog->String, _mesa_strlen((char *) prog->String));
}
+