c++ - OpenGL under QML -


so i've been toying around opengl under qml , have been looking @ supplied example file of same name. kind of understand how it's working here's thing: tried replace opengl shader program in paint() function of example own basic open gl stuff. unable visible on screen. thing able change color of background. i'm wondering how set viewport, camera, , whatever needed have on screen. have (very rusty) experience on opengl in past there's been things freeglut makes life bit easier. pointers or examples (something can put in paint() method observe , learn from) right direction appreciated...

edit: here's have in paint() method:

void qtopenglviewrenderer::paint() {     // following 2 lines fixed problem     qopenglfunctions glfuncs(qopenglcontext::currentcontext());     glfuncs.gluseprogram(0);      glviewport(0, 0, m_viewportsize.width(), m_viewportsize.height());      glmatrixmode(gl_projection);     glloadidentity();     glmatrixmode(gl_modelview);     glloadidentity();      glclearcolor(0.2, 0, 0, 1);     glclear(gl_color_buffer_bit);      glfloat triangle[] = {         0.25f, 0.25f, 0.0f,         0.75f, 0.25f, 0.0f,         0.25f, 0.75f, 0.0f     };      glfloat colors[] = {         1.0f, 0.0f, 0.0f, 1.0f,         0.0f, 1.0f, 0.0f, 1.0f,         0.0f, 0.0f, 1.0f, 1.0f     };      glvertexpointer(3, gl_float, 0, triangle);     glcolorpointer(4, gl_float, 0, colors);     glenableclientstate(gl_vertex_array);     glenableclientstate(gl_color_array);      glshademodel(gl_smooth);      gldrawarrays(gl_triangles, 0, 3);      glflush(); } 

all see dark reddish background no sign of triangle. why this?

answering own question record. problem qt default expecting new opengl shading language (glsl) style instructions. old style opengl instructions work need tell qt you're going use them instead of program defined shaders. done issuing following commands:

qopenglfunctions glfuncs(qopenglcontext::currentcontext()); glfuncs.gluseprogram(0); 

for these work need include following headers:

#include <qopenglfunctions> #include <qopenglcontext> 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -