From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YBnbt-0002C7-P2 for qemu-devel@nongnu.org; Thu, 15 Jan 2015 11:49:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YBnbq-0005Fb-IA for qemu-devel@nongnu.org; Thu, 15 Jan 2015 11:49:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54761) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YBnbq-0005FM-3q for qemu-devel@nongnu.org; Thu, 15 Jan 2015 11:49:26 -0500 Message-ID: <54B7EF90.9060204@redhat.com> Date: Thu, 15 Jan 2015 11:49:20 -0500 From: Max Reitz MIME-Version: 1.0 References: <1418295956-22479-1-git-send-email-kraxel@redhat.com> <1418295956-22479-3-git-send-email-kraxel@redhat.com> <5489BEE2.7090107@redhat.com> <1418382297.23141.23.camel@nilsson.home.kraxel.org> <548AEEF7.1000206@redhat.com> <1421066808.8695.31.camel@nilsson.home.kraxel.org> In-Reply-To: <1421066808.8695.31.camel@nilsson.home.kraxel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RfC PATCH 2/3] sdl2: add support for display rendering using opengl. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: qemu-devel@nongnu.org, Anthony Liguori 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 > >