Last active
August 29, 2015 14:23
-
-
Save defHLT/baa22d3134cf2d8fcc27 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyGdxGame extends ApplicationAdapter { | |
private ShaderProgram shaderProgram; | |
private Mesh mesh; | |
@Override | |
public void create () { | |
texture = new Texture(Gdx.files.internal("texture_default.jpg")); | |
batch = new SpriteBatch(); | |
sprite = new Sprite(texture); | |
FileHandle f = Gdx.files.internal("f_shader.glsl"); | |
FileHandle v = Gdx.files.internal("v_shader.glsl"); | |
shaderProgram = new ShaderProgram(v, f); | |
ShaderProgram.pedantic = false; | |
mesh = new Mesh(true, 4, 6, VertexAttribute.Position()); | |
mesh.setVertices(new float[] | |
{-0.5f, -0.5f, 0, | |
0.5f, -0.5f, 0, | |
0.5f, 0.5f, 0, | |
-0.5f, 0.5f, 0, }); | |
mesh.setIndices(new short[]{0, 1, 2, 2, 3, 0}); | |
if(!shaderProgram.isCompiled()) { | |
String log = shaderProgram.getLog(); | |
Gdx.app.log("Log", log); | |
} | |
} | |
@Override | |
public void render () { | |
Gdx.gl.glClearColor(0.3f, 0.3f, 0.3f, 1); | |
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); | |
Matrix4 o = new Matrix4(); | |
o.setToOrtho2D(0f, 0f, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); | |
shaderProgram.begin(); | |
shaderProgram.setUniformMatrix("u_projViewTrans", cam.combined); | |
shaderProgram.end(); | |
mesh.bind(shaderProgram); | |
mesh.render(shaderProgram, GL20.GL_TRIANGLES); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uniform mat4 u_projViewTrans; | |
uniform vec4 a_position; | |
attribute vec2 a_texCoord0; | |
void main() | |
{ | |
gl_Position = u_projViewTrans * a_position; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
precision lowp float; | |
void main() | |
{ | |
gl_FragColor.rgb = vec3(0.0, 1.0, 0.0); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
06-25 19:50:43.746 9786-9827/io.github.mlatu.gravity.android I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:379>: QUALCOMM Build: 01/15/15, ab0075f, Id3510ff6dc | |
06-25 19:50:43.746 9786-9827/io.github.mlatu.gravity.android I/OpenGLRenderer﹕ Initialized EGL, version 1.4 | |
06-25 19:50:43.774 9786-9827/io.github.mlatu.gravity.android D/OpenGLRenderer﹕ Enabling debug mode 0 | |
06-25 19:50:43.840 9786-9822/io.github.mlatu.gravity.android W/GL2JNIView﹕ creating OpenGL ES 2.0 context | |
06-25 19:50:43.857 9786-9822/io.github.mlatu.gravity.android I/GL2﹕ all initialized 2 | |
06-25 19:50:43.857 9786-9822/io.github.mlatu.gravity.android I/AndroidGraphics﹕ OGL renderer: Adreno (TM) 320 | |
06-25 19:50:43.857 9786-9822/io.github.mlatu.gravity.android I/AndroidGraphics﹕ OGL vendor: Qualcomm | |
06-25 19:50:43.857 9786-9822/io.github.mlatu.gravity.android I/AndroidGraphics﹕ OGL version: OpenGL ES 3.0 [email protected] AU@ (GIT@Id3510ff6dc) | |
06-25 19:50:43.857 9786-9822/io.github.mlatu.gravity.android I/AndroidGraphics﹕ OGL extensions: GL_AMD_compressed_ATC_texture GL_AMD_performance_monitor GL_AMD_program_binary_Z400 GL_EXT_debug_label GL_EXT_debug_marker GL_EXT_discard_framebuffer GL_EXT_robustness GL_EXT_texture_format_BGRA8888 GL_EXT_texture_type_2_10_10_10_REV GL_NV_fence GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth_texture GL_OES_depth24 GL_OES_EGL_image GL_OES_EGL_sync GL_OES_EGL_image_external GL_OES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_fragment_precision_high GL_OES_get_program_binary GL_OES_packed_depth_stencil GL_OES_depth_texture_cube_map GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_texture_3D GL_OES_texture_float GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_texture_npot GL_OES_vertex_half_float GL_OES_vertex_type_10_10_10_2 GL_OES_vertex_array_object GL_QCOM_alpha_test GL_QCOM_binning_control GL_QCOM_driver_control GL_QCOM_perfmon_global_mode GL_QCOM_extended_get GL_QCOM_extended_get2 GL_QCOM_tiled_rendering GL_QCOM_writeonly_rendering GL_EXT_sRGB GL_EXT_sRGB_write_control GL_EXT_texture_sRGB_decode GL_EXT_multisampled_render_to_texture GL_EXT_color_buffer_float GL_EXT_color_buffer_half_float GL_EXT_disjoint_timer_query | |
06-25 19:50:43.858 9786-9822/io.github.mlatu.gravity.android W/Adreno-EGL﹕ <qeglDrvAPI_eglGetConfigAttrib:607>: EGL_BAD_ATTRIBUTE | |
06-25 19:50:43.858 9786-9822/io.github.mlatu.gravity.android W/Adreno-EGL﹕ <qeglDrvAPI_eglGetConfigAttrib:607>: EGL_BAD_ATTRIBUTE | |
06-25 19:50:43.858 9786-9822/io.github.mlatu.gravity.android I/AndroidGraphics﹕ framebuffer: (5, 6, 5, 0) | |
06-25 19:50:43.858 9786-9822/io.github.mlatu.gravity.android I/AndroidGraphics﹕ depthbuffer: (16) | |
06-25 19:50:43.858 9786-9822/io.github.mlatu.gravity.android I/AndroidGraphics﹕ stencilbuffer: (0) | |
06-25 19:50:43.858 9786-9822/io.github.mlatu.gravity.android I/AndroidGraphics﹕ samples: (0) | |
06-25 19:50:43.858 9786-9822/io.github.mlatu.gravity.android I/AndroidGraphics﹕ coverage sampling: (false) | |
06-25 19:50:43.873 9786-9822/io.github.mlatu.gravity.android I/AndroidGraphics﹕ Managed meshes/app: { } | |
06-25 19:50:43.873 9786-9822/io.github.mlatu.gravity.android I/AndroidGraphics﹕ Managed textures/app: { } | |
06-25 19:50:43.873 9786-9822/io.github.mlatu.gravity.android I/AndroidGraphics﹕ Managed cubemap/app: { } | |
06-25 19:50:43.874 9786-9822/io.github.mlatu.gravity.android I/AndroidGraphics﹕ Managed shaders/app: { } | |
06-25 19:50:43.874 9786-9822/io.github.mlatu.gravity.android I/AndroidGraphics﹕ Managed buffers/app: { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment