小编Arc*_*ede的帖子

将纹理传递给着色器

我一直在尝试找出如何将纹理发送到着色器,但是我无法弄清楚。我的代码对我来说不错,但我的第二个纹理是黑色。

void setShaders() {

    glEnable (GL_TEXTURE_2D);
    v2 = glCreateShader(GL_VERTEX_SHADER);
    f2 = glCreateShader(GL_FRAGMENT_SHADER);    


    load_shader(v2,"a.vert");
    load_shader(f2,"a.frag");

    glCompileShader(v2);
    glCompileShader(f2);

    p = glCreateProgram();

    glAttachShader(p,v2);
    glAttachShader(p,f2);

    GLubyte* textura=LoadImageToTexture("d.jpg");
    GLubyte* textura2=LoadImageToTexture("n.jpg");

    GLuint texturaID[2];
    glGenTextures(2, texturaID);

    glBindTexture(GL_TEXTURE_2D, texturaID[0]);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA, w, h, 0, GL_RGBA,GL_UNSIGNED_BYTE,(GLvoid*)textura );


    glBindTexture(GL_TEXTURE_2D, texturaID[1]);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexImage2D(GL_TEXTURE_2D,1,GL_RGBA, w, h, 0, GL_RGBA,GL_UNSIGNED_BYTE,(GLvoid*)textura2 );


    glLinkProgram(p);
    glUseProgram(p);
    GLint baseImageLoc = glGetUniformLocation(p, "tex");
    GLint normImage = glGetUniformLocation(p, "norm");
    glUniform1i(baseImageLoc, 0);
    glUniform1i(normImage, 1);

    glActiveTexture(GL_TEXTURE0 + 0);
    glBindTexture(GL_TEXTURE_2D, texturaID[0]);

    glActiveTexture(GL_TEXTURE0 + 1);
    glBindTexture(GL_TEXTURE_2D, texturaID[1]);

}
Run Code Online (Sandbox Code Playgroud)

着色器[顶点]

void …
Run Code Online (Sandbox Code Playgroud)

opengl glsl

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

避免全索引扫描

我使用 MySQL 员工的测试数据库 - 测试数据库 我想优化查询

SELECT emp_no, SUM(salary)
FROM salaries
WHERE from_date < '1999-01-01'
group by emp_no;
Run Code Online (Sandbox Code Playgroud)

查询费用:287790

哪些索引可以帮助我?

我尝试使用emp_noandsalaryemp_noand创建索引from_date,但没有结果。有一个完整的扫描索引。

也尝试使用OVER(PARTITION BY)代替GROUP BY

SELECT emp_no, SUM(salary) OVER (PARTITION by emp_no)
FROM salaries  
WHERE from_date < '1999-01-01'; 
Run Code Online (Sandbox Code Playgroud)

OVER例如,避免完整索引扫描或使用GROUP BY

mysql query-optimization

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

Oracle v() 与 nv() 函数

oracle apex 中的v()nv()函数有什么区别?

我遇到了这个nv()函数,我唯一能让谷歌吐槽的就是这个nvl()函数。

apex_custom_auth.post_login(   
                p_uname      => l_authenticated_username,  
                p_session_id => nv('APP_SESSION'),  
                p_app_page   =>
apex_application.g_flow_id||':'||nvl(apex_application.g_flow_step_id,0));
Run Code Online (Sandbox Code Playgroud)

sql oracle plsql oracle-apex

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

我应该学习什么语言作为C(和衍生物)的桥梁

我学到的第一门语言是PHP,但最近我学习了Python.由于这些都是"高级"语言,我发现它们有点难以接受.我也试过学习Objective-C,但我放弃了.

那么,我应该学习什么语言来桥接Python到C.

c python

4
推荐指数
3
解决办法
809
查看次数

Time in Docker container out of sync with host machine

I'm trying to connect to CosmosDB through my SpringBoot app. I have all of this working if I run the app with Spring or via Intellij. But, when I run the app in Docker I get the following error message:

