Author Topic: OpenGl fruit flies  (Read 3347 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
OpenGl fruit flies
« on: April 17, 2011, 09:44:47 AM »
Deleted
[attachment deleted by admin]
« Last Edit: April 11, 2015, 09:18:10 AM by Peter »

Charles Pegge

  • Guest
Re: OpenGl fruit flies
« Reply #1 on: April 18, 2011, 01:46:41 AM »

Well done Peter. You have cracked it!

My fruitfly response :) Some adjustments to be made but I have compiled it for independent running.

It demonstrates binding to multiple images and and a procedure to make the background transparent from a jpg or png with a whitish background color.

Charles

[attachment deleted by admin]

Charles Pegge

  • Guest
Re: OpenGl fruit flies
« Reply #2 on: April 19, 2011, 07:55:02 AM »

Hi Peter,

Your Opengl example runs smoothly in Ubuntu/Wine and reports 80FPS.

In Vista we get 59.99999999999 Frames per sec :) You can fix this by doing "finit" after choose pixel format. It nobbles the FPU but I see this does not appear to happen under Wine/Linux.

Charles

Charles Pegge

  • Guest
Re: OpenGl fruit flies
« Reply #3 on: April 19, 2011, 10:53:09 AM »

Peter,

Choose Pixel Format tampers with the FPU control registers. I have not investigated this in detail but it is not good practice. The fpu should be returned to its original state, and it should not be necessary to reinitialise it.

I think 80FPS might be an upper limit. The frame rate is noticibly slower when there is more work to do between frames

Charles

Charles Pegge

  • Guest
Re: OpenGl fruit flies
« Reply #4 on: April 20, 2011, 07:00:03 AM »
Peter,

Quote

What is the handle or the address of the double buffer?
That is not hRC ! isn't it?


Opengl provides access to several buffers including the frame buffer. These are in the Graphics memory, not directly accessible by the CPU so these functions involve transferring data to and from the graphics card to a block in main memory.


glReadPixels

http://www.opengl.org/sdk/docs/man/xhtml/glReadPixels.xml


glDrawPixels

http://www.opengl.org/sdk/docs/man/xhtml/glDrawPixels.xml

glReadBuffer

http://www.opengl.org/sdk/docs/man/xhtml/glReadBuffer.xml



But most processing is done with vectors describing surfaces and all pixel creation is left to the graphics hardware.

Sprites are treated as textures "stretched" over a flat surface, the simplest being a triangle or a quad.

Charles

Charles Pegge

  • Guest
Re: OpenGl fruit flies
« Reply #5 on: April 20, 2011, 02:26:41 PM »
Hi Peter,

examples/GUI/OpenglWin2.o2bas reveals all the code needed to implement textures (using GDIplus). If you search through this file looking for "texn" you will find all the code involved in image loading, texture creation, texture handles,  texture enabling, texture binding and texture deletion.

the first 2 procedures in inc/glo2/texture.inc are used to create the texture.

Unlike GDI GDIplus must first be initialised before access. Then it must be shut down at the end.

As you can see, there are many stages to go through before you get a texture to appear on an object.

Charles
« Last Edit: April 20, 2011, 11:06:03 PM by Charles Pegge »