<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[ifstream: hieroglyphen beim einlesen einer Binärdatei]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich möchte gerne eine einfache Binärdatei einlesen. Der Inhalt ist GLSL-Code. Jedoch stehen am Ende des Strings immer komische hieroglyphen.</p>
<pre><code>void main() {            
    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
</code></pre>
<p>Im Debugger steht:</p>
<pre><code>void main() {            
    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
ÍÍÍÍýýýý««««««««þ
</code></pre>
<pre><code>GLchar* Shader::readShader(std::string path) {
	std::ifstream inputStream;
	GLchar* input = 0;
	inputStream.open(path, std::ios::in);
	if(inputStream.good()) {
		inputStream.seekg(0, std::ios_base::end);
		GLuint size = inputStream.tellg();
		inputStream.seekg(0, std::ios_base::beg);
		input = new GLchar[size];
		inputStream.read(input, size);

		std::cout &lt;&lt; std::endl &lt;&lt; &quot;[OK] Loading Shader &lt;&quot; &lt;&lt; path &lt;&lt; &quot;&gt;&quot; &lt;&lt; std::endl;
	} else {
		std::cerr &lt;&lt; std::endl &lt;&lt; &quot;[ERROR] Loading Shader &lt;&quot; &lt;&lt; path &lt;&lt; &quot;&gt;&quot; &lt;&lt; std::endl;
	}
	return input;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/312504/ifstream-hieroglyphen-beim-einlesen-einer-binärdatei</link><generator>RSS for Node</generator><lastBuildDate>Sun, 02 Aug 2026 18:46:38 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/312504.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 06 Jan 2013 17:07:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to ifstream: hieroglyphen beim einlesen einer Binärdatei on Sun, 06 Jan 2013 17:07:44 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich möchte gerne eine einfache Binärdatei einlesen. Der Inhalt ist GLSL-Code. Jedoch stehen am Ende des Strings immer komische hieroglyphen.</p>
<pre><code>void main() {            
    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
</code></pre>
<p>Im Debugger steht:</p>
<pre><code>void main() {            
    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
ÍÍÍÍýýýý««««««««þ
</code></pre>
<pre><code>GLchar* Shader::readShader(std::string path) {
	std::ifstream inputStream;
	GLchar* input = 0;
	inputStream.open(path, std::ios::in);
	if(inputStream.good()) {
		inputStream.seekg(0, std::ios_base::end);
		GLuint size = inputStream.tellg();
		inputStream.seekg(0, std::ios_base::beg);
		input = new GLchar[size];
		inputStream.read(input, size);

		std::cout &lt;&lt; std::endl &lt;&lt; &quot;[OK] Loading Shader &lt;&quot; &lt;&lt; path &lt;&lt; &quot;&gt;&quot; &lt;&lt; std::endl;
	} else {
		std::cerr &lt;&lt; std::endl &lt;&lt; &quot;[ERROR] Loading Shader &lt;&quot; &lt;&lt; path &lt;&lt; &quot;&gt;&quot; &lt;&lt; std::endl;
	}
	return input;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2286864</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2286864</guid><dc:creator><![CDATA[aptem]]></dc:creator><pubDate>Sun, 06 Jan 2013 17:07:44 GMT</pubDate></item><item><title><![CDATA[Reply to ifstream: hieroglyphen beim einlesen einer Binärdatei on Sun, 06 Jan 2013 17:15:46 GMT]]></title><description><![CDATA[<p>Lasse mich raten die Hieroglyphen sind immer anders?<br />
Das liegt daran weil read() kein Nullbyte an den String einfügt.<br />
Es wird alles als String interpretiert bis irgendwann eine Null im Speicher steht.<br />
Das sind deine Hieroglyphen.<br />
Ich würde außerdem kein read() verwenden sondern die ganze Datei normal einlesen und in einem C++-String speichern.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2286872</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2286872</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Sun, 06 Jan 2013 17:15:46 GMT</pubDate></item><item><title><![CDATA[Reply to ifstream: hieroglyphen beim einlesen einer Binärdatei on Sun, 06 Jan 2013 17:18:45 GMT]]></title><description><![CDATA[<p>Nathan schrieb:</p>
<blockquote>
<p>Lasse mich raten die Hieroglyphen sind immer anders?</p>
</blockquote>
<p>Nein, die sind immer gleich.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2286876</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2286876</guid><dc:creator><![CDATA[aptem]]></dc:creator><pubDate>Sun, 06 Jan 2013 17:18:45 GMT</pubDate></item><item><title><![CDATA[Reply to ifstream: hieroglyphen beim einlesen einer Binärdatei on Sun, 06 Jan 2013 17:21:29 GMT]]></title><description><![CDATA[<p>OK, dann ist immer der gleiche Speicher nach input.<br />
Trotzdem fehlt da das Nullbyte.</p>
<pre><code>GLchar* Shader::readShader(std::string path) {
    std::ifstream inputStream;
    GLchar* input = 0;
    inputStream.open(path, std::ios::in);
    if(inputStream.good()) {
        inputStream.seekg(0, std::ios_base::end);
        GLuint size = inputStream.tellg();
        inputStream.seekg(0, std::ios_base::beg);
        input = new GLchar[size + 1]; // Ein Zeichen mehr für das Nullbyte
        inputStream.read(input, size);
        input[size] = 0; // Nullbyte anfügen

        std::cout &lt;&lt; std::endl &lt;&lt; &quot;[OK] Loading Shader &lt;&quot; &lt;&lt; path &lt;&lt; &quot;&gt;&quot; &lt;&lt; std::endl;
    } else {
        std::cerr &lt;&lt; std::endl &lt;&lt; &quot;[ERROR] Loading Shader &lt;&quot; &lt;&lt; path &lt;&lt; &quot;&gt;&quot; &lt;&lt; std::endl;
    }
    return input;
}
</code></pre>
<p>So, probiere das mal. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2286882</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2286882</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Sun, 06 Jan 2013 17:21:29 GMT</pubDate></item><item><title><![CDATA[Reply to ifstream: hieroglyphen beim einlesen einer Binärdatei on Sun, 06 Jan 2013 17:34:25 GMT]]></title><description><![CDATA[<p>Nein der Code klappt leider auch nicht. Ich habe ein bisschen rumprobiert und mit diesem Code kann ich zumindest den Vertexshader einlesen und kompilieren aber der Fragementshader hat mit diesem Code immer noch hieroglyphen.</p>
<p>Hier dein etwas abegewandelter Code:</p>
<pre><code>GLchar* Shader::readShader(std::string path) {
	std::ifstream inputStream;
	GLchar* input = 0;
	inputStream.open(path, std::ios::in);
	if(inputStream.good()) {
		inputStream.seekg(0, std::ios_base::end);
		GLuint size = inputStream.tellg();
		inputStream.seekg(0, std::ios_base::beg);
		input = new GLchar[size + 1];
		inputStream.read(input, size);
		input[size-2] = 0;

		std::cout &lt;&lt; std::endl &lt;&lt; &quot;[OK] Loading Shader &lt;&quot; &lt;&lt; path &lt;&lt; &quot;&gt;&quot; &lt;&lt; std::endl;
	} else {
		std::cerr &lt;&lt; std::endl &lt;&lt; &quot;[ERROR] Loading Shader &lt;&quot; &lt;&lt; path &lt;&lt; &quot;&gt;&quot; &lt;&lt; std::endl;
	}
	return input;
}
</code></pre>
<p>Vertexshader:</p>
<pre><code>void main() {            
    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
</code></pre>
<p>Fragmentshader:</p>
<pre><code>uniform sampler2D textureSampler;

void main() {
	//gl_FragColor = texture2D(textureSampler, vec2()gl_TexCoord[0]);
	gl_FragColor = vec4(1.0);
}
</code></pre>
<p>Debuggerausgabe des Fragmentshaders:</p>
<pre><code>uniform sampler2D textureSampler;

void main() {
	//gl_FragColor = texture2D(textureSampler, vec2()gl_TexCoord[0]);
	gl_FragColor = vec4(1.0);
}ÍÍÍ
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2286893</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2286893</guid><dc:creator><![CDATA[aptem]]></dc:creator><pubDate>Sun, 06 Jan 2013 17:34:25 GMT</pubDate></item><item><title><![CDATA[Reply to ifstream: hieroglyphen beim einlesen einer Binärdatei on Sun, 06 Jan 2013 17:50:37 GMT]]></title><description><![CDATA[<p>Ersetze</p>
<pre><code>inputStream.open(path, std::ios::in);
</code></pre>
<p>durch</p>
<pre><code>inputStream.open(path, std::ios::binary);
</code></pre>
<p>und mache die Änderungen was das Nullbyte betrifft wieder rückgängig.<br />
read() hätte nämlich gerne eine Binärfile, deswegen klappte das nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2286907</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2286907</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Sun, 06 Jan 2013 17:50:37 GMT</pubDate></item><item><title><![CDATA[Reply to ifstream: hieroglyphen beim einlesen einer Binärdatei on Sun, 06 Jan 2013 17:55:29 GMT]]></title><description><![CDATA[<p>Heeeyyy, das ist es. Danke dir!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2286915</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2286915</guid><dc:creator><![CDATA[aptem]]></dc:creator><pubDate>Sun, 06 Jan 2013 17:55:29 GMT</pubDate></item><item><title><![CDATA[Reply to ifstream: hieroglyphen beim einlesen einer Binärdatei on Sun, 06 Jan 2013 17:56:08 GMT]]></title><description><![CDATA[<p>Bitte.<br />
Pass nur noch auf, dass du das Array auch ordnungsgemäß wieder freigibst. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2286917</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2286917</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Sun, 06 Jan 2013 17:56:08 GMT</pubDate></item><item><title><![CDATA[Reply to ifstream: hieroglyphen beim einlesen einer Binärdatei on Sun, 06 Jan 2013 18:44:56 GMT]]></title><description><![CDATA[<p>Nathan schrieb:</p>
<blockquote>
<p>read() hätte nämlich gerne eine Binärfile, deswegen klappte das nicht.</p>
</blockquote>
<p>Das ist dem read egal. Das operiert eine Ebene höher als die binary-Einstellung. Es bekommt dann bloß bei bestimmten Eingangsdaten andere Ausgangsdaten, diese Umwandlung bekommt das read jedoch gar nicht mit.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2286954</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2286954</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sun, 06 Jan 2013 18:44:56 GMT</pubDate></item></channel></rss>