Exemple #1
0
 /**
  *  @see CreateBufferHelloWorld
  *
  *  @alsymbols
  *  @alutfunref{CreateBufferFromFile}
  */
 Buffer CreateBufferFromFile(const StrCRef& file_path) const {
     assert(_initialized);
     ALuint name = OALPLUS_ALUTFUNC(CreateBufferFromFile)(
       file_path.is_nts() ? file_path.c_str() : file_path.str().c_str());
     OALPLUS_VERIFY_SIMPLE_ALUT(CreateBufferFromFile);
     return Buffer::FromRawName(BufferName(name));
 }
Exemple #2
0
	/// Deletes the value stored under @p name
	static void Delete(const StrCRef& name)
	{
		OGLPLUS_GLFUNC(DeleteNamedStringARB)(
			GLint(name.size()),
			name.c_str()
		);
		OGLPLUS_CHECK_SIMPLE(DeleteNamedStringARB);
	}
Exemple #3
0
	/// Pushes a debug group
	static void PushGroup(
		DebugSource source,
		GLuint id,
		StrCRef message
	)
	{
		PushGroup(source, id, message.size(), message.c_str());
	}
 static void ObjectLabel(const ObjectName<ObjTag>& object, StrCRef label) {
     OGLPLUS_GLFUNC(ObjectLabel)
     (GetGLName(object),
      ObjTypeOps<ObjTag>::ObjectType(),
      label.size(),
      label.c_str());
     OGLPLUS_VERIFY_SIMPLE(ObjectLabel);
 }
Exemple #5
0
	/// Checks if @p name is a stored string
	static bool IsA(const StrCRef& name)
	{
		GLboolean result = OGLPLUS_GLFUNC(IsNamedStringARB)(
			GLint(name.size()),
			name.c_str()
		);
		OGLPLUS_CHECK_SIMPLE(IsNamedStringARB);
		return result == GL_TRUE;
	}
Exemple #6
0
	Layout MakeLayout(const Font& font, StrCRef str)
	{
		CodePoints cps;
		UTF8ToCodePoints(str.begin(), str.size(), cps);

		Layout layout(MakeLayout(font, str.size()));
		layout.Set(cps.data(), cps.size());
		return std::move(layout);
	}
Exemple #7
0
	/// Gets the type of the named string stored under @p name
	static NamedStringType Type(const StrCRef& name)
	{
		GLint result = 0;
		OGLPLUS_GLFUNC(GetNamedStringivARB)(
			GLint(name.size()),
			name.c_str(),
			GL_NAMED_STRING_TYPE_ARB,
			&result
		);
		OGLPLUS_CHECK_SIMPLE(GetNamedStringivARB);
		return NamedStringType(GLenum(result));
	}
		/**
		 *  @overload
		 *
		 *  @glsymbols
		 *  @glfunref{PushDebugGroup}
		 */
		Group(
			DebugOutputSource source,
			GLuint id,
			StrCRef message
		)
		{
			OGLPLUS_GLFUNC(PushDebugGroup)(
				GLenum(source),
				id,
				message.size(),
				message.begin()
			);
			OGLPLUS_VERIFY_SIMPLE(PushDebugGroup);
		}
 /// Inserts a new message into the debug output
 static void InsertMessage(
   DebugOutputARBSource source,
   DebugOutputARBType type,
   GLuint id,
   DebugOutputARBSeverity severity,
   StrCRef message) {
     OGLPLUS_GLFUNC(DebugMessageInsertARB)
     (GLenum(source),
      GLenum(type),
      id,
      GLenum(severity),
      GLsizei(message.size()),
      message.c_str());
     OGLPLUS_VERIFY_SIMPLE(DebugMessageInsertARB);
 }
Exemple #10
0
	/// Store the @p value, of the specified @p type under @p name
	static void Set(
		NamedStringType type,
		const StrCRef& name,
		const StrCRef& value
	)
	{
		OGLPLUS_GLFUNC(NamedStringARB)(
			GLenum(type),
			GLint(name.size()),
			name.c_str(),
			GLint(value.size()),
			value.c_str()
		);
		OGLPLUS_CHECK_SIMPLE(NamedStringARB);
	}
Exemple #11
0
	/** Finds the location / index of the fragment data specified
	 *  by @p identifier in a @p program. If active_only is true then
	 *  throws if no such fragment data output exists or if it is not active.
	 *
	 *  @glsymbols
	 *  @glfunref{GetFragDataLocation}
	 */
	static GLint GetLocation(
		ProgramName program,
		StrCRef identifier,
		bool active_only
	)
	{
		GLint result = OGLPLUS_GLFUNC(GetFragDataLocation)(
			GetGLName(program),
			identifier.c_str()
		);
		OGLPLUS_CHECK(
			GetFragDataLocation,
			ProgVarError,
			Program(program).
			Identifier(identifier)
		);
		OGLPLUS_HANDLE_ERROR_IF(
			active_only && (result < 0),
			GL_INVALID_OPERATION,
			MsgGettingInactive(),
			ProgVarError,
			Program(program).
			Identifier(identifier)
		);
		return result;
	}
Exemple #12
0
	/// Inserts a new message into the debug output
	static void InsertMessage(
		DebugSource source,
		DebugType type,
		GLuint id,
		DebugSeverity severity,
		StrCRef message
	)
	{
		InsertMessage(
			source,
			type,
			id,
			severity,
			message.size(),
			message.c_str()
		);
	}
Exemple #13
0
 /**
  *  @see GetLocation
  *  @see QueryLocation
  *
  *  @glsymbols
  *  @glfunref{BindFragDataLocation}
  */
 static void BindLocation(
   ProgramName program, FragDataSlot location, StrCRef identifier) {
     OGLPLUS_GLFUNC(BindFragDataLocation)
     (GetGLName(program), GLuint(location), identifier.c_str());
     OGLPLUS_CHECK(
       BindFragDataLocation,
       ProgVarError,
       Program(program).Identifier(identifier).Index(GLuint(location)));
 }
Exemple #14
0
    /**
     *  @see LoadMemoryFromFileNormalized
     *  @see LoadMemoryHelloWorldNormalized
     *
     *  @alsymbols
     *  @alutfunref{LoadMemoryFromFile}
     */
    std::vector<ALubyte> LoadMemoryFromFile(
      const StrCRef& file_path,
      DataFormat* data_format,
      ALfloat* frequency) const {
        ::ALenum format = 0;
        ::ALsizei size = 0;
        ::ALvoid* ptr = OALPLUS_ALUTFUNC(LoadMemoryFromFile)(
          file_path.is_nts() ? file_path.c_str() : file_path.str().c_str(),
          &format,
          &size,
          frequency);
        OALPLUS_CHECK_SIMPLE_ALUT(LoadMemoryFromFile);

        _free_on_scope_exit cleaner = {ptr};
        OALPLUS_FAKE_USE(cleaner);

        if(data_format)
            *data_format = DataFormat(format);

        return _load_memory(ptr, size);
    }
Exemple #15
0
	/// Gets the value stored under @p name
	static String Get(const StrCRef& name)
	{
		GLint len = 0;
		OGLPLUS_GLFUNC(GetNamedStringivARB)(
			GLint(name.size()),
			name.c_str(),
			GL_NAMED_STRING_LENGTH_ARB,
			&len
		);
		OGLPLUS_CHECK_SIMPLE(GetNamedStringivARB);

		String result(len, '\0');
		OGLPLUS_GLFUNC(GetNamedStringARB)(
			GLint(name.size()),
			name.c_str(),
			len,
			&len,
			&result.front()
		);
		OGLPLUS_CHECK_SIMPLE(GetNamedStringARB);
		return std::move(result);

	}
