1
0
Fork 0

Compatibility fixes for Shaders 1.5

This commit is contained in:
MrDev023 2017-01-14 19:40:44 +01:00
parent eda25cf2c9
commit ae3320e067
4 changed files with 114 additions and 64 deletions

View file

@ -2,12 +2,8 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="00f293cb-c755-478c-9b6f-422f827454e0" name="Default" comment="">
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/res/shaders/fbo.frag" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/res/shaders/fbo.vert" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/globalgamejam/render/FrameBufferObject.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/res/shaders/main.frag" afterPath="$PROJECT_DIR$/res/shaders/main.frag" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/globalgamejam/game/MainGame.java" afterPath="$PROJECT_DIR$/src/globalgamejam/game/MainGame.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/globalgamejam/render/FrameBufferObject.java" afterPath="$PROJECT_DIR$/src/globalgamejam/render/FrameBufferObject.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/globalgamejam/render/Shaders.java" afterPath="$PROJECT_DIR$/src/globalgamejam/render/Shaders.java" />
</list>
<ignored path="$PROJECT_DIR$/out/" />
@ -23,7 +19,68 @@
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300" />
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="Shaders.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/globalgamejam/render/Shaders.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="476">
<caret line="47" column="47" lean-forward="false" selection-start-line="47" selection-start-column="47" selection-end-line="47" selection-end-column="47" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="main.vert" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/res/shaders/main.vert">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="19" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="main.frag" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/res/shaders/main.frag">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="136">
<caret line="8" column="2" lean-forward="false" selection-start-line="8" selection-start-column="2" selection-end-line="8" selection-end-column="2" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="fbo.vert" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/res/shaders/fbo.vert">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="272">
<caret line="16" column="28" lean-forward="false" selection-start-line="16" selection-start-column="28" selection-end-line="16" selection-end-column="28" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="fbo.frag" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/res/shaders/fbo.frag">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="170">
<caret line="10" column="50" lean-forward="false" selection-start-line="10" selection-start-column="50" selection-end-line="10" selection-end-column="50" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="FrameBufferObject.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/globalgamejam/render/FrameBufferObject.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1222">
<caret line="5" column="35" lean-forward="false" selection-start-line="5" selection-start-column="35" selection-end-line="5" selection-end-column="35" />
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
@ -75,11 +132,11 @@
<option value="$PROJECT_DIR$/src/globalgamejam/game/Game.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/tiles/FBOTile.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/game/MainGame.java" />
<option value="$PROJECT_DIR$/res/shaders/main.frag" />
<option value="$PROJECT_DIR$/res/shaders/fbo.vert" />
<option value="$PROJECT_DIR$/res/shaders/fbo.frag" />
<option value="$PROJECT_DIR$/src/globalgamejam/render/Shaders.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/render/FrameBufferObject.java" />
<option value="$PROJECT_DIR$/res/shaders/fbo.frag" />
<option value="$PROJECT_DIR$/res/shaders/main.frag" />
</list>
</option>
</component>
@ -535,7 +592,7 @@
</component>
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
<editor active="false" />
<editor active="true" />
<layout>
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
@ -546,7 +603,7 @@
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32980973" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32980973" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
<window_info id="Properties" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
@ -924,50 +981,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/res/shaders/main.frag">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="136">
<caret line="8" column="19" lean-forward="false" selection-start-line="8" selection-start-column="18" selection-end-line="8" selection-end-column="19" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/res/shaders/main.vert">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="19" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/res/shaders/fbo.vert">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="272">
<caret line="16" column="28" lean-forward="false" selection-start-line="16" selection-start-column="28" selection-end-line="16" selection-end-column="28" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/res/shaders/fbo.frag">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="170">
<caret line="10" column="50" lean-forward="false" selection-start-line="10" selection-start-column="50" selection-end-line="10" selection-end-column="50" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/render/FrameBufferObject.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="665">
<caret line="93" column="122" lean-forward="false" selection-start-line="93" selection-start-column="122" selection-end-line="93" selection-end-column="122" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#3230#3231#0" expanded="true" />
<element signature="e#3282#3283#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/render/Texture.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="359">
@ -990,8 +1003,48 @@
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/render/Shaders.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="255">
<caret line="19" column="51" lean-forward="false" selection-start-line="19" selection-start-column="51" selection-end-line="19" selection-end-column="51" />
<state relative-caret-position="476">
<caret line="47" column="47" lean-forward="false" selection-start-line="47" selection-start-column="47" selection-end-line="47" selection-end-column="47" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/render/FrameBufferObject.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1222">
<caret line="5" column="35" lean-forward="false" selection-start-line="5" selection-start-column="35" selection-end-line="5" selection-end-column="35" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/res/shaders/fbo.frag">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="170">
<caret line="10" column="50" lean-forward="false" selection-start-line="10" selection-start-column="50" selection-end-line="10" selection-end-column="50" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/res/shaders/fbo.vert">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="272">
<caret line="16" column="28" lean-forward="false" selection-start-line="16" selection-start-column="28" selection-end-line="16" selection-end-column="28" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/res/shaders/main.vert">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="19" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/res/shaders/main.frag">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="136">
<caret line="8" column="2" lean-forward="false" selection-start-line="8" selection-start-column="2" selection-end-line="8" selection-end-column="2" />
<folding />
</state>
</provider>

View file

@ -1,4 +1,4 @@
#version 330
#version 150
//Il ny a pas de layout(location=i) dans OpenGL < 3.3, mais tu peux utiliser glFragData[i] = myvalue à la place.
uniform sampler2D materialTex;
uniform vec4 color;
@ -6,8 +6,8 @@ uniform vec4 color;
in vec2 fragTexCoord;
in vec3 fragVert;
layout(location = 0) out vec4 finalColor;
//layout(location = 0) out vec4 finalColor;
void main() {
finalColor = texture(materialTex, fragTexCoord) * color;
gl_FragData[0] = texture(materialTex, fragTexCoord) * color;
}

View file

@ -2,11 +2,8 @@ package globalgamejam.render;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL30.*;
import static org.lwjgl.opengl.GL32.*;
import globalgamejam.Main;
import globalgamejam.math.Matrix4f;
import globalgamejam.math.Vector2f;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13;

View file

@ -38,14 +38,14 @@ public class Shaders {
System.err.println(glGetShaderInfoLog(vert, 2048));
System.exit(1);
}else{
System.out.println("Vertex compiled !");
System.out.println(vertexFile + " compiled !");
}
glCompileShader(frag);
if (glGetShaderi(frag, GL_COMPILE_STATUS) == GL_FALSE) {
System.err.println(glGetShaderInfoLog(frag, 2048));
System.exit(1);
}else{
System.out.println("Fragment compiled !");
System.out.println(fragmentFile + " compiled !");
}
glAttachShader(program, vert);
glAttachShader(program, frag);