com.azure.data.cosmos.CosmosClientException: The authorization token is not valid at the current time.
Please create another token and retry
(token start time: Thu, 26 Mar 2020 04:32:10 GMT, 
token expiry time: Thu, 26 Mar 2020 04:47:10 GMT, current server time: Tue, …
Run Code Online (Sandbox Code Playgroud)

docker

4
推荐指数
2
解决办法
2221
查看次数

Flux 不会在“then”之前等待元素完成

我无法理解这个问题,我不确定我做错了什么。

我想等待 Flux 结束然后Mono返回serverResponse

我已附上代码片段,它将doOnNext填充categoryIdToPrintRepository.

我已经查看了如何在通量结束后返回单声道,并发现了“then”,但在处理 onNextSite 之前仍然执行“then”方法,这会导致错误:

java.lang.IllegalArgumentException: 'producer' type is unknown to ReactiveAdapterRegistry
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

 public Mono<ServerResponse> retrieveCatalog(ServerRequest ignored) {
        return Mono.just("start").flatMap(id ->
                Flux.fromIterable(appSettings.getSites())
                        .subscribeOn(ForkJoinPoolScheduler.create("SiteCatalogScheduler"))
                        .doOnNext(this::onNextSite)
                        .then(Mono.from(ServerResponse.ok().body(categoryIdToPrintRepository.getSortedTreeValues(), String.class))));

    }

    private void onNextSite(Integer siteId) {
        IntStream.range(1, appSettings.getCatalogMaxValue()).parallel().forEach(catalogId -> {
            Optional<SiteCatalogCategoryDTO> cacheData =
                    siteCatalogCacheUseCaseService.getSiteCatalogResponseFromCache(siteId, catalogId);
            cacheData.ifPresentOrElse(siteCatalogCategoryDTO -> {/*do nothing already exist in cache*/},
                    () -> {
                    Mono<SiteCatalogCategoryDTO> catalogCategoryDTOMono = WebClient.create(getUri(siteId, catalogId))
                            .get().retrieve().bodyToMono(SiteCatalogCategoryDTO.class);
                    catalogCategoryDTOMono.subscribe(siteCatalogCategoryDTO ->
                            handleSiteServerResponse(siteCatalogCategoryDTO, siteId, catalogId));
            });
        });
    }


    private void handleSiteServerResponse(SiteCatalogCategoryDTO siteCatalogCategoryDTO, …
Run Code Online (Sandbox Code Playgroud)

java netty spring-boot project-reactor spring-webflux

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

CDK未更新

更新我的堆栈后运行 cdk deploy:

export function createTaskXXXX (stackScope: Construct, workflowContext: WorkflowContext) {
  const lambdaXXXX = new lambda.Function(stackScope, 'XXXXFunction', {
    runtime: Globals.LAMBDA_RUNTIME,
    memorySize: Globals.LAMBDA_MEMORY_MAX,
    code: lambda.Code.fromAsset(CDK_MODULE_ASSETS_PATH),
    handler: 'xxxx-handler.handler',
    timeout: Duration.minutes(Globals.LAMBDA_DURATION_2MIN),
    environment: {
      YYYY_ENV: (workflowContext.production) ? 'prod' : 'test',
      YYYY_A_LOCATION: `s3://${workflowContext.S3ImportDataBucket}/adata-workflow/split-input/`,
      YYYY_B_LOCATION: `s3://${workflowContext.S3ImportDataBucket}/bdata-workflow/split-input/`  <--- added
    }
  })
  lambdaXXXX.addToRolePolicy(new iam.PolicyStatement({
    effect: Effect.ALLOW,
    actions: ['s3:PutObject'],
    resources: [
        `arn:aws:s3:::${workflowContext.S3ImportDataBucket}/adata-workflow/split-input/*`,
        `arn:aws:s3:::${workflowContext.S3ImportDataBucket}/bdata-workflow/split-input/*` <---- added
    ]
  }))
Run Code Online (Sandbox Code Playgroud)

我意识到这些更改不会在 stack.template.json 中更新:

...
        "Runtime": "nodejs12.x",
        "Environment": {
          "Variables": {
            "YYYY_ENV": "test",
            "YYYY_A_LOCATION": "s3://.../adata-workflow/split-input/"
          }
        },
        "MemorySize": 3008,
        "Timeout": 120
      }
... …
Run Code Online (Sandbox Code Playgroud)

aws-cdk

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

Swift Spotify API 错误代码 405 添加到库?

我正在尝试使用 Spotify API 添加Track到用户的库,但收到 400 响应状态。我已经尝试过这个请求,并且由于标头令牌而Alamofire开始出现错误。postCountSpotify

这是代码的一部分:

func spotify_addToLibrary()
{

    self.spotify_verifySession(completion:{ success , auth in

        if !success
        {
            return
        }

        let postString                  = "ids=[\"\(self.trackid)\"]"
        let url: NSURL                  = NSURL(string: "https://api.spotify.com/v1/me/tracks")!
        var request                     = URLRequest(url: url as URL)
            request.cachePolicy         = .useProtocolCachePolicy
            request.timeoutInterval     = 8000
            request.addValue("application/x-www-form-urlencoded;charset=UTF-8", forHTTPHeaderField: "Content-Type")
            request.addValue("application/json", forHTTPHeaderField: "Accept")
            request.addValue("Bearer \(auth.session.accessToken!)", forHTTPHeaderField: "Authorization")
            request.httpMethod = "post"
            request.httpBody   = postString.data(using: .utf8)

         URLSession.shared.dataTask(with: request) {data, response, err in

                    if err == nil
                    {
                        print("Add to Library …
Run Code Online (Sandbox Code Playgroud)

spotify swift

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

Spring Reactor doOnNext,它被执行了吗?

我在玩反应堆

public @NotNull Mono<ServerResponse> findXXXXSse(final ServerRequest request) {
    return request.bodyToMono(XXXXSearch.class)
            .doOnNext(this::validate)
            .flatMap(this::findXXXXSse)
            .switchIfEmpty(this.emptyBodyException());
}
Run Code Online (Sandbox Code Playgroud)

我想知道使用.doOnNext(this::validate)是否正确。从我的角度来看,我不确定在findXXXXSse?之前调用 validate 。

我错了吗?

spring reactive-programming spring-webflux

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

检查内存是否在堆上?

我有一个类,constructor它将对象的地址作为参数.

MyClass(OtherClass * otherClass);
Run Code Online (Sandbox Code Playgroud)

Destructor这个类中,我尝试delete了实例OtherClass.

~MyClass() {
    if(otherClass != nullptr) {
        delete otherClass;
    }
}
Run Code Online (Sandbox Code Playgroud)

我遇到的问题是,当我调用constructor它时,我用一个元素来stack代替heap它来调用它,因此我将其称为如下:

MyClass myClass(&otherObject);

所以当myClass对象超出范围时,我得到一个例外.如果我的OtherObject变量是stackheap?或者?上声明的,我怎么能够喜欢?或者换句话说,我怎么知道我是否可以delete对象?

c++ memory-management

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