Exemple #16
0
 /** This function binds the location of the vertex attribute
  *  @c vertex_attrib to the shader variable identified by
  *  @c identifier.
  */
 void BindLocation(
     VertexAttribSlot vertex_attrib_slot,
     StrCRef identifier
 )
 {
     OGLPLUS_GLFUNC(BindAttribLocation)(
         _name,
         GLuint(vertex_attrib_slot),
         identifier.c_str()
     );
     OGLPLUS_CHECK(
         BindAttribLocation,
         ProgVarError,
         Program(*this).
         Identifier(identifier).
         Index(GLuint(vertex_attrib_slot))
     );
 }
 /** Finds the location of the subroutine uniform specified
  *  by @p identifier in a @p program. If active_only is true then
  *  throws if no such subroutine exists or if it is not active.
  *
  *  @glsymbols
  *  @glfunref{GetSubroutineUniformLocation}
  */
 static GLint GetLocation(
   ProgramName program,
   ShaderType stage,
   StrCRef identifier,
   bool active_only) {
     GLint result = OGLPLUS_GLFUNC(GetSubroutineUniformLocation)(
       GetGLName(program), GLenum(stage), identifier.c_str());
     OGLPLUS_CHECK(
       GetSubroutineUniformLocation,
       ProgVarError,
       Program(program).Identifier(identifier).EnumParam(stage));
     OGLPLUS_HANDLE_ERROR_IF(
       active_only && (result < 0),
       GL_INVALID_OPERATION,
       MsgGettingInactive(),
       ProgVarError,
       Program(program).Identifier(identifier).EnumParam(stage));
     return result;
 }
    /** Finds the location / index of the subroutine specified
     *  by @p identifier in the @p stage of a @p program. If active_only
     *  is true then throws if no such subroutine exists or if it is
     *  not active.
     *
     *  @glsymbols
     *  @glfunref{GetSubroutineIndex}
     */
    static GLint GetLocation(
      ProgramName program,
      ShaderType stage,
      StrCRef identifier,
      bool active_only) {
        GLuint result = OGLPLUS_GLFUNC(GetSubroutineIndex)(
          GetGLName(program), GLenum(stage), identifier.c_str());
        OGLPLUS_CHECK(
          GetSubroutineIndex,
          ProgVarError,
          Program(program).Identifier(identifier).EnumParam(stage));
        OGLPLUS_HANDLE_ERROR_IF(
          active_only && (result == GL_INVALID_INDEX),
          GL_INVALID_OPERATION,
          MsgGettingInactive(),
          ProgVarError,
          Program(program).Identifier(identifier).EnumParam(stage));

        if(result == GL_INVALID_INDEX) {
            return -1;
        }
        return GLint(result);
    }
Exemple #19
0
 void Set(StrCRef str) {
     Set(UTF8ToCodePoints(str.begin(), str.size()));
 }
Exemple #20
0
	GLSLString(const StrCRef& str)
	 : _str(str.begin())
	 , _len(GLint(str.size()))
	{ }
oglplus::Program SpectraSharedObjects::BuildProgramWithXFB(
	const char* prog_name,
	const char** xfb_varyings,
	std::size_t xfb_var_count,
	bool separate_attribs
)
{
	using namespace oglplus;

	Program prog = Program(ObjectDesc(prog_name));

	std::ifstream prog_file;
	OpenResourceFile(prog_file, "glsl", prog_name, ".txt");

	const std::size_t linesize = 1024;
	char line[1024] = {'\0'};

	int line_no = 0;
	while(prog_file.getline(line, linesize).good())
	{
		std::size_t line_len = prog_file.gcount();
		++line_no;
		auto types = EnumValueRange<ShaderType>();
		ShaderType type = ShaderType::Fragment;
		std::size_t name_len = 0;
		while(!types.Empty())
		{
			type = types.Front();
			StrCRef name = EnumValueName(type);
			name_len = name.size();
			if(std::strncmp(line, name.c_str(), name.size()) == 0)
				break;
			types.Next();
		}
		if(types.Empty())
		{
			wxString message = wxString::Format(
				wxGetTranslation(wxT(
					"Invalid shader type in program '%s' "\
					"on line %d: '%s'"
				)),
				wxString(prog_name, wxConvUTF8).c_str(),
				line_no,
				wxString(line, wxConvUTF8).c_str()
			);
			throw std::runtime_error(
				(const char*)message.mb_str(wxConvUTF8)
			);
		}

		// rtrim the name
		for(std::size_t i = name_len+1; i!=line_len; ++i)
		{
			if(std::isspace(line[i]))
			{
				line[i] = '\0';
				break;
			}
		}

		std::ifstream shader_file;
		OpenResourceFile(shader_file, "glsl", line+name_len+1, ".glsl");

		Shader shader(type);
		shader.Source(GLSLSource::FromStream(shader_file));
		shader.Compile();

		prog.AttachShader(shader);
	}

	if(xfb_varyings && xfb_var_count)
	{
		prog.TransformFeedbackVaryings(
			xfb_var_count,
			xfb_varyings,
			separate_attribs
			?TransformFeedbackMode::SeparateAttribs
			:TransformFeedbackMode::InterleavedAttribs
		);
	}

	prog.Link().Use();
	return std::move(prog);
}
Exemple #22
0
	void Set(StrCRef str)
	{
		Set(str.begin(), str.size());
	}