5656import com .jme3 .scene .Geometry ;
5757import com .jme3 .shader .*;
5858import com .jme3 .shader .bufferobject .BufferObject ;
59- import com .jme3 .texture .GlImage ;
60- import com .jme3 .texture .GlTexture ;
61- import com .jme3 .texture .TextureImage ;
59+ import com .jme3 .texture .*;
6260import com .jme3 .texture .image .ColorSpace ;
6361import com .jme3 .util .ListMap ;
6462import com .jme3 .util .SafeArrayList ;
63+ import com .jme3 .vulkan .buffers .GpuBuffer ;
6564import com .jme3 .vulkan .commands .CommandBuffer ;
65+ import com .jme3 .vulkan .frames .VersionedResource ;
6666import com .jme3 .vulkan .pipelines .Pipeline ;
6767import org .lwjgl .opengl .GL45 ;
6868
@@ -104,23 +104,9 @@ public class GlMaterial implements Material, CloneableSmartAsset, Cloneable, Sav
104104 private boolean receivesShadows = false ;
105105 private int sortingId = -1 ;
106106
107- @ Override
108- public void bind (CommandBuffer cmd , Pipeline pipeline , int offset ) {
109- // todo: implement properly
110- int loc = GL45 .glGetUniformLocation (pipeline .getNativeObject ().intValue (), "MyUniformName" );
111- GL45 .glUniform1f (loc , 123.4f );
112- }
113-
114107 @ Override
115108 public void setParam (String uniform , String param , Object value ) {
116- // todo: implement
117- throw new UnsupportedOperationException ("Not implemented yet." );
118- }
119-
120- @ Override
121- public <T extends com .jme3 .vulkan .material .uniforms .Uniform > T getUniform (String name ) {
122- // todo: implement
123- throw new UnsupportedOperationException ("Not implemented yet." );
109+ setParam (param , value );
124110 }
125111
126112 /**
@@ -578,6 +564,7 @@ public void setParam(String name, VarType type, Object value) {
578564 * @param name the name of the parameter defined in the material definition (j3md)
579565 * @param value the value of the parameter
580566 */
567+ @ Override
581568 public void setParam (String name , Object value ) {
582569 MatParam p = getMaterialDef ().getMaterialParam (name );
583570 setParam (name , p .getVarType (), value );
@@ -669,15 +656,20 @@ private void checkTextureParamColorSpace(String name, GlTexture value) {
669656 * (.j3md) (e.g. Texture for Lighting.j3md)
670657 * @param value the Texture object previously loaded by the asset manager
671658 */
672- public void setTexture (String name , GlTexture value ) {
659+ @ Override
660+ public void setTexture (String name , VersionedResource <? extends Texture > value ) {
673661 if (value == null ) {
674662 // clear it
675663 clearParam (name );
676664 return ;
677665 }
666+ if (!(value .get () instanceof GlTexture )) {
667+ throw new IllegalArgumentException ("Must be a GlTexture." );
668+ }
678669
679670 VarType paramType = null ;
680- switch (value .getType ()) {
671+ GlTexture .Type type = ((GlTexture )value .get ()).getType ();
672+ switch (type ) {
681673 case TwoDimensional :
682674 paramType = VarType .Texture2D ;
683675 break ;
@@ -691,10 +683,10 @@ public void setTexture(String name, GlTexture value) {
691683 paramType = VarType .TextureCubeMap ;
692684 break ;
693685 default :
694- throw new UnsupportedOperationException ("Unknown texture type: " + value . getType () );
686+ throw new UnsupportedOperationException ("Unknown texture type: " + type );
695687 }
696688
697- setTextureParam (name , paramType , value );
689+ setTextureParam (name , paramType , ( GlTexture ) value );
698690 }
699691
700692 /**
@@ -703,6 +695,7 @@ public void setTexture(String name, GlTexture value) {
703695 * @param name the name of the matrix defined in the material definition (j3md)
704696 * @param value the Matrix4f object
705697 */
698+ @ Override
706699 public void setMatrix4 (String name , Matrix4f value ) {
707700 setParam (name , VarType .Matrix4 , value );
708701 }
@@ -713,6 +706,7 @@ public void setMatrix4(String name, Matrix4f value) {
713706 * @param name the name of the boolean defined in the material definition (j3md)
714707 * @param value the boolean value
715708 */
709+ @ Override
716710 public void setBoolean (String name , boolean value ) {
717711 setParam (name , VarType .Boolean , value );
718712 }
@@ -723,6 +717,7 @@ public void setBoolean(String name, boolean value) {
723717 * @param name the name of the float defined in the material definition (j3md)
724718 * @param value the float value
725719 */
720+ @ Override
726721 public void setFloat (String name , float value ) {
727722 setParam (name , VarType .Float , value );
728723 }
@@ -734,6 +729,7 @@ public void setFloat(String name, float value) {
734729 * @param name the name of the float defined in the material definition (j3md)
735730 * @param value the float value
736731 */
732+ @ Override
737733 public void setFloat (String name , Float value ) {
738734 setParam (name , VarType .Float , value );
739735 }
@@ -744,6 +740,7 @@ public void setFloat(String name, Float value) {
744740 * @param name the name of the int defined in the material definition (j3md)
745741 * @param value the int value
746742 */
743+ @ Override
747744 public void setInt (String name , int value ) {
748745 setParam (name , VarType .Int , value );
749746 }
@@ -754,6 +751,7 @@ public void setInt(String name, int value) {
754751 * @param name the name of the color defined in the material definition (j3md)
755752 * @param value the ColorRGBA value
756753 */
754+ @ Override
757755 public void setColor (String name , ColorRGBA value ) {
758756 setParam (name , VarType .Vector4 , value );
759757 }
@@ -778,12 +776,18 @@ public void setShaderStorageBufferObject(final String name, final BufferObject v
778776 setParam (name , VarType .ShaderStorageBufferObject , value );
779777 }
780778
779+ @ Override
780+ public void setUniform (String name , VersionedResource <? extends GpuBuffer > buffer ) {
781+
782+ }
783+
781784 /**
782785 * Pass a Vector2f to the material shader.
783786 *
784787 * @param name the name of the Vector2f defined in the material definition (j3md)
785788 * @param value the Vector2f value
786789 */
790+ @ Override
787791 public void setVector2 (String name , Vector2f value ) {
788792 setParam (name , VarType .Vector2 , value );
789793 }
@@ -794,6 +798,7 @@ public void setVector2(String name, Vector2f value) {
794798 * @param name the name of the Vector3f defined in the material definition (j3md)
795799 * @param value the Vector3f value
796800 */
801+ @ Override
797802 public void setVector3 (String name , Vector3f value ) {
798803 setParam (name , VarType .Vector3 , value );
799804 }
@@ -804,6 +809,7 @@ public void setVector3(String name, Vector3f value) {
804809 * @param name the name of the Vector4f defined in the material definition (j3md)
805810 * @param value the Vector4f value
806811 */
812+ @ Override
807813 public void setVector4 (String name , Vector4f value ) {
808814 setParam (name , VarType .Vector4 , value );
809815 }
@@ -1106,6 +1112,7 @@ private void resetUniformsNotSetByCurrent(Shader shader) {
11061112 * @param lights Presorted and filtered light list to use for rendering
11071113 * @param renderManager The render manager requesting the rendering
11081114 */
1115+ @ Override
11091116 public void render (Geometry geometry , LightList lights , RenderManager renderManager ) {
11101117 if (technique == null ) {
11111118 selectTechnique (TechniqueDef .DEFAULT_TECHNIQUE_NAME , renderManager );
0 commit comments