enum piglit_result piglit_display(void) { static const GLfloat color[4] = { 0.0, 1.0, 0.0, 1.0 }; static const GLfloat bad_color[4] = { 1.0, 0.0, 0.0, 1.0 }; enum piglit_result result = PIGLIT_PASS; unsigned i; glClear(GL_COLOR_BUFFER_BIT); glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 0, bad_color); glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 1, color); glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 2, color); glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 3, color); for (i = 0; i < ARRAY_SIZE(progs); i++) { const int x = 1 + (i * (BOX_SIZE + 1)); glBindProgramARB(GL_VERTEX_PROGRAM_ARB, progs[i]); if (i == 0) { glVertexAttrib4fARB(1, 1.0, 0.0, 0.0, 0.0); } else { glVertexAttrib4fARB(1, 0.0, 1.0, 2.0, 3.0); } piglit_draw_rect(x, 1, BOX_SIZE, BOX_SIZE); if (!piglit_probe_pixel_rgb(x + (BOX_SIZE / 2), 1 + (BOX_SIZE / 2), color)) { result = PIGLIT_FAIL; } } piglit_present_results(); return result; }
/* GL locking is done by the caller */ static inline void send_attribute(IWineD3DDeviceImpl *This, WINED3DFORMAT format, const UINT index, const void *ptr) { const struct wined3d_gl_info *gl_info = &This->adapter->gl_info; switch(format) { case WINED3DFMT_R32_FLOAT: GL_EXTCALL(glVertexAttrib1fvARB(index, ptr)); break; case WINED3DFMT_R32G32_FLOAT: GL_EXTCALL(glVertexAttrib2fvARB(index, ptr)); break; case WINED3DFMT_R32G32B32_FLOAT: GL_EXTCALL(glVertexAttrib3fvARB(index, ptr)); break; case WINED3DFMT_R32G32B32A32_FLOAT: GL_EXTCALL(glVertexAttrib4fvARB(index, ptr)); break; case WINED3DFMT_R8G8B8A8_UINT: GL_EXTCALL(glVertexAttrib4ubvARB(index, ptr)); break; case WINED3DFMT_B8G8R8A8_UNORM: if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA]) { const DWORD *src = ptr; DWORD c = *src & 0xff00ff00; c |= (*src & 0xff0000) >> 16; c |= (*src & 0xff) << 16; GL_EXTCALL(glVertexAttrib4NubvARB(index, (GLubyte *)&c)); break; } /* else fallthrough */ case WINED3DFMT_R8G8B8A8_UNORM: GL_EXTCALL(glVertexAttrib4NubvARB(index, ptr)); break; case WINED3DFMT_R16G16_SINT: GL_EXTCALL(glVertexAttrib4svARB(index, ptr)); break; case WINED3DFMT_R16G16B16A16_SINT: GL_EXTCALL(glVertexAttrib4svARB(index, ptr)); break; case WINED3DFMT_R16G16_SNORM: { GLshort s[4] = {((const GLshort *)ptr)[0], ((const GLshort *)ptr)[1], 0, 1}; GL_EXTCALL(glVertexAttrib4NsvARB(index, s)); break; } case WINED3DFMT_R16G16_UNORM: { GLushort s[4] = {((const GLushort *)ptr)[0], ((const GLushort *)ptr)[1], 0, 1}; GL_EXTCALL(glVertexAttrib4NusvARB(index, s)); break; } case WINED3DFMT_R16G16B16A16_SNORM: GL_EXTCALL(glVertexAttrib4NsvARB(index, ptr)); break; case WINED3DFMT_R16G16B16A16_UNORM: GL_EXTCALL(glVertexAttrib4NusvARB(index, ptr)); break; case WINED3DFMT_R10G10B10A2_UINT: FIXME("Unsure about WINED3DDECLTYPE_UDEC3\n"); /*glVertexAttrib3usvARB(instancedData[j], (GLushort *) ptr); Does not exist */ break; case WINED3DFMT_R10G10B10A2_SNORM: FIXME("Unsure about WINED3DDECLTYPE_DEC3N\n"); /*glVertexAttrib3NusvARB(instancedData[j], (GLushort *) ptr); Does not exist */ break; case WINED3DFMT_R16G16_FLOAT: /* Are those 16 bit floats. C doesn't have a 16 bit float type. I could read the single bits and calculate a 4 * byte float according to the IEEE standard */ if (gl_info->supported[NV_HALF_FLOAT]) { /* Not supported by GL_ARB_half_float_vertex */ GL_EXTCALL(glVertexAttrib2hvNV(index, ptr)); } else { float x = float_16_to_32(((const unsigned short *)ptr) + 0); float y = float_16_to_32(((const unsigned short *)ptr) + 1); GL_EXTCALL(glVertexAttrib2fARB(index, x, y)); } break; case WINED3DFMT_R16G16B16A16_FLOAT: if (gl_info->supported[NV_HALF_FLOAT]) { /* Not supported by GL_ARB_half_float_vertex */ GL_EXTCALL(glVertexAttrib4hvNV(index, ptr)); } else { float x = float_16_to_32(((const unsigned short *)ptr) + 0); float y = float_16_to_32(((const unsigned short *)ptr) + 1); float z = float_16_to_32(((const unsigned short *)ptr) + 2); float w = float_16_to_32(((const unsigned short *)ptr) + 3); GL_EXTCALL(glVertexAttrib4fARB(index, x, y, z, w)); } break; default: ERR("Unexpected attribute format: %s\n", debug_d3dformat(format)); break; } }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_ARBVertexProgram_nglVertexAttrib4fARB(JNIEnv *env, jclass clazz, jint index, jfloat x, jfloat y, jfloat z, jfloat w, jlong function_pointer) { glVertexAttrib4fARBPROC glVertexAttrib4fARB = (glVertexAttrib4fARBPROC)((intptr_t)function_pointer); glVertexAttrib4fARB(index, x, y, z, w); }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_ARBVertexShader_nglVertexAttrib4fARB(JNIEnv *env, jclass clazz, jint index, jfloat v0, jfloat v1, jfloat v2, jfloat v3, jlong function_pointer) { glVertexAttrib4fARBPROC glVertexAttrib4fARB = (glVertexAttrib4fARBPROC)((intptr_t)function_pointer); glVertexAttrib4fARB(index, v0, v1, v2, v3); }
//-------------------------------------------------------------------- // LLViewerJointMesh::drawShape() //-------------------------------------------------------------------- U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass) { if (!mValid || !mMesh || !mFace || !mVisible || mFace->mVertexBuffer.isNull() || mMesh->getNumFaces() == 0) { return 0; } U32 triangle_count = 0; stop_glerror(); //---------------------------------------------------------------- // setup current color //---------------------------------------------------------------- if (!gRenderForSelect) { if ((mFace->getPool()->getVertexShaderLevel() > 0)) { glColor4f(0,0,0,1); if (gMaterialIndex > 0) { glVertexAttrib4fvARB(gMaterialIndex, mColor.mV); } if (mShiny && gSpecularIndex > 0) { glVertexAttrib4fARB(gSpecularIndex, 1,1,1,1); } } else { glColor4fv(mColor.mV); } } stop_glerror(); LLGLSSpecular specular(LLColor4(1.f,1.f,1.f,1.f), gRenderForSelect ? 0.0f : mShiny && !(mFace->getPool()->getVertexShaderLevel() > 0)); LLGLEnable texture_2d((gRenderForSelect && isTransparent()) ? GL_TEXTURE_2D : 0); //---------------------------------------------------------------- // setup current texture //---------------------------------------------------------------- llassert( !(mTexture.notNull() && mLayerSet) ); // mutually exclusive if (mTestImageName) { LLImageGL::bindExternalTexture( mTestImageName, 0, GL_TEXTURE_2D ); if (mIsTransparent) { glColor4f(1.f, 1.f, 1.f, 1.f); } else { glColor4f(0.7f, 0.6f, 0.3f, 1.f); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_ONE_MINUS_SRC_ALPHA); } } else if( mLayerSet ) { if( mLayerSet->hasComposite() ) { mLayerSet->getComposite()->bindTexture(); } else { llwarns << "Layerset without composite" << llendl; gImageList.getImage(IMG_DEFAULT)->bind(); } } else if ( mTexture.notNull() ) { mTexture->bind(); if (!mTexture->getClampS()) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); } if (!mTexture->getClampT()) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } } else { gImageList.getImage(IMG_DEFAULT_AVATAR)->bind(); } LLGLDisable tex(gRenderForSelect && !isTransparent() ? GL_TEXTURE_2D : 0); if (gRenderForSelect) { if (isTransparent()) { glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_MODULATE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE); // GL_TEXTURE_ENV_COLOR is set in renderPass1 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA); } } else { //---------------------------------------------------------------- // by default, backface culling is enabled //---------------------------------------------------------------- /*if (sRenderPass == AVATAR_RENDER_PASS_CLOTHING_INNER) { LLImageGL::bindExternalTexture( sClothingMaskImageName, 1, GL_TEXTURE_2D ); glClientActiveTextureARB(GL_TEXTURE0_ARB); glActiveTextureARB(GL_TEXTURE0_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PRIMARY_COLOR_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PRIMARY_COLOR_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); glClientActiveTextureARB(GL_TEXTURE1_ARB); glEnable(GL_TEXTURE_2D); // Texture unit 1 glActiveTextureARB(GL_TEXTURE1_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, sClothingInnerColor.mV); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_CONSTANT_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_ALPHA); } else if (sRenderPass == AVATAR_RENDER_PASS_CLOTHING_OUTER) { glAlphaFunc(GL_GREATER, 0.1f); LLImageGL::bindExternalTexture( sClothingMaskImageName, 1, GL_TEXTURE_2D ); glClientActiveTextureARB(GL_TEXTURE0_ARB); glActiveTextureARB(GL_TEXTURE0_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PRIMARY_COLOR_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PRIMARY_COLOR_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); glClientActiveTextureARB(GL_TEXTURE1_ARB); glEnable(GL_TEXTURE_2D); // Texture unit 1 glActiveTextureARB(GL_TEXTURE1_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_MODULATE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA); }*/ } mFace->mVertexBuffer->setBuffer(sRenderMask); U32 start = mMesh->mFaceVertexOffset; U32 end = start + mMesh->mFaceVertexCount - 1; U32 count = mMesh->mFaceIndexCount; U32* indicesp = ((U32*) mFace->mVertexBuffer->getIndicesPointer()) + mMesh->mFaceIndexOffset; if (mMesh->hasWeights()) { if ((mFace->getPool()->getVertexShaderLevel() > 0)) { if (first_pass) { uploadJointMatrices(); } llDrawRangeElements(GL_TRIANGLES, start, end, count, GL_UNSIGNED_INT, indicesp); } else { llDrawRangeElements(GL_TRIANGLES, start, end, count, GL_UNSIGNED_INT, indicesp); } } else { glPushMatrix(); LLMatrix4 jointToWorld = getWorldMatrix(); glMultMatrixf((GLfloat*)jointToWorld.mMatrix); llDrawRangeElements(GL_TRIANGLES, start, end, count, GL_UNSIGNED_INT, indicesp); glPopMatrix(); } triangle_count += mMesh->mFaceIndexCount; if (mTestImageName) { glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } /*if (sRenderPass != AVATAR_RENDER_PASS_SINGLE) { LLImageGL::unbindTexture(1, GL_TEXTURE_2D); glActiveTextureARB(GL_TEXTURE1_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE); // Return to the default texture. LLImageGL::unbindTexture(0, GL_TEXTURE_2D); glClientActiveTextureARB(GL_TEXTURE0_ARB); glActiveTextureARB(GL_TEXTURE0_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE); glAlphaFunc(GL_GREATER, 0.01f); }*/ if (mTexture.notNull()) { if (!mTexture->getClampS()) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); } if (!mTexture->getClampT()) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); } } return triangle_count; }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_ARBVertexProgram_glVertexAttrib4fARB(JNIEnv *__env, jclass clazz, jint index, jfloat v0, jfloat v1, jfloat v2, jfloat v3) { glVertexAttrib4fARBPROC glVertexAttrib4fARB = (glVertexAttrib4fARBPROC)tlsGetFunction(1404); UNUSED_PARAM(clazz) glVertexAttrib4fARB(index, v0, v1, v2, v3); }