Beispiel #1
0
	void Renderer::ShaderToy(std::string pShader, vec2 pPosition, vec2 pSize, std::string pTexture1, std::string pTexture2, std::string pTexture3, std::string pTexture4)
	{
		if (_userPrograms.find(pShader) != _userPrograms.end())
		{
			Program* program = _userPrograms[pShader];
			glUseProgram(program->GetProgram());
			glBindVertexArray(_baseVAO);
			glUniform4f(program->GetUniforms()["PositionSize"].Location, pPosition.x, pPosition.y, pSize.x, pSize.y);
				
			if(pTexture1 != "" && program->IsUniformActive("Texture0"))
				glUniformHandleui64ARB(program->GetUniforms()["Texture0"].Location, _userTextures[pTexture1]->GetHandle());
			if (pTexture2 != "" && program->IsUniformActive("Texture1"))
				glUniformHandleui64ARB(program->GetUniforms()["Texture1"].Location, _userTextures[pTexture2]->GetHandle());
			if (pTexture3 != "" && program->IsUniformActive("Texture2"))
				glUniformHandleui64ARB(program->GetUniforms()["Texture2"].Location, _userTextures[pTexture3]->GetHandle());
			if (pTexture4 != "" && program->IsUniformActive("Texture3"))
				glUniformHandleui64ARB(program->GetUniforms()["Texture3"].Location, _userTextures[pTexture4]->GetHandle());

			if (program->IsUniformActive("iGlobalTime"))
				glUniform1f(program->GetUniforms()["iGlobalTime"].Location, Clock::GetRef().GetTotalTime());
				
			if (program->IsUniformActive("iMouse"))
			{
				vec4 mouse = vec4(
					_uiFunctionPtr->GetCurrentInputPtr()->IsLeftButtonDown() || _uiFunctionPtr->GetCurrentInputPtr()->IsRightButtonDown() ?
					_uiFunctionPtr->GetCurrentInputPtr()->GetMousePosition() : vec2(0.0,0.0), 
					_uiFunctionPtr->GetCurrentInputPtr()->IsLeftButtonDown() ? 1.0 : 0.0,
					_uiFunctionPtr->GetCurrentInputPtr()->IsRightButtonDown() ? 1.0 : 0.0);

				glUniform4f(program->GetUniforms()["iMouse"].Location,mouse.x,mouse.y,mouse.z,mouse.w);
			}

			glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
		}
	}
Beispiel #2
0
    void setTextureHandlesImpl(uint64_t handle, HandlesId... args)
    {
#if !defined(USE_GLES2)
        if (handle)
            glUniformHandleui64ARB(m_texture_location[N], handle);
#endif
        setTextureHandlesImpl<N + 1>(args...);
    }   // setTextureHandlesImpl
Beispiel #3
0
template<> void uniform<cubemap>::assign(const cubemap &value)
{
    if (value.bindless()) {
        glUniformHandleui64ARB(id, value.handle());
    } else {
        glUniform1i(id, value.tmu());
    }
}
Beispiel #4
0
template<> void uniform<array_texture>::assign(const array_texture &value)
{
    if (value.bindless()) {
        glUniformHandleui64ARB(id, value.handle());
    } else {
        glUniform1i(id, value.tmu());
    }
}
Beispiel #5
0
	void Renderer::DrawText(std::string pPath, vec2 pPosition)
	{
		Program* program = _programs["Texture"];
		glUseProgram(program->GetProgram());
		glBindVertexArray(_baseVAO);
		glUniform4f(program->GetUniforms()["PositionSize"].Location, pPosition.x, pPosition.y, (GLfloat)_userTexts[pPath]->GetWidth(), (GLfloat)_userTexts[pPath]->GetHeight());
		glUniformHandleui64ARB(program->GetUniforms()["Texture"].Location, _userTexts[pPath]->GetHandle());
		glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
	}
Beispiel #6
0
	void Renderer::DrawImage(GLuint64 pHandle, vec2 pPosition, vec2 pSize)
	{
		Program* program = _programs["Texture"];
		glUseProgram(program->GetProgram());
		glBindVertexArray(_baseVAO);
		glUniform4f(program->GetUniforms()["PositionSize"].Location, pPosition.x, pPosition.y, pSize.x, pSize.y);
		glUniformHandleui64ARB(program->GetUniforms()["Texture"].Location, pHandle);
		glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
	}
 void SetTextureHandles(const std::vector<uint64_t> &args)
 {
     assert(args.size() == TextureLocation.size() && "Wrong Handle count");
     for (unsigned i = 0; i < args.size(); i++)
     {
         if (args[i])
             glUniformHandleui64ARB(TextureLocation[i], args[i]);
     }
 }
Beispiel #8
0
void ImageViewerPanel::paintGL()
{
	makeCurrent();

	glClearColor(0.2, 0.2, 0.2, 1.0);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	glBindVertexArray(vao);
	shaderP->use_program();
	if (textures)
	{
		glUniformHandleui64ARB((*shaderP)["tex"], texHandle);
	}

	glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);

	glBindVertexArray(0);
	doneCurrent();
}
void UniformImplementation_Legacy::set(const Program * program, const GLint location, const GLuint64 & value) const
{
    program->use();
    glUniformHandleui64ARB(location, value);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_ARBBindlessTexture_nglUniformHandleui64ARB(JNIEnv *env, jclass clazz, jint location, jlong value, jlong function_pointer) {
	glUniformHandleui64ARBPROC glUniformHandleui64ARB = (glUniformHandleui64ARBPROC)((intptr_t)function_pointer);
	glUniformHandleui64ARB(location, value);
}
Beispiel #11
0
 void SetTextureHandles_impl(uint64_t handle, HandlesId... args)
 {
     if (handle)
         glUniformHandleui64ARB(TextureLocation[N], handle);
     SetTextureHandles_impl<N + 1>(args...);
 }
// --------------------------------------------------------------------------------------------------------------------
void TexturedQuadsGLBindless::Render(const std::vector<Matrix>& _transforms)
{
    // Program
    Vec3 dir = { 0, 0, 1 };
    Vec3 at = { 0, 0, 0 };
    Vec3 up = { 0, 1, 0 };
    dir = normalize(dir);
    Vec3 eye = at - 250 * dir;
    Matrix view = matrix_look_at(eye, at, up);
    Matrix view_proj = mProj * view;

    glUseProgram(mProgram);
    glUniformMatrix4fv(mUniformLocation.ViewProjection, 1, GL_TRUE, &view_proj.x.x);

    // Input Layout. First the IB
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer);

    // Then the VBs.
    glBindBuffer(GL_ARRAY_BUFFER, mVertexBuffer);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(TexturedQuadsProblem::Vertex), (void*)offsetof(TexturedQuadsProblem::Vertex, pos));
    glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(TexturedQuadsProblem::Vertex), (void*)offsetof(TexturedQuadsProblem::Vertex, tex));
    glEnableVertexAttribArray(0);
    glEnableVertexAttribArray(1);

    // Rasterizer State
    glEnable(GL_CULL_FACE);
    glCullFace(GL_FRONT);
    glFrontFace(GL_CCW);

    glDisable(GL_SCISSOR_TEST);

    // Blend State
    glDisable(GL_BLEND);
    glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);

    // Depth Stencil State
    glEnable(GL_DEPTH_TEST);
    glDepthMask(GL_TRUE);

    for (auto it = mTexHandles.begin(); it != mTexHandles.end(); ++it) {
        glMakeTextureHandleResidentARB(*it);
    }

    glBindBuffer(GL_SHADER_STORAGE_BUFFER, mTransformBuffer);
    BufferData(GL_SHADER_STORAGE_BUFFER, _transforms, GL_DYNAMIC_DRAW);
    size_t xformCount = _transforms.size();
    assert(xformCount <= mObjectCount);

    // Code below assumes at least 1 texture.
    assert(mTexHandles.size() > 0);
    auto texIt = mTexHandles.begin();

    for (size_t u = 0; u < xformCount; ++u) {
        // Update the Draw ID (since we cannot use multi_draw here
        glUniform1i(mUniformLocation.DrawID, u);

        if (texIt == mTexHandles.end()) {
            texIt = mTexHandles.begin();
        }

        GLuint64 activeTex = *texIt;
        ++texIt;

        glUniformHandleui64ARB(mUniformLocation.gTex, activeTex);
        glDrawElements(GL_TRIANGLES, mIndexCount, GL_UNSIGNED_SHORT, 0);
    }

    for (auto it = mTexHandles.begin(); it != mTexHandles.end(); ++it) {
        glMakeTextureHandleNonResidentARB(*it);
    }
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_ARBBindlessTexture_glUniformHandleui64ARB(JNIEnv *__env, jclass clazz, jint location, jlong value) {
    glUniformHandleui64ARBPROC glUniformHandleui64ARB = (glUniformHandleui64ARBPROC)tlsGetFunction(1082);
    UNUSED_PARAM(clazz)
    glUniformHandleui64ARB(location, value);
}