Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added new project with some basic shader tests regarding structs and …

…arrays of structs.
  • Loading branch information...
commit 27ee88b6722a0ee6f2a5bbdb235a9da85a7f3752 1 parent c414c3e
@mrwonko authored
View
3  code/Jedi Academy Renaissance.workspace
@@ -12,7 +12,7 @@
<Project filename="jarlib/jar-audio.cbp">
<Depends filename="jarlib/jar-core.cbp" />
</Project>
- <Project filename="renaissance/renaissance.cbp" active="1">
+ <Project filename="renaissance/renaissance.cbp">
<Depends filename="jarlib/jar-core.cbp" />
<Depends filename="jarlib/jar-input.cbp" />
<Depends filename="jarlib/jar-graphics.cbp" />
@@ -22,5 +22,6 @@
<Project filename="../dependencies/pluto-jar/jar-pluto.cbp">
<Depends filename="../dependencies/lua-5.1.4-jar/jar-lua.cbp" />
</Project>
+ <Project filename="r&amp;d/shadertests/shadertests.cbp" active="1" />
</Workspace>
</CodeBlocks_workspace_file>
View
25 code/r&d/shadertests/bin/shader.frag
@@ -0,0 +1,25 @@
+#version 110
+
+#define NUM_ELEMENTS 2
+
+struct Test
+{
+ vec3 color;
+};
+
+struct TestContainer
+{
+ Test array[NUM_ELEMENTS];
+};
+
+uniform TestContainer UniformStruct;
+
+void main()
+{
+ vec3 color = vec3(0, 0, 0);
+ for(int i = 0; i < NUM_ELEMENTS; ++i)
+ {
+ color += (1.f/NUM_ELEMENTS) * UniformStruct.array[i].color;
+ }
+ gl_FragColor = vec4(color, 1);
+}
View
56 code/r&d/shadertests/main.cpp
@@ -0,0 +1,56 @@
+#include <SFML/Graphics.hpp>
+#include <iostream>
+#include <cassert>
+#include <string>
+#include <fstream>
+
+int main()
+{
+ assert(sf::Shader::isAvailable() && "No shaders available on this system!");
+ sf::RenderWindow wnd(sf::VideoMode(800, 600), "Shader tests");
+
+ sf::Shader shader;
+ if(!shader.loadFromFile("shader.frag", sf::Shader::Fragment))
+ {
+ return 0;
+ }
+ shader.setParameter("UniformStruct.array[0].color", 255, 0, 0);
+ shader.setParameter("UniformStruct.array[1].color", 0, 0, 255);
+
+ sf::RectangleShape rect(sf::Vector2f(400, 300));
+ rect.setOrigin(200, 150);
+ rect.setPosition(400, 300);
+
+ while(wnd.isOpen())
+ {
+ // rendering (filling queue)
+ wnd.clear();
+
+ sf::RenderStates states;
+ states.shader = &shader;
+ if(1)
+ {
+ wnd.draw(rect, states);
+ }
+ else
+ {
+ wnd.draw(rect);
+ }
+
+ // logic
+ //poll events
+ sf::Event ev;
+ while(wnd.pollEvent(ev))
+ {
+ if(ev.type == sf::Event::Closed || (ev.type == sf::Event::KeyPressed && ev.key.code == sf::Keyboard::Escape))
+ {
+ wnd.close();
+ }
+ }
+
+
+ // buffer flipping (waits for rendering to finish if not done yet)
+ wnd.display();
+ }
+ return 0;
+}
View
51 code/r&d/shadertests/shadertests.cbp
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<CodeBlocks_project_file>
+ <FileVersion major="1" minor="6" />
+ <Project>
+ <Option title="shadertests" />
+ <Option pch_mode="2" />
+ <Option compiler="gcc" />
+ <Build>
+ <Target title="Debug">
+ <Option output="bin\shadertests" prefix_auto="1" extension_auto="1" />
+ <Option working_dir="bin" />
+ <Option object_output="obj\Debug\" />
+ <Option type="1" />
+ <Option compiler="gcc" />
+ <Compiler>
+ <Add option="-g" />
+ </Compiler>
+ </Target>
+ <Target title="Release">
+ <Option output="bin\shadertests" prefix_auto="1" extension_auto="1" />
+ <Option working_dir="bin" />
+ <Option object_output="obj\Release\" />
+ <Option type="1" />
+ <Option compiler="gcc" />
+ <Compiler>
+ <Add option="-O2" />
+ </Compiler>
+ <Linker>
+ <Add option="-s" />
+ </Linker>
+ </Target>
+ </Build>
+ <Compiler>
+ <Add option="-Wall" />
+ <Add option="-fexceptions" />
+ </Compiler>
+ <Linker>
+ <Add library="sfml-graphics" />
+ <Add library="sfml-window" />
+ <Add library="sfml-system" />
+ <Add library="opengl32" />
+ </Linker>
+ <Unit filename="main.cpp" />
+ <Extensions>
+ <code_completion />
+ <envvars />
+ <debugger />
+ <lib_finder disable_auto="1" />
+ </Extensions>
+ </Project>
+</CodeBlocks_project_file>
Please sign in to comment.
Something went wrong with that request. Please try again.