Thursday, 15 July 2010

c++ - SDL2 With OpenGL ES 2.0 - Cannot draw simple triangle on iOS -



c++ - SDL2 With OpenGL ES 2.0 - Cannot draw simple triangle on iOS -

i using sdl2 test out opengl es 2.0 , reason unable draw on screen. configured shaders , compiled correctly , binded vertex attributes still nothing. triangle draw if compile app macosx or windows.

here's shader:

[vertex shader]

attribute vec3 vposition; void main() { gl_position = vec4(vposition.xyz, 1.0); }

[fragment shader]

precision mediump float; varying vec4 _color; void main() { gl_fragcolor = vec4(1.0, 1.0, 1.0, 1.0); }

also note before linking shader phone call this:

glbindattriblocation(programobj, 0, "vposition");

[drawing code]

gluseprogram(programobj); glfloat vvertices[] = {0.0f, 0.5f, 0.0f, -0.5f, -0.5f, 0.0f, 0.5f, -0.5f, 0.0f}; glviewport(0, 0, 320, 480); glclear(gl_color_buffer_bit | gl_depth_buffer_bit | gl_stencil_buffer_bit); // load vertex info glvertexattribpointer(0, 3, gl_float, gl_false, 0, vvertices); glenablevertexattribarray(0); gldrawarrays(gl_triangles, 0, 3); sdl_gl_swapwindow(window);

as mentioned before, works fine on macosx or windows when compile ios, nil draws. can point out doing wrong?

this means initialization code not complete. create sure initialized can create sdl renderer, initialize necessary. not have utilize drawing after creation.

sdl_renderer *renderer = sdl_createrenderer(window, -1, 0);

if find solution dirty , hackish, can examine source code of sdl_createrenderer , add together missing parts code.

i had same problem when porting opengl game ios, creating renderer fixed issue.

c++ ios opengl-es sdl-2

No comments:

Post a Comment