Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » HELP! Problem when I tried to make a5 and librocket gui work together.

This thread is locked; no one can reply to it. rss feed Print
HELP! Problem when I tried to make a5 and librocket gui work together.
fy0001
Member #15,516
February 2014

I found a GUI library called library two days ago, and it's here.
librocket

Then I build the DX sample, looks like that:
{"name":"608507","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/8\/080dbc5585b6cafe8029c9f486741556.png","w":1030,"h":764,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/8\/080dbc5585b6cafe8029c9f486741556"}608507

Now I try to write an allegro render, I got that:
.....

==================================================================================

Well, now i'm succeeded.
but i don't know why.

The font texture gen function are absolutely wrong, but it looks like works fine.I don't know why, it just works.
↓↓↓
bool RocketAllegroRenderer::GenerateTexture(...)

And it's my codes:
https://www.allegro.cc/files/attachment/608519

Thomas Fjellstrom
Member #476
June 2000
avatar

This is just a guess, but I bet your transform is wrong in some way.

--
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

fy0001
Member #15,516
February 2014

Maybe al_draw_indexed_prim call has problem?

Another opengl render here:
opengl

I think my codes did same work.

#SelectExpand
1void RocketSDLRenderInterfaceOpenGL::RenderGeometry(Rocket::Core::Vertex* vertices, 2 int num_vertices, 3 int* indices, 4 int num_indices, 5 const Rocket::Core::TextureHandle texture, 6 const Rocket::Core::Vector2f& translation) { 7 glPushMatrix(); 8 glTranslatef(translation.x, translation.y, 0); 9 10 std::vector<Rocket::Core::Vector2f> Positions(num_vertices); 11 std::vector<Rocket::Core::Colourb> Colors(num_vertices); 12 std::vector<Rocket::Core::Vector2f> TexCoords(num_vertices); 13 float texw, texh; 14 15 SDL_Texture* sdl_texture = NULL; 16 if(texture) { 17 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 18 sdl_texture = (SDL_Texture *) texture; 19 SDL_GL_BindTexture(sdl_texture, &texw, &texh); 20 } 21 22 for(int i = 0; i < num_vertices; i++) { 23 Positions[i] = vertices[i].position; 24 Colors[i] = vertices[i].colour; 25 if (sdl_texture) { 26 TexCoords[i].x = vertices[i].tex_coord.x * texw; 27 TexCoords[i].y = vertices[i].tex_coord.y * texh; 28 } 29 else { 30 TexCoords[i] = vertices[i].tex_coord; 31 } 32 } 33 34 glEnableClientState(GL_VERTEX_ARRAY); 35 glEnableClientState(GL_COLOR_ARRAY); 36 glVertexPointer(2, GL_FLOAT, 0, &Positions[0]); 37 glColorPointer(4, GL_UNSIGNED_BYTE, 0, &Colors[0]); 38 glTexCoordPointer(2, GL_FLOAT, 0, &TexCoords[0]); 39 40 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 41 glEnable(GL_BLEND); 42 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 43 glDrawElements(GL_TRIANGLES, num_indices, GL_UNSIGNED_INT, indices); 44 glDisableClientState(GL_VERTEX_ARRAY); 45 glDisableClientState(GL_COLOR_ARRAY); 46 47 48 if (sdl_texture) { 49 SDL_GL_UnbindTexture(sdl_texture); 50 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 51 } 52 53 glColor4f(1.0, 1.0, 1.0, 1.0); 54 glPopMatrix(); 55}

SiegeLord
Member #7,827
October 2006
avatar

I'm a bit confused at what the problem is here... the letters appear to be placed in the right spot, and the only issue is that they have the wrong background and for whatever reason you're rendering only half the text. Maybe you're loading your textures incorrectly? The code you're using in that .rar certainly seems incorrect:

#SelectExpand
1 ALLEGRO_BITMAP* image = al_create_bitmap(source_dimensions.x, source_dimensions.y);
2 ALLEGRO_LOCKED_REGION* region = al_lock_bitmap(image, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_READWRITE);
3 4 for (int y = 0; y < source_dimensions.y; ++y) 5 { 6 for (int x = 0; x < source_dimensions.x; ++x) 7 { 8 const byte* source_pixel = source + (source_dimensions.x * 4 * y) + (x * 4); 9 byte* destination_pixel = ((byte*) region->data) + region->pitch * y + x * 4;
10 destination_pixel[0] = source_pixel[3];
11 destination_pixel[1] = source_pixel[3]; 12 destination_pixel[2] = source_pixel[3]; 13 destination_pixel[3] = source_pixel[3]; 14 } 15 }

You probably want to be locking with ALLEGRO_PIXER_FORMAT_RGBA_8888 format. Also, the indices you use when copying over data seem to be wrong.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Go to: