Merge remote branch 'origin/master'
This commit is contained in:
commit
0f823dd419
7 changed files with 63 additions and 21 deletions
|
@ -56,18 +56,15 @@ std::string path::separator()
|
|||
std::string path::executable_path()
|
||||
{
|
||||
std::string result;
|
||||
|
||||
const size_t MAXPATHLEN = 2048;
|
||||
std::vector<char> buf(MAXPATHLEN);
|
||||
|
||||
#if defined(__APPLE__)
|
||||
CFURLRef bundleURL;
|
||||
CFStringRef pathStr;
|
||||
|
||||
CFBundleRef mainBundle = CFBundleGetMainBundle();
|
||||
|
||||
bundleURL = CFBundleCopyExecutableURL(mainBundle);
|
||||
pathStr = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);
|
||||
CFStringGetCString(pathStr, path, MAXPATHLEN, kCFStringEncodingASCII);
|
||||
|
||||
result.assign(&path[0]);
|
||||
CFURLRef bundleURL = CFBundleCopyExecutableURL(mainBundle);
|
||||
CFStringRef pathStr = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);
|
||||
CFStringGetCString(pathStr, buf.data(), buf.size(), kCFStringEncodingASCII);
|
||||
|
||||
CFRelease(pathStr);
|
||||
CFRelease(bundleURL);
|
||||
|
@ -77,11 +74,10 @@ std::string path::executable_path()
|
|||
DWORD ret = GetModuleFileName( NULL, &lpFname[0], MAXPATHLEN );
|
||||
result.assign(&lpFname[0]);
|
||||
#elif defined(__USE_POSIX)
|
||||
const size_t MAXPATHLEN = 2048;
|
||||
std::vector<char> buf(MAXPATHLEN);
|
||||
readlink("/proc/self/exe", buf.data(), buf.size());
|
||||
result.assign(buf.data());
|
||||
#endif
|
||||
result.assign(buf.data());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ public:
|
|||
~shader();
|
||||
|
||||
enum code_type {
|
||||
vertex, //<
|
||||
vertex,
|
||||
fragment,
|
||||
geometry,
|
||||
compute
|
||||
|
@ -36,7 +36,8 @@ public:
|
|||
|
||||
int uniform_location(std::string const & name) const;
|
||||
|
||||
template<typename T> shader & bind(std::string const & name, T&& value)
|
||||
template<typename T>
|
||||
shader & bind(std::string const & name, T&& value)
|
||||
{
|
||||
int location = uniform_location(name);
|
||||
if (location >= 0)
|
||||
|
|
|
@ -49,6 +49,8 @@ class texture {
|
|||
void set_wrap(wrap_mode w);
|
||||
wrap_mode wrap() const { return _wrap; }
|
||||
|
||||
void generate_mipmaps();
|
||||
|
||||
protected:
|
||||
|
||||
shared_ptr<image> _image;
|
||||
|
|
|
@ -14,6 +14,10 @@ namespace pw {
|
|||
|
||||
class command {
|
||||
|
||||
};
|
||||
|
||||
class mesh_command : command {
|
||||
|
||||
// shader
|
||||
// vertexarray
|
||||
|
||||
|
@ -26,9 +30,9 @@ class queue {
|
|||
|
||||
struct triangle_renderer
|
||||
{
|
||||
GLuint vbo = 0;
|
||||
GLuint vao = 0;
|
||||
GLuint shader_programme = 0;
|
||||
// GLuint vbo = 0;
|
||||
// GLuint vao = 0;
|
||||
// GLuint shader_programme = 0;
|
||||
|
||||
shader shader_p;
|
||||
mesh amesh;
|
||||
|
@ -42,11 +46,12 @@ struct triangle_renderer
|
|||
void setup()
|
||||
{
|
||||
mesh::vertex3array_t vertices = {
|
||||
{ 0.0f, 0.5f, 0.0f}
|
||||
,{ 0.5f, -0.5f, 0.0f}
|
||||
,{-0.5f, -0.5f, 0.0f}
|
||||
{ 0.0f, 0.5f, 0.0f} // 0
|
||||
,{ 0.5f, -0.5f, 0.0f} // 1
|
||||
,{-0.5f, -0.5f, 0.0f} // 2
|
||||
};
|
||||
|
||||
// actual indices
|
||||
mesh::indexarray_t indices = { 0, 1, 2};
|
||||
|
||||
amesh.set_indices(indices);
|
||||
|
@ -109,6 +114,27 @@ struct triangle_renderer
|
|||
frag_colour = input_color;
|
||||
})";
|
||||
|
||||
|
||||
|
||||
const char* vertex_shader_2 = R"(
|
||||
#version 400
|
||||
in vec3 vertex_p;
|
||||
in vec3 normal_p;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(vp, 1.0);
|
||||
}
|
||||
)";
|
||||
|
||||
const char *fragment_shader_2 = R"(
|
||||
#version 400
|
||||
uniform vec4 input_color = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
out vec4 frag_colour;
|
||||
void main() {
|
||||
frag_colour = input_color;
|
||||
})";
|
||||
|
||||
|
||||
shader_p.set_source(fragment_shader,shader::fragment);
|
||||
shader_p.set_source(vertex_shader,shader::vertex);
|
||||
|
||||
|
|
|
@ -116,7 +116,6 @@ struct shader::impl
|
|||
|
||||
debug::e() << info_log.get();
|
||||
|
||||
|
||||
/* Handle the error in an appropriate way such as displaying a message or writing to a log file. */
|
||||
/* In this simple program, we'll just leave */
|
||||
|
||||
|
|
|
@ -44,6 +44,9 @@ struct texture::impl {
|
|||
|
||||
glSamplerParameteri(_texture_sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
|
||||
// glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
// glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
|
||||
glBindTexture(gl_shape(),0);
|
||||
}
|
||||
|
||||
|
@ -51,6 +54,11 @@ struct texture::impl {
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
void generate_mipmaps()
|
||||
{
|
||||
glGenerateMipmap(gl_shape());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -92,5 +100,10 @@ void texture::set_wrap(wrap_mode w)
|
|||
_wrap = w;
|
||||
}
|
||||
|
||||
void texture::generate_mipmaps()
|
||||
{
|
||||
_impl->generate_mipmaps();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -30,6 +30,11 @@ struct vertex_array::impl {
|
|||
|
||||
void create(const mesh& m)
|
||||
{
|
||||
// not sure ...
|
||||
if (ready()) {
|
||||
destroy();
|
||||
}
|
||||
|
||||
glGenVertexArrays(1,&_vao);
|
||||
glBindVertexArray(_vao);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue