Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Framebuffer?

This thread is locked; no one can reply to it. rss feed Print
 1   2 
Framebuffer?
Eric Johnson
Member #14,841
January 2013
avatar

Ha ha; Trent, you rock! There it is: wiz_display_fb, wiz_display_opengl, wiz_joystick, and wiz_system! :o What I'm really here for is the wiz_display_fb, right; you think it could be modified to support what I have going on?

[EDIT]
Also, people on the Raspberry Pi forum are telling me that the Pi supports both GL and GL ES (there's even a sub-forum about it). Yet Allegro on the Pi doesn't use GL, does it?

Elias
Member #358
May 2000

Allegro uses OpenGL ES. But if I understand this thread right, the question is whether OpenGL ES (not Allegro) can work with your monitor (since it might just send the data to the HDMI port).

--
"Either help out or stop whining" - Evert

Eric Johnson
Member #14,841
January 2013
avatar

Oh, I see. Thanks, Elias. Then scratch the GL and GL ES whatnots. I'm looking at the GP2X files now.

[EDIT]
Taking a look at the wiz files, I've found a few issues. In wiz_system.c, the inclusion of "allegro5/internal/aintern_gp2xwiz.h" doesn't exist; the same applies to wiz_display_opengl.c. Also, aintern_bitmap.h and aintern_opengl.h are missing. As a matter of fact, this also applies to wiz_display_fb.c. This comes at no surprise though, as this is older, so it makes sense things go missing.

Trent Gamblin
Member #261
April 2000
avatar

In those blog posts I made is the important stuff you need. There should be a libwiz or something like that attached to one post. That has the main bulk of the framebuffer code. Actually it's based on libcastor which you can probably find for wiz.

Eric Johnson
Member #14,841
January 2013
avatar

I haven't yet found the attached file(s) you speak of (still browsing the blog), but I did find libcastor 0.2, which debuted on January the 26th, of 2009. The contents of the libcastor files are opaque to me; I understand C's constructs and whatnot, but it's difficult to follow... Aah, I see there's a readme with documentation links. I'll explore those for a while.

[EDIT]
The documentation site has a lovely SQL error; nice. Trent, what you did was modeled off of the libcastor files (or perhaps modified off of)?

Trent Gamblin
Member #261
April 2000
avatar

I modified libcastor but only slightly. You should be able to start with that and work from there.

Eric Johnson
Member #14,841
January 2013
avatar

Sounds good; thanks, Trent. I don't quite know where to start with this, but I'll give it a go and play with it for a while. Also, on an off-topic question: how long must a thread remain untouched for it to be locked by the system? I've gone places before and left threads for a while, only to return and have them locked. I'd rather than not happen here. :P

Vanneto
Member #8,643
May 2007

Threads get locked after 1 week of inactivity. But opening a new thread is no problem and is even encouraged. So don't worry man. >:(

In capitalist America bank robs you.

Arthur Kalliokoski
Second in Command
February 2005
avatar

The stale threads are locked to avoid people dredging up stuff that's several months or years old, and nobody cares about them anymore. But if you have something truly valuable to say, go ahead and make a new thread.

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”

― Robert A. Heinlein

Eric Johnson
Member #14,841
January 2013
avatar

Thanks for clearing that up for me! ;D On other forums, posting new topics that continue threads which have been locked is deemed as spam, so I wasn't sure. Thanks for the input.

Thomas Fjellstrom
Member #476
June 2000
avatar

If the thread was locked my a moderator, then yes, continuing it in the same way the thread ended would be seen as spam or against the rules.

But even in the case it was locked by a moderator, if you continue it on topic, (threads usually get locked by a mod after they go way off topic) then its ok.

The rules here are fairly lax.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Eric Johnson
Member #14,841
January 2013
avatar

That's good to know, Thomas; thank you. :D

Trent, I found some files pertaining to the Wiz on your blog. I don't know if they are the correct files, but they're the only ones I've found so far. I'm looking them over now, trying to make sense of them. There is hope yet.

[EDIT]
You even were kind enough to upload a bitmap example file for the Wiz. I'll post it here just for the heck of it.

#SelectExpand
1#include "allegro5/allegro5.h" 2#include "allegro5/a5_iio.h" 3#include "allegro5/a5_primitives.h" 4 5#include <stdio.h> 6#include <stdarg.h> 7 8int main(void) 9{ 10 al_init(); 11 al_init_iio_addon(); 12 13 al_create_display(320, 240); 14 ALLEGRO_BITMAP *bmp = al_load_bitmap("rock.tga"); 15 16 int i; 17 const int NUM = 250; 18 19 ALLEGRO_VERTEX v[NUM*6]; 20 21 struct Info { 22 float dx, dy; 23 float a; 24 float maxscale; 25 float currscale; 26 float ds; 27 float x, y; 28 } info[NUM]; 29 30 for (i = 0; i < NUM; i++) { 31 int w = al_get_bitmap_width(bmp); 32 int h = al_get_bitmap_height(bmp); 33 v[i*6].x = 0; 34 v[i*6].y = h; 35 v[i*6].u = 0; 36 v[i*6].v = 0; 37 v[i*6].color = al_get_prim_color(al_map_rgb(255, 255, 255)); 38 39 v[i*6+1].x = 0; 40 v[i*6+1].y = 0; 41 v[i*6+1].u = 0; 42 v[i*6+1].v = 1; 43 v[i*6+1].color = al_get_prim_color(al_map_rgb(255, 255, 255)); 44 45 v[i*6+2].x = w; 46 v[i*6+2].y = h; 47 v[i*6+2].u = 1; 48 v[i*6+2].v = 0; 49 v[i*6+2].color = al_get_prim_color(al_map_rgb(255, 255, 255)); 50 51 52 v[i*6+3].x = w; 53 v[i*6+3].y = 0; 54 v[i*6+3].u = 1; 55 v[i*6+3].v = 1; 56 v[i*6+3].color = al_get_prim_color(al_map_rgb(255, 255, 255)); 57 58 59 v[i*6+4].x = 0; 60 v[i*6+4].y = 0; 61 v[i*6+4].u = 0; 62 v[i*6+4].v = 1; 63 v[i*6+4].color = al_get_prim_color(al_map_rgb(255, 255, 255)); 64 65 66 v[i*6+5].x = w; 67 v[i*6+5].y = h; 68 v[i*6+5].u = 1; 69 v[i*6+5].v = 0; 70 v[i*6+5].color = al_get_prim_color(al_map_rgb(255, 255, 255)); 71 72 info[i].dx = rand() % 3 - 1 * ((rand() % RAND_MAX) / (float)RAND_MAX * 2); 73 info[i].dy = rand() % 3 - 1 * ((rand() % RAND_MAX) / (float)RAND_MAX * 2); 74 75 info[i].a = (float)((rand() % RAND_MAX) / (float)RAND_MAX) * 0.2f; 76 info[i].maxscale = ((rand() % RAND_MAX) / (float)RAND_MAX) * 4 + 4; 77 info[i].ds = rand() % 2 ? 0.95f : 1.05f; 78 info[i].currscale = 1; 79 80 info[i].x = rand() % 320; 81 info[i].y = rand() % 240; 82 } 83 84 long now = al_current_time(); 85 86 for (i = 0; i < 60*10; i++) { 87 al_clear_to_color(al_map_rgb(0, 0, 0)); 88 int j; 89 for (j = 0; j < NUM; j++) { 90 info[j].currscale *= info[j].ds; 91 if (info[j].ds < 1) { 92 if (info[j].currscale < 1) { 93 info[j].ds = 1.05f; 94 info[j].currscale = 1; 95 } 96 } 97 else { 98 if (info[j].currscale > info[j].maxscale) { 99 info[j].ds = 0.95f; 100 info[j].currscale = info[j].maxscale; 101 } 102 } 103 104 ALLEGRO_TRANSFORM t; 105 al_identity_transform(&t); 106 al_translate_transform(&t, -v[j*6+1].x-8, -v[j*6+1].y-8); 107 int k; 108 for (k = 0; k < 6; k++) { 109 al_transform_vertex(&t, &v[j*6+k]); 110 } 111 al_build_transform(&t, info[j].x+8, info[j].y+8, info[j].ds, 112 info[j].ds, info[j].a); 113 for (k = 0; k < 6; k++) { 114 al_transform_vertex(&t, &v[j*6+k]); 115 } 116 117 info[j].x += info[j].dx * 0.4f; 118 info[j].y += info[j].dy * 0.4f; 119 120 if (info[j].x < 0) 121 info[j].dx = -info[j].dx; 122 else if (info[j].x > 320) 123 info[j].dx = -info[j].dx; 124 125 if (info[j].y > 240) 126 info[j].dy = -info[j].dy; 127 else if (info[j].y < 0) 128 info[j].dy = -info[j].dy; 129 } 130 al_draw_prim(v, bmp, 0, NUM*6, ALLEGRO_PRIM_TRIANGLE_LIST); 131 al_flip_display(); 132 } 133 134 long end = al_current_time(); 135 printf("FPS=%d\n", (int)(600/(end-now))); 136 137 al_uninstall_system(); 138 139 return 0; 140} 141END_OF_MAIN()

Trent Gamblin
Member #261
April 2000
avatar

Well, there's no point in me looking up my modified version of libcastor really. All it did was combine the OpenGL libraries and libcastor and clean it up a little but that's mostly Wiz specific. If you're serious about writing a framebuffer driver, look into SDL's framebuffer code, or optionally libcastor's. When you get that far, the attached file might help with optimization (too big to inline.)

That is one file that was removed from the Allegro repo. I believe I got 30-60 fps on Wiz (a very slow system) with these routines.

Eric Johnson
Member #14,841
January 2013
avatar

I am serious about this, as it'd be quite helpful to me. :P I'm going at it somewhat blind though, so it'll take some time. I appreciate you giving me these files.

[EDIT]
I've been messing around with drawing low-level "graphics" (just colors really) to the framebuffer in C. It's pretty cool how this stuff works. So basically I'm getting a feel for how this stuff works before I go into attempting to make it work with Allegro. Cool stuff though.

 1   2 


Go to: