Easy GL2D
-The bugs were because I wasn't including the .bas module. I assumed it was written in the .bi file already.
-Under the screeninit function, I had to include 'OR 1' to the flag for screenres to make it fullscreen. I know it's easy to add manually, but it should be an option.
-I tried asteroidz in fullscreen and its really smooth, but every 1-2 seconds, I see a scan line distorting the image, which looks like evidence of no vsync or poorly done vsync. Is GL in charge of maintaning and syncing the refresh rate? Any way of fixing this? Don't know much about GL.
-Under the screeninit function, I had to include 'OR 1' to the flag for screenres to make it fullscreen. I know it's easy to add manually, but it should be an option.
-I tried asteroidz in fullscreen and its really smooth, but every 1-2 seconds, I see a scan line distorting the image, which looks like evidence of no vsync or poorly done vsync. Is GL in charge of maintaning and syncing the refresh rate? Any way of fixing this? Don't know much about GL.
-
- Posts: 2338
- Joined: May 31, 2005 9:59
- Location: Croatia
- Contact:
GL2D lib demo on my PC, full screen (GeForce 8600 GTS): 510 + FPS
Asteroidz: 3600 FPS
In windowed mode higher FPS values.
But, I had to force no VSYNC in my video card settings to get these values. Otherwise, I get 60 FPS, naturally.
Any my card is not really high end.
Not sure what to say to people who don't want to update with the year 2005 (which I think is enough in video card quality sense)...erm, just don't use the lib.
Asteroidz: 3600 FPS
In windowed mode higher FPS values.
But, I had to force no VSYNC in my video card settings to get these values. Otherwise, I get 60 FPS, naturally.
Any my card is not really high end.
Not sure what to say to people who don't want to update with the year 2005 (which I think is enough in video card quality sense)...erm, just don't use the lib.
Ophelius: I'll add the fullscreen switch next update (I also forgot to add h4tten's ellipse code). As for the vsync, your card controls that. I could add a screensync call in there but that would make if do a double vsynch call.
I also tested this on a 64mb Nvidia mx400 (A video card so old, it's older than my daughter who is 10 years now) and the FPS I'm getting is about 200 FPS.
Should GL2D support FB.IMAGE rather than what it uses now?
http://www.freebasic.net/forum/viewtopic.php?t=16287
I also tested this on a 64mb Nvidia mx400 (A video card so old, it's older than my daughter who is 10 years now) and the FPS I'm getting is about 200 FPS.
Should GL2D support FB.IMAGE rather than what it uses now?
http://www.freebasic.net/forum/viewtopic.php?t=16287
-
- Posts: 2655
- Joined: Aug 28, 2008 10:54
- Location: new york
@Rel
My entire polygon library is based on sprites (don't ask, nothing I do makes sense). So my answer is YES. I will port all my drawing routines over if I you can support FB IMAGES, since all the cool stuff my lib does is worthless without the sprite stuff.
But I'm really interested in 3600 FPS.
:)
My entire polygon library is based on sprites (don't ask, nothing I do makes sense). So my answer is YES. I will port all my drawing routines over if I you can support FB IMAGES, since all the cool stuff my lib does is worthless without the sprite stuff.
But I'm really interested in 3600 FPS.
:)
I'm waiting for the go ahead with dkl on this. I'll work on the FB.IMAGE compatible version once dkl says _reserved() won't ever be used.rolliebollocks wrote:@Rel
My entire polygon library is based on sprites (don't ask, nothing I do makes sense). So my answer is YES. I will port all my drawing routines over if I you can support FB IMAGES, since all the cool stuff my lib does is worthless without the sprite stuff.
But I'm really interested in 3600 FPS.
:)
Cross your fingers.
I'm talking with dkl on irc right now.
Code: Select all
Update ver 0.5
Fixed:
1. pixel inconsistency in sprite rendering
2. Filled primitive stuff discrepancy
Added:
Vsynch
Ellipse
Made a version compatible with FB.IMAGE
Code: Select all
**Everything is the same as the standard mode except that:
*******1. all calls to "byref image as Tglsprite" has been changed to
"byval spr as image ptr"
*******2. Calling the sprite routines needs casting
ie.
PUT (310,30), images(81)
becomes:
gl2d.sprite(310,30,cast(gl2d.image ptr, images(81)))
* no way to go around this as of the moment as we cannot undef stuff
inside namespaces
*******3. init_sprites() changed prototypes (a lot simpler now)
*******4. Added load_image_to_HW(byval spr as image ptr)
* Loads an FB.image to texture
* See example file
There are now two versions. The standard(old one) and the FB.IMAGE compatible one.
Difference are noted above.
Also by making it FB.Image compatible I was able to make use of Mysoft's pixel-perfect collision routine.
So we collide via sofware and at the same time, rendering via hardware. Check out the example exes.
-
- Posts: 2338
- Joined: May 31, 2005 9:59
- Location: Croatia
- Contact:
-
- Posts: 2655
- Joined: Aug 28, 2008 10:54
- Location: new york
Hahah, this is getting pretty cool.
Please change it to
So it compiles on Linux.
I seriously doubt any video card made in the last 2 years will survive for 10 years.
Please change it to
Code: Select all
#include once "GL/gl.bi"
#include once "GL/glu.bi"
I have one of those too. It has no fan, and still works.I also tested this on a 64mb Nvidia mx400 (A video card so old, it's older than my daughter who is 10 years now) and the FPS I'm getting is about 200 FPS.
I seriously doubt any video card made in the last 2 years will survive for 10 years.
-
- Posts: 2655
- Joined: Aug 28, 2008 10:54
- Location: new york
@Rel
In your demo I'm getting about 740 FPS.
A couple of quick questions... Reading data from the screenbuffer... Is it any different? I need something like
somecolor = point(x,y)
...but probably faster. Can I read pixdata directly from the screen?
<edit>
and something like
Get ( source_gl_sprite, x1,y1, x2,y2, dest_gl_sprite )
<edit>
Oh. With vsync? I get a solid 60 all the way.
Also, your lib is rendering my polygons, points, and lines without a hitch, and about a half an hour's worth of work.
In your demo I'm getting about 740 FPS.
A couple of quick questions... Reading data from the screenbuffer... Is it any different? I need something like
somecolor = point(x,y)
...but probably faster. Can I read pixdata directly from the screen?
<edit>
and something like
Get ( source_gl_sprite, x1,y1, x2,y2, dest_gl_sprite )
<edit>
Oh. With vsync? I get a solid 60 all the way.
Also, your lib is rendering my polygons, points, and lines without a hitch, and about a half an hour's worth of work.
-
- Posts: 2655
- Joined: Aug 28, 2008 10:54
- Location: new york
I found a bug. This code is causing the fb.image to stretch across the buffer. If I call these two functions twice however:
gl2d.screen_init ( screen_x, screen_y )
gl2d.start_2d ( screen_x, screen_y )
There is no problem...
Weird.
gl2d.screen_init ( screen_x, screen_y )
gl2d.start_2d ( screen_x, screen_y )
There is no problem...
Weird.
Code: Select all
gl2d.screen_init ( screen_x, screen_y )
gl2d.start_2d ( screen_x, screen_y )
dim img as fb.image ptr = imagecreate( 32, 32, rgb(255, 0, 255), 32 )
circle img, (16, 16), 15, rgb(255, 255, 0), , , 1, f
circle img, (10, 10), 3, rgb( 0, 0, 0), , , 2, f
circle img, (23, 10), 3, rgb( 0, 0, 0), , , 2, f
circle img, (16, 18), 10, rgb( 0, 0, 0), 3.14, 6.28
gl2d.load_image_to_HW(cast(gl2d.image ptr, img))
'gl2d.vsync_on()
dim as integer numpoints = 1500, frames, fps
dim as double tnow, tlast
'dim as polygon p = LoadPoly2d ( "shape1.txt" )
'p = Scale ( p, 10,10 )
do
gl2d.clear_screen()
' GLPutPolygon2d ( , p )
' RotateRad (,.01,p )
gl2d.sprite(400,350,cast(gl2d.image ptr,img))
gl2d.set_blend_mode(GL2D.E_TRANS)
gl2d.sprite(500,0,cast(gl2d.image ptr,img))
gl2d.set_blend_mode(GL2D.E_BLENDED)
glColor4ub(255,255,255,128)
gl2d.sprite(550,0,cast(gl2d.image ptr,img))
gl2d.set_blend_mode(GL2D.E_SOLID)
gl2d.sprite(600,0,cast(gl2d.image ptr,img))
flip
sleep 1
frames+=1
If frames=100 Then
tNow = Timer()
fps = frames/(tNow-tLast)
windowtitle "fps = " & fps
Sleep 1
tLast=Timer():frames=0
End If
Loop Until Multikey( FB.SC_ESCAPE )
You can use glReadPixels to copy the pixel data from the framebuffer to a system memory buffer, or glCopyTexImage2D to copy pixel data from the framebuffer to a texture.A couple of quick questions... Reading data from the screenbuffer... Is it any different? I need something like
somecolor = point(x,y)
...but probably faster. Can I read pixdata directly from the screen?
They're both not very fast, glCopyTexImage2d is a bit faster. Also the double buffer usually causes me problems with those.
The best way would be using a Frame Buffer Object (FBO), but that's something I didn't have time to look at yet.