小编Ruk*_*uks的帖子

为什么精灵不能在OpenGL中渲染?

我试图在OpenGL中渲染2D(屏幕协调)精灵.然而,当我编译它时,它没有显示出来.我看到代码很好(甚至没有任何着色器编译错误,也没有任何其他错误).我也设置了矩阵(我怀疑这是导致问题的原因,那就是启动混乱!!)

顺便说一句,这是源代码(没有调试,简而言之): -

main.cpp中

// Including all required headers here...

#include <iostream>

#define GLEW_STATIC
#include <GL/glew.h>

#include <GLFW/glfw3.h>

#include "SOIL2/SOIL2.h"

#include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtc/matrix_transform.hpp>

const GLchar * vertexShaderSource =
    "#version 330 core\n"
    "layout(location = 0) in vec4 vertex;\n"
    "out vec2 TexCoords;\n"
    "uniform mat4 model;\n"
    "uniform mat4 projection;\n"
    "void main()\n"
    "{\n"
    "TexCoords = vertex.zw;\n"
    "gl_Position = projection * model * vec4(vertex.xy, 0.0, 1.0);\n"
    "}\0";

const GLchar * fragmentShaderSource =
    "#version 330 core\n"
    "in vec2 TexCoords;\n"
    "out vec4 color;\n"
    "uniform …
Run Code Online (Sandbox Code Playgroud)

c++ opengl glsl sprite glm-math

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

是否可以将纯虚函数覆盖到模板?

我不知道这是否可能:让我说我有一个接口定义:

virtual void func()=0;
Run Code Online (Sandbox Code Playgroud)

是否有可能在具体类中我重写它如下:

template <std::size_t  number> 
void func(){ /* do something with number... */ }
Run Code Online (Sandbox Code Playgroud)

谢谢!

c++ templates

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

标签 统计

c++ ×2

glm-math ×1

glsl ×1

opengl ×1

sprite ×1

templates ×1