Skip to content
Permalink
Browse files

Window: move glEnable in internal init

Shader: added asserts
  • Loading branch information...
Dgame committed May 20, 2015
1 parent c2fc15d commit 83b2ce3ef2ccb82267d6103d98a210a0ca4bcc31
@@ -3,8 +3,8 @@ module Dgame.Graphic.Shader;
private:

import derelict.opengl3.gl;
import Dgame.Internal.m3;

import Dgame.Internal.m3;
import Dgame.Internal.Error;

@nogc
@@ -92,20 +92,12 @@ public:
*/
@nogc
void loadFromFile(string filename) const nothrow {
assert(_shader != 0, "Shader was not created so far");

char[] buffer = file_get_contents(filename);
scope(exit) unmake(buffer);

this.loadFrom(buffer);
}

/**
* Load the Shader-Source from a slice
*
* Note: The Shader will not be automatically compiled, use compile to do that by yourself
*/
@nogc
void loadFrom(char[] content) const nothrow {
const char* ptr = content.ptr;
const char* ptr = buffer.ptr;
glShaderSource(_shader, 1, &ptr, null);
}

@@ -116,6 +108,8 @@ public:
*/
@nogc
bool compile() const nothrow {
assert(_shader != 0, "Shader was not created so far");

glCompileShader(_shader);

int isCompiled = 0;
@@ -202,6 +202,8 @@ void _initGL() {
glDisable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);

glEnable(GL_TEXTURE_2D);

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

@@ -700,10 +700,8 @@ package(Dgame):
if (vertices.length == 0)
return;

if (texture) {
glEnable(GL_TEXTURE_2D);
if (texture)
texture.bind();
}

glVertexPointer(2, GL_FLOAT, Vertex.sizeof, &vertices[0].position.x);
glColorPointer(4, GL_FLOAT, Vertex.sizeof, &vertices[0].color.red);
@@ -48,14 +48,6 @@ <h1>Dgame.Graphic.Shader</h1>
<b>Note:</b><br>
The Shader will not be automatically compiled, use compile to do that by yourself<br><br>

</dd>
<dt><big><a name="Shader.loadFrom"></a>const nothrow @nogc void <u>loadFrom</u>(char[] <i>content</i>);
</big></dt>
<dd>Load the Shader-Source from a slice
<br><br>
<b>Note:</b><br>
The Shader will not be automatically compiled, use compile to do that by yourself<br><br>

</dd>
<dt><big><a name="Shader.compile"></a>const nothrow @nogc bool <u>compile</u>();
</big></dt>

0 comments on commit 83b2ce3

Please sign in to comment.
You can’t perform that action at this time.