playing with gles11

Monkey Forums/Monkey Programming/playing with gles11

bruZard(Posted 2011) [#1]


Source for this image:
Strict

Import mojo
Import s3d.s3d

Class S3DTest Extends App
	Field plane:Mesh
	Field cam:Camera
	
	Method OnCreate:Int()
		InitS3D()
		
		plane = LoadMesh("mesh.txt")
		PositionEntity(plane, 0.0, 0.0, -2.0)
		EntityColor(plane, 255, 200, 0, 255)
				
		cam = CreateCamera()
		CameraClsColor(cam, 90, 120, 220)
				
		SetUpdateRate(60)
		
		Return 0
	End
	
	Method OnUpdate:Int()
		TurnEntity(plane, 1.0, 1.0, 1.0)
		
		Return 0
	End
	
	Method OnRender:Int()
		RenderWorld()
		
		Return 0
	End
End

Function Main:Int()
	New S3DTest()
	Return 0
End


the module:
http://www.sedm.de/monkey/s3d/s3d.zip

it's just experimental and not useful. but now i understand opengl a little bit better and can enhance this module.

ps: this will not work for android. i've no idea whats going wrong but i think i can fix that


benmc(Posted 2011) [#2]
This looks interesting. Could you post the contents of mesh.txt so we can see what the format of that file needs to be?


bruZard(Posted 2011) [#3]
oh, i forgot: http://www.sedm.de/monkey/s3d/s3dExample.zip ... there you find a executable for windows and with http://www.sedm.de/monkey/s3d/s3dExampleSource.zip you get the source. mesh.txt is in s3d.data/


benmc(Posted 2011) [#4]
Thanks, the example helped, mesh loaded. Is there a way to texture it with a PNG? Is there a license for this module?


bruZard(Posted 2011) [#5]
the license: do whatever you want to do with it
textures: a really hard theme ... i work on this.


marksibly(Posted 2011) [#6]
Hi,

Nice!

The next release will include the utility function...

Function LoadImageData:DataBuffer( path$ )

...to help with creating textures.


bruZard(Posted 2011) [#7]
kewl, i'am stay tuned! :D


bruZard(Posted 2012) [#8]
i think there are a few bugs in gles11 module:

if i try to set the colorbuffer pointer to a correct colorbuffer the mesh is rendered black. if i try to set "stride" or/and "pointer" for "glColorPointer()" to 0 the vertex takes its position as color. no matter where i try set a pointer on glXXXPointer the result is a fail.

glColorPointer(3, GL_FLOAT, 0, 0) ' works, but with the vertex coordinates
glColorPointer(3, GL_FLOAT, 0, Self.colorBuffer) 'fails



bruZard(Posted 2012) [#9]
a new version is available


changes:
01/01/2011 v0.1
added	: Color.toArray:Float[]()
added	: Color.toBuffer:Int(buffer:DataBuffer, address:Int)
added	: Color.toString:String()
added	: Vertex.toBuffer:Int(buffer:DataBuffer, address:Int)
added	: Entity.SetColor:Void(col:Color4F)
added	: Entity.SetColor:Void(col:String) can actually be white, black, red, green, blue, yellow, magenta, grey, lightgrey, darkgrey, orange or brown
added	: Entity.GetColor:Color4F()
added	: Color.New(col:Color4F)
added	: Color.New(col:String)
added	: Vector.toArray:Float[]()
added	: Light.New(number:Int = GL_LIGHT0, lightType:Int = LIGHT_DIRECTIONAL)
added	: S3D.CreateLight:Light(lightType:Int = LIGHT_DIRECTIONAL)
added	: CreateLight:Light(lightType:Int = LIGHT_DIRECTIONAL)
changed	: MeshFileFormat: the chunk "face" has now 7 values: x, y, z, r, g, b, a for a vertex, RGBA is optional
fixed	: Mesh.New(meshFile:String) not longer read indices to vertices
note	: Lights can be created but are currently ignored because there are no material functions in s3d
note	: if CreateLight() returns Null, there be more than 8 lights in your code
note	: a bug (or my fail) prevents that a mesh can have vertex colors


v0.1 Module : http://www.sedm.de/monkey/s3d/s3d.zip
v0.1 Example: http://www.sedm.de/monkey/s3d/s3dExample.zip

have fun :D


Rob Pearmain(Posted 2012) [#10]
This is awesome, can't wait to see all the Mesh features added.

However, when I go to run the example in IOS 5 Simulator I get the following runtime error:

Thread 1: Program received signal "EXC_BAD_ACCESS" (mesh.monkey 147) for

_glDrawElements(4,this->f_indices.Length(),5123,this->f_ibo);


bruZard(Posted 2012) [#11]
at this time it does not work for iOS or Android. I've tried with jumping in a circle but this has not helped, now i'll try it again with bug fixing ;)

has anyone an idea why the colorPointer is ignored and gles11 takes the vertexcoordinates for colors?


Fred(Posted 2012) [#12]
The following code is NOT working !

I'm investigating OpenGL ES 1.1 as well. I tried to quickly (and dirty) implement this MilkShape ASCII file loader in your (previous) code but vertex indices are messed up. I drop it here just in case it may help you to test your code with already made meshes.





bruZard(Posted 2012) [#13]
ok that shows some funny results with a cube :D



i'll take a closer look on your importer and try to find out what's wrong.

S3D takes the indices in this way:
' one vertex per line
' X     Y     Z    R    G    B    A
>face
-1.0,  1.0,  0.0, 1.0, 1.0, 0.0, 1.0
 1.0,  1.0,  0.0, 1.0, 1.0, 0.0, 1.0
 1.0, -1.0,  0.0, 1.0, 1.0, 0.0, 1.0
-1.0, -1.0,  0.0, 1.0, 1.0, 0.0, 1.0

' indices for the mesh above in clockwise order
' 0---1
' |\  |
' | \ |
' |  \|
' 3---2
>indices
0, 1, 2, 0, 2, 3

notice: the S3D format now read chunks with ">", the "'" is for comments now


marksibly(Posted 2012) [#14]
Hi,

> has anyone an idea why the colorPointer is ignored and gles11 takes the vertexcoordinates for colors?

Ok, you're program appears to be doing several things wrong:

* It binds the color buffer to GL_ELEMENT_ARRAY_BUFFER somewhere - should be GL_ARRAY_BUFFER.

* It binds the color buffer to GL_COLOR_ARRAY which wont work at all! Again, use GL_ARRAY_BUFFER.

* Last param of glDrawElements should be '0'.

Quick hints:

* If a VBO is bound (ie: with glBindBuffer GL_ARRAY_BUFER,...) then glBlahPointer 'pointer' params are int offsets into the VBO.

* Ditto if an IBO is bound (ie: with glBindBuffer GL_ELEMENT_ARRAY_BUFFER,...) then the glDrawElements 'indices' param is an int offset into the index buffer.

* 'Interleaved' vertices are supposed to be more efficient, ie: stick all your position/color data in one VBO in order x#,y#,z#,r#,g#,b#,x#,y#,z#,...etc...and use...

glBindBuffer GL_ARRAY_BUFFER,vbo
glVertexPointer 3,GL_FLOAT,24,0
glColorPointer 3,GL_FLOAT,24,12

...to bind.


bruZard(Posted 2012) [#15]
ah, many thanks for the hints mark. that means i must change wide parts of my code because the buffer can be changed everytime a folk calls AddVertex() :D

but i'll try it out later ... in germany it is 11pm and i want go to bed ;)


bruZard(Posted 2012) [#16]
now the Milkshape ASCII Loader works properly and all runs fine in GLFW and on Android, i've not tested on iOS.

example: http://www.sedm.de/monkey/s3d/s3dExample.zip
module: http://www.sedm.de/monkey/s3d/s3d.zip

next step: Lighting


slenkar(Posted 2012) [#17]
which version of opengl are you using for GLFW?
it fails to execute on my 2003 PC, so its higher than 1.3?


DruggedBunny(Posted 2012) [#18]
Is it meant to look like this?



If so, it's working on GLFW and my Android phone! (Orange San Francisco, aka. ZTE Blade.)

However, every few seconds the model flashes light grey or white on the phone, just for a frame or so, which doesn't happen on GLFW.


marksibly(Posted 2012) [#19]
Hi,

It currently requires GL1.5, but I can probably get it to fallback to using ARB extensions as well, which should improve compatibility.

Can you do a check to see what extensions your GL supports?


bruZard(Posted 2012) [#20]
@DruggedBunny
yes, that's right. I think the flashing appears because there are no normals or vertex coordinates. i'am working on lighting and texturing, stay tuned.

@mark
make it sense to poke the normals and texture coordinates in the same buffer like the vertices and the colors?


bruZard(Posted 2012) [#21]

void _glDrawElements( int mode,int count,int type,int offset ){
glDrawElements( mode,count,type,(const GLvoid*)offset );
}


failed with

Thread 1: Program received Signal: "EXC_BAD_ACCESS"


in iOS Simulator :-(


slenkar(Posted 2012) [#22]
it says here opengl 1.3
http://www.intel.com/support/graphics/sb/CS-004662.htm


marksibly(Posted 2012) [#23]
Slenkar,

Can you run this little GLFW app and let me know what version/extensions it lists?

Import mojo
Import opengl.gles11

Function Main()
	Print glGetString( GL_VERSION )
	Print glGetString( GL_EXTENSIONS )
End


Here's mine (whew!)...

4.2.0
GL_ARB_base_instance GL_ARB_blend_func_extended GL_ARB_color_buffer_float GL_ARB_compatibility GL_ARB_compressed_texture_pixel_storage GL_ARB_conservative_depth GL_ARB_copy_buffer GL_ARB_depth_buffer_float GL_ARB_depth_clamp GL_ARB_depth_texture GL_ARB_draw_buffers GL_ARB_draw_buffers_blend GL_ARB_draw_indirect GL_ARB_draw_elements_base_vertex GL_ARB_draw_instanced GL_ARB_ES2_compatibility GL_ARB_explicit_attrib_location GL_ARB_fragment_coord_conventions GL_ARB_fragment_program GL_ARB_fragment_program_shadow GL_ARB_fragment_shader GL_ARB_framebuffer_object GL_ARB_framebuffer_sRGB GL_ARB_geometry_shader4 GL_ARB_get_program_binary GL_ARB_gpu_shader5 GL_ARB_gpu_shader_fp64 GL_ARB_half_float_pixel GL_ARB_half_float_vertex GL_ARB_imaging GL_ARB_instanced_arrays GL_ARB_internalformat_query GL_ARB_map_buffer_alignment GL_ARB_map_buffer_range GL_ARB_multisample GL_ARB_multitexture GL_ARB_occlusion_query GL_ARB_occlusion_query2 GL_ARB_pixel_buffer_object GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_provoking_vertex GL_ARB_robustness GL_ARB_sample_shading GL_ARB_sampler_objects GL_ARB_seamless_cube_map GL_ARB_separate_shader_objects GL_ARB_shader_atomic_counters GL_ARB_shader_bit_encoding GL_ARB_shader_image_load_store GL_ARB_shader_objects GL_ARB_shader_precision GL_ARB_shader_subroutine GL_ARB_shading_language_100 GL_ARB_shading_language_420pack GL_ARB_shading_language_include GL_ARB_shading_language_packing GL_ARB_shadow GL_ARB_sync GL_ARB_tessellation_shader GL_ARB_texture_border_clamp GL_ARB_texture_buffer_object GL_ARB_texture_buffer_object_rgb32 GL_ARB_texture_compression GL_ARB_texture_compression_bptc GL_ARB_texture_compression_rgtc GL_ARB_texture_cube_map GL_ARB_texture_cube_map_array GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_crossbar GL_ARB_texture_env_dot3 GL_ARB_texture_float GL_ARB_texture_gather GL_ARB_texture_mirrored_repeat GL_ARB_texture_multisample GL_ARB_texture_non_power_of_two GL_ARB_texture_query_lod GL_ARB_texture_rectangle GL_ARB_texture_rg GL_ARB_texture_rgb10_a2ui GL_ARB_texture_storage GL_ARB_texture_swizzle GL_ARB_timer_query GL_ARB_transform_feedback2 GL_ARB_transform_feedback3 GL_ARB_transform_feedback_instanced GL_ARB_transpose_matrix GL_ARB_uniform_buffer_object GL_ARB_vertex_array_bgra GL_ARB_vertex_array_object GL_ARB_vertex_attrib_64bit GL_ARB_vertex_buffer_object GL_ARB_vertex_program GL_ARB_vertex_shader GL_ARB_vertex_type_2_10_10_10_rev GL_ARB_viewport_array GL_ARB_window_pos GL_ATI_draw_buffers GL_ATI_texture_float GL_ATI_texture_mirror_once GL_S3_s3tc GL_EXT_texture_env_add GL_EXT_abgr GL_EXT_bgra GL_EXT_bindable_uniform GL_EXT_blend_color GL_EXT_blend_equation_separate GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_compiled_vertex_array GL_EXT_Cg_shader GL_EXT_depth_bounds_test GL_EXT_direct_state_access GL_EXT_draw_buffers2 GL_EXT_draw_instanced GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_EXTX_framebuffer_mixed_formats GL_EXT_framebuffer_object GL_EXT_framebuffer_sRGB GL_EXT_geometry_shader4 GL_EXT_gpu_program_parameters GL_EXT_gpu_shader4 GL_EXT_multi_draw_arrays GL_EXT_packed_depth_stencil GL_EXT_packed_float GL_EXT_packed_pixels GL_EXT_pixel_buffer_object GL_EXT_point_parameters GL_EXT_provoking_vertex GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_shader_objects GL_EXT_separate_specular_color GL_EXT_shader_image_load_store GL_EXT_shadow_funcs GL_EXT_stencil_two_side GL_EXT_stencil_wrap GL_EXT_texture3D GL_EXT_texture_array GL_EXT_texture_buffer_object GL_EXT_texture_compression_dxt1 GL_EXT_texture_compression_latc GL_EXT_texture_compression_rgtc GL_EXT_texture_compression_s3tc GL_EXT_texture_cube_map GL_EXT_texture_edge_clamp GL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_EXT_texture_filter_anisotropic GL_EXT_texture_format_BGRA8888 GL_EXT_texture_integer GL_EXT_texture_lod GL_EXT_texture_lod_bias GL_EXT_texture_mirror_clamp GL_EXT_texture_object GL_EXT_texture_shared_exponent GL_EXT_texture_sRGB GL_EXT_texture_sRGB_decode GL_EXT_texture_storage GL_EXT_texture_swizzle GL_EXT_texture_type_2_10_10_10_REV GL_EXT_timer_query GL_EXT_transform_feedback2 GL_EXT_vertex_array GL_EXT_vertex_array_bgra GL_EXT_vertex_attrib_64bit GL_EXT_import_sync_object GL_IBM_rasterpos_clip GL_IBM_texture_mirrored_repeat GL_KTX_buffer_region GL_NV_alpha_test GL_NV_blend_minmax GL_NV_blend_square GL_NV_complex_primitives GL_NV_conditional_render GL_NV_copy_depth_to_color GL_NV_copy_image GL_NV_depth_buffer_float GL_NV_depth_clamp GL_NV_explicit_multisample GL_NV_fbo_color_attachments GL_NV_fence GL_NV_float_buffer GL_NV_fog_distance GL_NV_fragdepth GL_NV_fragment_program GL_NV_fragment_program_option GL_NV_fragment_program2 GL_NV_framebuffer_multisample_coverage GL_NV_geometry_shader4 GL_NV_gpu_program4 GL_NV_gpu_program4_1 GL_NV_gpu_program5 GL_NV_gpu_program_fp64 GL_NV_gpu_shader5 GL_NV_half_float GL_NV_light_max_exponent GL_NV_multisample_coverage GL_NV_multisample_filter_hint GL_NV_occlusion_query GL_NV_packed_depth_stencil GL_NV_parameter_buffer_object GL_NV_parameter_buffer_object2 GL_NV_path_rendering GL_NV_pixel_data_range GL_NV_point_sprite GL_NV_primitive_restart GL_NV_register_combiners GL_NV_register_combiners2 GL_NV_shader_atomic_counters GL_NV_shader_buffer_load GL_NV_texgen_reflection GL_NV_texture_barrier GL_NV_texture_compression_vtc GL_NV_texture_env_combine4 GL_NV_texture_expand_normal GL_NV_texture_lod_clamp GL_NV_texture_multisample GL_NV_texture_rectangle GL_NV_texture_shader GL_NV_texture_shader2 GL_NV_texture_shader3 GL_NV_transform_feedback GL_NV_transform_feedback2 GL_NV_vertex_array_range GL_NV_vertex_array_range2 GL_NV_vertex_attrib_integer_64bit GL_NV_vertex_buffer_unified_memory GL_NV_vertex_program GL_NV_vertex_program1_1 GL_NV_vertex_program2 GL_NV_vertex_program2_option GL_NV_vertex_program3 GL_NVX_conditional_render GL_NVX_gpu_memory_info GL_OES_depth24 GL_OES_depth32 GL_OES_depth_texture GL_OES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_get_program_binary GL_OES_mapbuffer GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_texture_3D GL_OES_texture_float GL_OES_texture_float_linear GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_texture_npot GL_OES_vertex_array_object GL_OES_vertex_half_float GL_SGIS_generate_mipmap GL_SGIS_texture_lod GL_SGIX_depth_texture GL_SGIX_shadow GL_SUN_slice_accum GL_WIN_swap_hint WGL_EXT_swap_control




slenkar(Posted 2012) [#24]
1.3.0 - Build 4.14.10.4342
GL_ARB_multitexture GL_ARB_point_parameters GL_ARB_texture_border_clamp GL_ARB_texture_compression GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_dot3 GL_ARB_texture_env_crossbar GL_ARB_transpose_matrix GL_ARB_vertex_buffer_object GL_ARB_vertex_program GL_ARB_window_pos GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_clip_volume_hint GL_EXT_compiled_vertex_array GL_EXT_cull_vertex GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_multi_draw_arrays GL_EXT_packed_pixels GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_specular_color GL_EXT_stencil_wrap GL_EXT_texture_compression_s3tc GL_EXT_texture_env_add GL_EXT_texture_env_combine GL_EXT_texture_filter_anisotropic GL_3DFX_texture_compression_FXT1 GL_IBM_texture_mirrored_repeat GL_NV_blend_square GL_NV_texgen_reflection GL_SGIS_generate_mipmap GL_WIN_swap_hint


taumel(Posted 2012) [#25]
I don't get it. Why not going straight for OpenGL ES 2?


Samah(Posted 2012) [#26]
I don't get it. Why not going straight for OpenGL ES 2?

Not all mobile devices and/or OS versions support ES2.


taumel(Posted 2012) [#27]
Those where using 3D makes sense do. Secondly mobile device get a lot faster replaced than desktops. This is like caring about a niche market where the time is working against you.


ErikT(Posted 2012) [#28]
Except maybe for kids and demented people, nobody here has ambitions to do PS3-quality games with Monkey anyhow. ES 1.1 goes a long way if you use it right.


bruZard(Posted 2012) [#29]
ES2.0 works completely different from ES1.x and who want ES2.x should write his own wrapper ;)


Fred(Posted 2012) [#30]
bruZard you grabbed my code just before I edited it: remove the 4 comments to have this:
if not nbtriangles nbmeshes -= 1
if not nbmeshes
Rethink(indexarray)
Return ' we stop here for the moment
Else
state = MKSP_MESH_NAME
Endif
EndIf
So you'll be able to load the full heli.txt


taumel(Posted 2012) [#31]
@ErikT
Following this logic i wonder why you care about 3D at all and not stick to ASCII graphics instead. I understand that due to a lack of a proper 3D engine in the Blitz community for years things aren't up to date but quite some of the rest of the tools are. You're free to enjoy the same spinning triangles over and over again but i doubt your audience does, as at least they are able to compare and of course common shader support on mobiles doesn't mean PS3 content heavy games.


Fred(Posted 2012) [#32]
I would like to continue playing with this but I don't know where you want to go. by the way thanks for sharing your investigations.
MilkShape files (I never used them before) has one material per mesh with several meshes inside the txt file.
So, with your current implementation it could be better to have a higher level function that load milkshape.txt and create several s3d.meshes from there. but then it needs higher handling to manipulate a group of meshes as an object.
I guess I have to wait for your next release.


benmc(Posted 2012) [#33]
This may be off topic, but I'm not sure.

Once you start working in 3D, how does collision detection and physics come into play? Is there anything built-in to OpenGL that relates to this, or do you have to start from scratch with all the math? Or just bail and learn Unity ;)


bruZard(Posted 2012) [#34]
@Fred: the plan is to write a complete engine, but now i must learn all the funny things about opengl es 1.1.
the code above is not written in stones and i think it is possible that i publish a complete new module in the next few weeks. atm i read the Khronos OpenGL ES1.x specification and learn and learn and learn and whine and learn and .... ;)
When i start to write a really cool gles11 wrapper, i start a new thread in "Projects".

@benmc: if i really create an easy-to-use 3D engine then you can be sure that there are collisions and all the other funny things you known from Blitz3D.

@OpenGL ES2.x
surely, it would be awesome if we had ES2.x, but now we just have 1.1 and i think we should live with that.


charlie(Posted 2012) [#35]
We should be getting GLES 2.whatever according to Mark: http://www.monkeycoder.co.nz/Community/post.php?topic=2035&post=19463

Hopefully it won't take too much longer...

Cheers
Charlie


AdamRedwoods(Posted 2012) [#36]
Once you start working in 3D, how does collision detection and physics come into play? Is there anything built-in to OpenGL that relates to this, or do you have to start from scratch with all the math? Or just bail and learn Unity ;)

For physics and collisions, you have to do your own math.

There's always Unity.... or learn Shiva 3D!


To be honest, when I get done with my paid project, I'll see if I can't finish porting over miniB3D so everyone has a place to start (unless Simon has done it already!).


ErikT(Posted 2012) [#37]
taumel:
Following this logic i wonder why you care about 3D at all

You're free to enjoy the same spinning triangles over and over again but i doubt your audience does, as at least they are able to compare and of course common shader support on mobiles doesn't mean PS3 content heavy games.


I care about maximum compatibility, as do most people interested in using Monkey to make a buck I reckon. Could it be that a target audience also cares about this? That is to say, outside of the segment that upgrades every six months? Hmmm...


charlie(Posted 2012) [#38]
Just being able to use GL would be more than enough for me. I like the idea of WebGL, so i'm looking forward to being able to try it out with Monkey.

Cheers
Charlie


Dima(Posted 2012) [#39]
I remember watching a video presentation for android gaming by Google, it was a guy who made Replica Island, and I remember him mention that if the device supports ES2.0 it is always better to use that instead of 1.1 because of something to do with emulating the 1.1 layer. I don't know any real info on this.


taumel(Posted 2012) [#40]
@ErikT
Contrary to you i don't know what most people using monkey want but i know what's reasonable to use for making a buck and that's supporting what's widely spread and taking advantage of the features being available there. Again those devices where it makes sense using 3D are supporting OpenGL ES 2 since years but it certainly also is a business model designing a game for the models which are outdated. It's not my business model but fair enough if it's yours.


bruZard(Posted 2012) [#41]
i try to load a Wavefront .obj File, but nothing i try will work.

Here's the file i try to load:

(just a cube)

and here is the code which try to interpret the data:

the result looks like this:



DruggedBunny(Posted 2012) [#42]
@bruZard: Just so you know, I edited your post (I'm a moderator!) to change the (code) tag to (codebox) -- this puts large code examples in a scrollable box.


bruZard(Posted 2012) [#43]
thank you!


marksibly(Posted 2012) [#44]
Hi,

Looks a bit wrong in a few places - esp. the 'EachIn' to set up the indices.

Try this (model renamed to cube.txt). It's a little intense because it merges identical vertices if possible...




bruZard(Posted 2012) [#45]
Very cool! Many thanks Mark



let me now read and realize what you've done ;)

iOS simulator: fun with normals


looks good on android



bruZard(Posted 2012) [#46]
textures seems to be turned by 180 degrees. The monkey should stay at the bottom of the face.


EDIT:

does the job ;)


bruZard(Posted 2012) [#47]
now it works




bruZard(Posted 2012) [#48]
yet another issue. On android i got the runtime error: "length - offset < needed" at glMaterialfv functions, for example:

glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, Self.mat.ambient, 0)


Any idea what is going wrong?

Source + Executable: http://www.sedm.de/monkey/s3d/monkeytest.zip


Soap(Posted 2012) [#49]
Your new signature image would look better with tighter shadows. Awesome progress on this. :)


bruZard(Posted 2012) [#50]
when i don't know what's going wrong and i make steps over steps in the same footsteps, i play with photoshop ;)


Soap(Posted 2012) [#51]
Good use of time! I am a Photoshop wizard. If you ever have questions I can probably help. :)


samowitsch(Posted 2012) [#52]
Very cool. Is there anywhere a complete example?


bruZard(Posted 2012) [#53]
in the archive i've posted: http://www.sedm.de/monkey/s3d/monkeytest.zip


bruZard(Posted 2012) [#54]
now we have this:

...to produce this:


here is the module so far:


special thanx to mark sibly for the massive help!


CopperCircle(Posted 2012) [#55]
That is great work, well done.


bruZard(Posted 2012) [#56]
executable for Android:


or try http://www.sedm.de/monkey/s3d/s3d.apk

and a short video:
http://www.youtube.com/watch?v=rhX93PxE5cU


bruZard(Posted 2012) [#57]
another video, it shows 17 monkeys. 16 monkeys are just references and not real loaded meshes.

http://www.youtube.com/watch?v=3d2-7E_6A5c&feature=g-upl&context=G2748571AUAAAAAAAAAA

the source for this demo:


now it works also on iOS



GC-Martijn(Posted 2012) [#58]
And what about your first polygon http://www.monkeycoder.co.nz/Community/post.php?topic=2099&post=20534

with a texture on andriod/iOS ?


bruZard(Posted 2012) [#59]
like that?




GC-Martijn(Posted 2012) [#60]
cool !


slenkar(Posted 2012) [#61]
very nice,


bruZard(Posted 2012) [#62]
Restart!

S3D is now again at version 0.1. I've added the greatful code from the "Master of Desaster" Mark Sibly and enhanced the code like i can do.

The module : http://www.sedm.de/monkey/s3d/s3d.zip
The 17 Monkeys Example: http://www.sedm.de/monkey/s3d/s3d17monkeys.zip

the demo doesn't work with GLFW, i've no idea why. I've just renamed the files so you not must edit your build config, and now it just will work on iOS and Android.

If you want to use custom models with S3D, here are some things you have to note:

1. the mesh must have texture coordinates (unwrap your mesh!)
2. at now you can only load Wavefront Object (*.obj) models with S3D
3. export your model with texture coordinates, uv coordinates and triangulate it. For Blender 2.6x: select "Include Normals" and "Triangulate Faces" in the export options.

If you want to use Wavefront Objects directly, add "|*.obj|*mtl" to the CONFIG.TXT. Otherwise you have to rename the file extension to "txt"

The plan is now to create a full 3D Engine which is to use like Blitz3D. Next step is to implement AABB bounding boxes for simple collisions

the changloig so far



Tibit(Posted 2012) [#63]
I am impressed! Really nicer to see some 3D going on! Maybe I'll have to rename or redo my 2D Vector Class after all! :)


DruggedBunny(Posted 2012) [#64]
That works on my Android phone, nice!

[Removed GLFW bug rambling already discovered by bruZard... ]


bruZard(Posted 2012) [#65]
the code has works until i've renamed the resource files. There is no bug in the code.


bruZard(Posted 2012) [#66]
the glNormalPointer bug related to the issue that there is a bug in the native files of opengl.gles11 ... there is no function wich compare with the call an you have to add this function by yourself. I've posted that bug and i hope mark will fix it with the final 052 release.


DruggedBunny(Posted 2012) [#67]
Yeah, that's what I meant by posting the difference in definitions ^^

At least you know what the problem is, so that's good.


DruggedBunny(Posted 2012) [#68]
OK, I found your bug report (sorry, hadn't seen it before), and it now builds for GLFW after adding that function override.

However, it crashes on LoadMesh("monkey.txt") for me. So far, I've traced it to Texture.New -> glTexImage2D, as the last piece of code that runs prior to that is Self.textureData = LoadImageData(fileName, Self.textureInfo).

Did you have to modify anything else to get the latest code (in your post above) to run on GLFW?


benmc(Posted 2012) [#69]
@DruggedBunny

First, in the zip file you downloaded, you need to change the "data" folder to "gles.data"

Then, you need to rename monkey.obj to monkeyobj.txt and then edit gles.monkey to load monkeyobj.txt instead of monkey.obj because LoadString only loads .txt, .xml, .json files

Now, rename monkey.mtl to monkeymtl.txt

Then, edit the monkeyobj.txt file and change the monkey.mtl reference to monkeymtl.txt

You may have to delete your glfw build folder for this project.

Then build again for glfw and it should work. Did for me.

EDIT:
On my computer there is a LOT of flicker on the monkey.

EDIT 2:
If I comment out the line:
glLightfv GL_LIGHT0,GL_POSITION,[-5.0,5.0,3.0]
The flicker is gone.


DruggedBunny(Posted 2012) [#70]
@benmc: thanks, but I think we're looking at different archives! I'm using those in post #62, and s3d17monkeys.zip contains a folder called example.data, containing:

monkey.blend
monkey.jpg
monkey.txt
monkey_mat.txt


Your post did prompt me to check GLFW's CONFIG.TXT, but the filters look OK:

TEXT_FILES=*.txt|*.xml|*.json

IMAGE_FILES=*.png|*.jpg



benmc(Posted 2012) [#71]
@DruggedBunny: I see. I was getting the same error you were on the other code, just figured it was the same. Still, might help someone else get the Monkey head example going.

On the example you are referring to, I get a "Monkey runtime error: Memory access violation" error. :(


DruggedBunny(Posted 2012) [#72]

On the example you are referring to, I get a "Monkey runtime error: Memory access violation" error. :(


There should be a list of lines below that, one of which should include s3d17monkeys/example.monkey<15> -- do you get that? If so, we have the same problem, which ultimately appears to be a crash in glTexImage2D.


marksibly(Posted 2012) [#73]
Hi,

Looks like GLFW doesn't like that particular jpg file - I converted it to png (and edited the material file) and it worked.


DruggedBunny(Posted 2012) [#74]
Ah, yes, that does it. Turns out it's a progressive JPEG, which is unsupported by the stb_image.c loader GLFW uses.

Slightly OT: I notice also that trans/makemeta prevent this image from loading in HTML5 Mojo too (fine on all other targets) -- it appears that get_info_jpg returns 0, as it only appears to check for the 0xc0 marker; you get c0-c3 markers, with c2 being progressive.

If HTML5 is meant to load progressive JPEGs, this short BlitzMax function can correctly read the width/height from that JPEG (and 13,000 others), and might be easy enough to port to C. I tried hacking get_info_jpg to check for c0-c3 to no avail, but don't really understand the code well enough.




MonkeyPlotter(Posted 2012) [#75]
Really looking forward to trying this later.......