Skip to content

Commit

Permalink
debug shader compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
pragma37 committed Jul 29, 2021
1 parent 10ac833 commit 44a4539
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
28 changes: 16 additions & 12 deletions Malt/GL/Shader.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,22 +189,29 @@ def remove_line_directive_paths(source):

def compile_gl_program(vertex, fragment):
status = gl_buffer(GL_INT,1)
length = gl_buffer(GL_INT,1)
info_log = gl_buffer(GL_BYTE, 1024)

error = ""

def compile_shader (source, shader_type):
shader = glCreateShader(shader_type)
glShaderSource(shader, source)

source_ascii = source.encode('ascii')

print("DEBUG SOURCE -------------------")
print(source_ascii)

import ctypes
c_shader = GLuint(shader)
c_count = GLsizei(1)
c_source = (ctypes.c_char_p * 1)(source_ascii)
c_length = (GLint * 1)(len(source_ascii))

glShaderSource.wrappedOperation(c_shader, c_count, c_source, c_length)

glCompileShader(shader)

glGetShaderiv(shader, GL_COMPILE_STATUS, status)
if status[0] == GL_FALSE:
try: #BGL
glGetShaderInfoLog(shader, 1024, length, info_log)
except: #PYOPENGL
info_log = glGetShaderInfoLog(shader)
info_log = glGetShaderInfoLog(shader)
nonlocal error
error += 'SHADER COMPILER ERROR :\n' + buffer_to_string(info_log)

Expand All @@ -223,10 +230,7 @@ def compile_shader (source, shader_type):

glGetProgramiv(program, GL_LINK_STATUS, status)
if status[0] == GL_FALSE:
try: #BGL
glGetProgramInfoLog(program, 1024, length, info_log)
except: #PYOPENGL
info_log = glGetProgramInfoLog(program)
info_log = glGetProgramInfoLog(program)
error += 'SHADER LINKER ERROR :\n' + buffer_to_string(info_log)

return (program, error)
Expand Down
6 changes: 2 additions & 4 deletions Malt/Pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@

class Pipeline(object):

GLSL_HEADER = '''
#version 410 core
#extension GL_ARB_shading_language_include : enable
'''
GLSL_HEADER = "#version 410 core\n#extension GL_ARB_shading_language_include : enable\n"

SHADER_INCLUDE_PATHS = []

BLEND_SHADER = None
Expand Down

0 comments on commit 44a4539

Please sign in to comment.