qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RfC PATCH 2/3] sdl2: add support for display rendering


From: Max Reitz
Subject: Re: [Qemu-devel] [RfC PATCH 2/3] sdl2: add support for display rendering using opengl.
Date: Thu, 15 Jan 2015 11:49:20 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0

On 2015-01-12 at 07:46, Gerd Hoffmann wrote:
   Hi,

+    glBegin(GL_QUADS);
+    glTexCoord2f(0, 1);  glVertex3f(-1, -1, 0);
+    glTexCoord2f(0, 0);  glVertex3f(-1, 1, 0);
+    glTexCoord2f(1, 0);  glVertex3f(1, 1, 0);
+    glTexCoord2f(1, 1);  glVertex3f(1, -1, 0);
+    glEnd();
I've been trained to hate direct mode, but it should be fine for just
this quad.
--verbose please.  Guess for longer sequences it would be much more
efficient to compile this into a shader program?
Well, again, I'm used to OpenGL 3/4 Core now which doesn't have the
immediate mode any more. [ ... ]
[ ... ] and maybe for some
reason there are people which want to use qemu with OpenGL acceleration
on a pre OpenGL 2 machine.
For virtio-gpu we'll need OPENGL 3 anyway, so I don't feel like caring
too much about old opengl versions.  How would the opengl 3/4 version of
the above would look like?

Regarding OpenGL 3/4 Core, you'd need some shaders and a buffer for the vertex data.

So, regarding the vertex buffers, you'd have to create a buffer with glGenBuffers(), bind it to GL_ARRAY_BUFFER with glBindBuffer() and fill it with glBufferData(). Then, for every (vertex) attribute your vertex shader has, you call glVertexAttribPointer() (after glEnableVertexArray()) to specify the part of the buffer to be used for that attribute. You can receive the ID required for glVertexAttribPointer() by using glGetAttribLocation() on the linked shader program.

It's probably best to just go for the OpenGL 1 (or 3/4 Compatibility) version for now and I'll see to a patch to make it 3/4 Core later on. Then we can decide what to do and don't have to decide now.

Max

Using glTexSubImage2D() would give us the advantage of being able to
perform partial updates on the texture; but it seems to fit pretty bad
into the existing code. To make it fit, I'd call glTexSubImage2D()
directly in sdl2_gl_update() and just draw the quad here.
Yes, that should work.
Done, also factoring this into helper functions so gtk can use this too
some day, new series sent out, please have a look.

thanks,
   Gerd






reply via email to

[Prev in Thread] Current Thread [Next in Thread]