小编Dom*_*yre的帖子

将项目升级到Android Studio 1.0(Gradle问题)

刚开始我对android开发/ android studio/gradle很新,请原谅我,如果我问一个愚蠢的问题.

我的团队一直在研究android studio测试版的项目,我刚刚安装了新版本(1.0),我从github远程仓库导入了我们的项目.

当尝试使用gradle同步项目时,我得到错误:Gradle version 2.1 is required. Current version is 2.2.1.它建议我在gradle-2.1中更改distributionUrl,但是当我这样做时,我得到gradle插件需要2.2.1的错误.

问题是为什么我的项目需要2.1,我可以在哪里更改?

这是我的gradle.build:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"

    defaultConfig {
        applicationId "com.<teamName>.<projectName>"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

buildscript{
    dependencies{
        classpath 'com.android.tools.build:gradle:1.0.0'
    }
}
Run Code Online (Sandbox Code Playgroud)

android gradle android-studio android-gradle-plugin

11
推荐指数
1
解决办法
7582
查看次数

如何计算Win2D中一段文本的大小

我正在使用Win2D编写一个Windows 10应用程序,我正在尝试绘制一个动态缩放的形状,以适应其中的任何文本.

我想要做的是弄清楚给定CanvasTextFormat的特定字符串有多大,然后使用它来设置形状的大小.

我的问题是我似乎无法找到一种方法来计算字符串的大小?

c# windows win2d

8
推荐指数
1
解决办法
1934
查看次数

任务栏上的应用程序图标具有透明背景(UWA)

我正在制作通用Windows应用程序,我希望任务栏上的应用程序图标具有透明背景,因此它不在彩色框中.

许多微软自己的股票应用都是这样的(邮件,照片,Xbox等),我知道它可以完成,因为我偶然做到了.但是我使用的图标太大了,当我使用正确尺寸的图标时它停止工作.我已经尝试过再次使用旧的太大的图标,它仍然无法正常工作.

在此输入图像描述

在应用程序清单中设置图块背景只会使背景成为用户主题颜色而不是实际透明,所以我必须做其他事情,我对Square 44x44徽标的所有资产当然都有透明背景但我只是得到了瓷砖背景颜色哪里什么都没有.

c# windows xaml win-universal-app uwp

7
推荐指数
1
解决办法
2169
查看次数

将SSBO绑定到片段着色器

我有一个SSBO,它为屏幕上的每个像素存储vec4颜色值,并在主循环之前通过计算着色器预先填充值.

我现在正试图在屏幕上获取这些数据,我猜这涉及到使用片段着色器(虽然如果你知道一个更好的方法,我可以接受建议)

所以我试图将缓冲区或至少其中的数据添加到片段着色器中,以便我可以将每个片段的颜色设置为缓冲区中的相应值,但我找不到任何方法这样做?

有人告诉我,我可以将SSBO绑定到片段着色器,但我不知道该怎么做?我的其他想法是以某种方式将数据从SSBO移动到纹理,但我也无法解决这个问题

更新:

作为回应thokra的优秀答案和以下评论是设置我的缓冲区的代码:

//Create the buffer
GLuint pixelBufferID;
glGenBuffers(1, &pixelBufferID);

//Bind it
glBindBuffer(GL_SHADER_STORAGE_BUFFER, pixelBufferID);

//Set the data of the buffer
glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(vec4) * window.getNumberOfPixels, new vec4[window.getNumberOfPixels], GL_DYNAMIC_DRAW);

//Bind the buffer to the correct interface block number
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, pixelBufferID);
Run Code Online (Sandbox Code Playgroud)

然后我调用计算着色器,这部分工作,我检查数据是否已正确填充.然后在我的片段着色器中,就像测试一样:

layout(std430, binding=0) buffer PixelBuffer
{
    vec4 data[];
} pixelBuffer

void main()
{
    gl_FragColor = pixelBuffer.data[660000];
}
Run Code Online (Sandbox Code Playgroud)

我注意到的是,它似乎需要越来越长的索引越高,因此在660000它实际上并没有崩溃,只是花了很多时间.

opengl glsl compute-shader fragment-shader

3
推荐指数
1
解决办法
6272
查看次数

纹理值被削减到0-1的范围?

简单的问题:

OpenGL默认情况下是否将纹理值剪辑到0-1范围内?如果它确实有一种方法来禁用它?

详细问题:

我有一个纹理,在创建时,我将一些默认值.

我创建RGBA值大小为16x16的纹理,如下所示:

//Generate the texture and get its ID
GLuint texID;
glGenTextures(1, &texID);

//Bind the texture
glBindTexture(GL_TEXTURE_2D, texID);

//Define the size of the texture
int width = 16;
int height = 16;
int numberOfElementsPerTexel = 4;
int size = width * height * numberOfElementsPerTexel;

//Create an empty array of texel data
float data[size];
std::fill_n(data, size, 0.0f);

//Add the empty data to the texture
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, GL_RGBA, GL_FLOAT, data);
Run Code Online (Sandbox Code Playgroud)

为了测试这在我创建和填充纹理后正常工作,我检查内容如下:

//Bind the texture
glBindTexture(GL_TEXTURE_2D, texID); …
Run Code Online (Sandbox Code Playgroud)

c++ opengl textures

3
推荐指数
1
解决办法
1816
查看次数

如何避免使用不同类型的C++执行相同操作的多个函数

我有一个用于OpenGL缓冲区的C++类,它有许多setData()函数来解释缓冲区可能包含的不同类型的数据,例如:ints:

void Buffer::setData(int* data)
{
    //Bind the buffer
    bind();

    //Input the data into the buffer based on the type
    glBufferData(type, sizeof(int) * size, data, GL_DYNAMIC_DRAW);
}
Run Code Online (Sandbox Code Playgroud)

这对于函数的每个版本都是相同的,然后只有变化的东西sizeof(int)变成了sizeof(<other type>)

我想知道是否有办法解决这个问题?我考虑过的一种可能性是泛型变量,例如var?我知道var本身在C++中不存在但是有一些等价物吗?

c++

1
推荐指数
1
解决办法
86
查看次数

如何返回满足条件C#的ObservableCollection中的所有项

我正在尝试找到一种巧妙的方法来查找符合特定条件的可观察集合中的所有值.对于这个示例来保持简单,让我们说它的集合包含int,我试图找到大于5的所有项目.

我目前所知道的最好的方法就是这样

ObservableCollection<Int> findAllGreaterThanFive (ObservableCollection<Int> numbers)
{
    ObservableCollection<Int> numbersGreaterThanFive;

    foreach(Int number in numbers)
    {
        if (number > 5)
        {
            numbersGreaterThanFive.add(number);    
        }
    }

    return numbersGreaterThanFive;
}
Run Code Online (Sandbox Code Playgroud)

显然忽略任何利用我正在寻找的事实的简单解决方案我需要一个适用于任何条件的任何类型的ObservableCollection的解决方案.我只是想知道是否使用foreach循环检查每个项目,条件是最好的方法吗?

c#

1
推荐指数
2
解决办法
7870
查看次数