Przeglądaj źródła

The material stage is now on opengl 3.3 core

Panagiotis Christopoulos Charitos 15 lat temu
rodzic
commit
e25d60f74c

Plik diff jest za duży
+ 1 - 2
build/debug/Makefile


+ 3 - 2
shaders/Final.glsl

@@ -8,14 +8,15 @@
 
 uniform sampler2D rasterImage;
 in vec2 vTexCoords;
-out vec3 fragColor;
+layout(location = 0) out vec3 fragColor;
 
 void main()
 {
 	//if( gl_FragCoord.x > 0.5 ) discard;
 
 	fragColor.rgb = texture2D(rasterImage, vTexCoords).rgb;
-	fragColor.rgb = fragColor.rgb * vec3(1.0, 0.0, 1.0) + vec3(1.0, 0.0, 1.0);
+	
+	//fragColor = vec3(1.0, 0.0, 1.0);
 
 
 	//gl_FragColor.rgb = vec3(texture2D(rasterImage, vTexCoords).r);

+ 2 - 2
shaders/SimpleVert.glsl

@@ -3,8 +3,8 @@
 /// get the Normalized Display Coordinates ([-1,1]) simply by looking in the vertex
 /// position. The vertex positions of the quad are from 0.0 to 1.0 for both axis.
 
-#pragma anki attribute position 0
-in vec2 position;
+//#pragma anki attribute position 0
+layout(location = 0) in vec2 position;
 
 out vec2 vTexCoords;
 

+ 1 - 1
src/Main.cpp

@@ -385,7 +385,7 @@ int main(int argc, char* argv[])
 	}
 	catch(std::exception& e)
 	{
-		MESSAGE("Fatal error: " + e.what());
+		ERROR("Fatal error: " + e.what());
 		//abort();
 		return 1;
 	}

+ 15 - 15
src/Math/Quat.inl.h

@@ -7,38 +7,38 @@ namespace M {
 
 
 // constructor []
-inline Quat::Quat()
-	: x(0.0), y(0.0), z(0.0), w(1.0)
+inline Quat::Quat():
+	x(0.0), y(0.0), z(0.0), w(1.0)
 {}
 
 // constructor [float]
-inline Quat::Quat(float f)
-	: x(f), y(f), z(f), w(f)
+inline Quat::Quat(float f):
+	x(f), y(f), z(f), w(f)
 {}
 
 // constructor [float, float, float, float]
-inline Quat::Quat(float x_, float y_, float z_, float w_)
-	: x(x_), y(y_), z(z_), w(w_)
+inline Quat::Quat(float x_, float y_, float z_, float w_):
+	x(x_), y(y_), z(z_), w(w_)
 {}
 
 // constructor [vec2, float, float]
-inline Quat::Quat(const Vec2& v2, float z_, float w_)
-	: x(v2.x), y(v2.y), z(z_), w(w_)
+inline Quat::Quat(const Vec2& v2, float z_, float w_):
+	x(v2.x), y(v2.y), z(z_), w(w_)
 {}
 
 // constructor [vec3, float]
-inline Quat::Quat(const Vec3& v3, float w_)
-	: x(v3.x), y(v3.y), z(v3.z), w(w_)
+inline Quat::Quat(const Vec3& v3, float w_):
+	x(v3.x), y(v3.y), z(v3.z), w(w_)
 {}
 
 // constructor [vec4]
-inline Quat::Quat(const Vec4& v4)
-	: x(v4.x), y(v4.y), z(v4.z), w(v4.w)
+inline Quat::Quat(const Vec4& v4):
+	x(v4.x), y(v4.y), z(v4.z), w(v4.w)
 {}
 
 // constructor [quat]
-inline Quat::Quat(const Quat& b)
-	: x(b.x), y(b.y), z(b.z), w(b.w)
+inline Quat::Quat(const Quat& b):
+	x(b.x), y(b.y), z(b.z), w(b.w)
 {}
 
 // constructor [mat3]
@@ -282,7 +282,7 @@ inline void Quat::setIdentity()
 }
 
 // getIdentity
-inline const Quat::Quat& getIdentity()
+inline const Quat& Quat::getIdentity()
 {
 	static Quat ident(0.0, 0.0, 0.0, 1.0);
 	return ident;

+ 2 - 2
src/Renderer/BufferObjects/BufferObject.cpp

@@ -10,7 +10,7 @@ void BufferObject::create(GLenum target_, uint sizeInBytes_, const void* dataPtr
 {
 	// unacceptable usage_
 	RASSERT_THROW_EXCEPTION(usage_ != GL_STREAM_DRAW && usage_ != GL_STATIC_DRAW && usage_ != GL_DYNAMIC_DRAW);
-	RASSERT_THROW_EXCEPTION(sizeInBytes < 1); // unacceptable sizeInBytes
+	RASSERT_THROW_EXCEPTION(sizeInBytes_ < 1); // unacceptable sizeInBytes
 
 	usage = usage_;
 	target = target_;
@@ -41,7 +41,7 @@ void BufferObject::write(void* buff, size_t size)
 {
 	if(usage == GL_STATIC_DRAW)
 	{
-		throw EXCEPTION("Its not recomended to map GL_STATIC_DRAW BOs");
+		throw EXCEPTION("Its not recommended to map GL_STATIC_DRAW BOs");
 	}
 
 	bind();

+ 28 - 2
src/Renderer/Renderer.cpp

@@ -21,6 +21,32 @@ Renderer::Renderer(Object* parent):
 {}
 
 
+
+GLsizei const ElementCount = 6;
+GLsizeiptr const ElementSize = ElementCount * sizeof(uint);
+uint const ElementData[ElementCount] =
+{
+	0, 1, 2,
+	0, 2, 3
+};
+
+GLsizei const VertexCount = 4;
+GLsizeiptr const PositionSize = VertexCount * sizeof(Vec2);
+Vec2 const PositionData[VertexCount] =
+{
+	Vec2(-1.0f,-1.0f),
+	Vec2( 1.0f,-1.0f),
+	Vec2( 1.0f, 1.0f),
+	Vec2(-1.0f, 1.0f)
+};
+
+GLuint VertexArrayName;
+GLuint ProgramName;
+GLuint ArrayBufferName;
+GLuint ElementBufferName;
+
+
+
 //======================================================================================================================
 // init                                                                                                                =
 //======================================================================================================================
@@ -36,7 +62,7 @@ void Renderer::init(const RendererInitializer& initializer)
 	// a few sanity checks
 	if(width < 10 || height < 10)
 	{
-		throw EXCEPTION("Incorrect width");
+		throw EXCEPTION("Incorrect sizes");
 	}
 
 	// init the stages. Careful with the order!!!!!!!!!!
@@ -53,7 +79,7 @@ void Renderer::init(const RendererInitializer& initializer)
 	quadVertIndecesVbo = new Vbo(GL_ELEMENT_ARRAY_BUFFER, sizeof(quadVertIndeces), quadVertIndeces, GL_STATIC_DRAW);
 
 	globalVao = new Vao();
-	globalVao->attachArrayBufferVbo(*quadPositionsVbo, 0, 3, GL_FLOAT, false, 0, NULL);
+	globalVao->attachArrayBufferVbo(*quadPositionsVbo, 0, 2, GL_FLOAT, false, 0, NULL);
 	globalVao->attachElementArrayBufferVbo(*quadVertIndecesVbo);
 }
 

+ 2 - 2
src/Resources/ShaderProg.cpp

@@ -19,8 +19,8 @@
 std::string ShaderProg::stdSourceCode(
 	"#version 330 core\n"
 	//"precision lowp float;\n"
-	"#pragma optimize(on)\n"
-	"#pragma debug(off)\n"
+	//"#pragma optimize(on)\n"
+	//"#pragma debug(off)\n"
 );
 
 

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików