Allegro.cc - Online Community

Allegro.cc Forums » The Depot » OpenLayer 1.8 Released

Credits go to Arvidsson, Bob, Carrus85, Chris Katko, Edward Sheets, Evert, FMC, fuzinavl, Hrvoje Ban, juvinious, kazzmir, Krzysztof Kluczek, Mandrake Root Produc, Mark Oates, Mika Halttunen, miran, Mordredd, Phr00t, Rampage, ReyBrujo, Richard Phipps, Sepiroth, Thomas Fjellstrom, Tobi Vollebregt, Ultio, and Zaphos for helping out!
This thread is locked; no one can reply to it. rss feed Print
OpenLayer 1.8 Released
Mordredd
Member #5,291
December 2004
avatar

1#include <allegro.h>
2#include <OpenLayer.hpp>
3 
4using namespace std;
5using namespace ol;
6 
7int main( void )
8{
9 Setup::SetupProgram();
10 Setup::SetupScreen(1024, 768, false, 32);
11 
12 
13
14 Bitmap mouse_sprite(::mouse_sprite, false, true);
15 Bitmap foo;
16 foo.Load("test.png");
17
18 while (!key[KEY_ESC]) {
19 GfxRend::FillScreen(Rgba::WHITE);
20 
21 foo.Blit(0,0);
22 mouse_sprite.Blit(mouse_x, mouse_y);
23 GfxRend::RefreshScreen();
24 }
25 
26 return 0;
27 
28}
29END_OF_MAIN();

Hm... why does that crash?

RP: Why? There is no need for a C Version...

edit

Jeremy, give us your specs please...

Rampage
Member #3,035
December 2002
avatar

Quote:

RP: Why? There is no need for a C Version...

Since someone is asking, there IS a need for a C version ::).

-R

Mordredd
Member #5,291
December 2004
avatar

Quote:

Since someone is asking, there IS a need for a C version .

So? Then give me the reason...

Fladimir da Gorf
Member #1,565
October 2001
avatar

This has been discussed of already and I think it shouldn't be too hard to compile the C code as C++ even if you'd need to modify the malloc lines slightly... In my eyes it's the same thing that if a C++ user would have to use a C library they'd need to adapt C coding style to use the library.

EDIT:

Quote:

Hm... why does that crash?

Post allegro.log. Maybe the bitmap couldn't be loaded?

OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori)

Rampage
Member #3,035
December 2002
avatar

Quote:

So? Then give me the reason...

Because someone needs a C version. Or maybe you want to know why that someone needs a C version: because some people prefer to use pure C, or they don't know C++ at all, or they don't have a C++ compiler (ok, this is improbable, but still counts).

-R

Mordredd
Member #5,291
December 2004
avatar

If that is the case, they are to write a wrapper. That easy.

Fladimir da Gorf
Member #1,565
October 2001
avatar

Not knowing C++ isn't much of a problem as the examples in the manual show how to use the classes and functions. Prefering pure C... why do I use Allegro even if I prefer C++ over C? ;)

OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori)

Rampage
Member #3,035
December 2002
avatar

Someone who doesn't know C++... to write a C wrapper over a C++ library?

-R

Mordredd
Member #5,291
December 2004
avatar

If he/she does not know C++, he/she cannot either use the library or find someone who writes a wrapper for him/her. Personally, I prefer C++ very much over C, so that is why I am so strict.

Fladimir da Gorf
Member #1,565
October 2001
avatar

It's not that possible to just to write a C wrapper over a C++ library... the whole inner workings must be changed in this case. The only C++ you have to know to use OpenLayer is to know how to call a member function of a class. And the manual shows how to do this.

I understand all the C users, but... if you want to use a C library you have to learn C coding style. It's the same as if you want to use a C++ library you have to learn C++ coding style.

OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori)

Rampage
Member #3,035
December 2002
avatar

Quote:

If he/she does not know C++, he/she cannot either use the library or find someone who writes a wrapper for him/her. Personally, I prefer C++ very much over C, so that is why I am so strict.

That's exaclty the point. By using C++ you limit the potential users of the library. It's not a bad thing for the developer or C++ programmers, but for C programmers that need the functionality, it's a bad thing. And do you think it's right to alienate those programmers just because of a personal preference?

Ok, I'm just playing devil's advocate here, I do know C++, so why do I care?

-R

Fladimir da Gorf
Member #1,565
October 2001
avatar

Quote:

By using C++ you limit the potential users of the library.

But with that logic you could also say that by using C you limit the potential users (as I state in my previous posts). The best thing would be to have both C++ and C versions but... I'm not a C coder and maintaining the library is a big task already. If the C coders wish to use the C++ version all they have to do is to learn to call a member function ;)

OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori)

Rampage
Member #3,035
December 2002
avatar

Quote:

But with that logic you could also say that by using C you limit the potential users (as I state in my previous posts).

Since C++ is a superset of C, that's clearly not true, is it?

-R

Fladimir da Gorf
Member #1,565
October 2001
avatar

Quote:

Since C++ is a superset of C, that's clearly not true, is it?

Since C++ is a superset of C, you can compile a C program in C++ with little or no changes (and by using extern "C" in your code, with no changes). But the C and C++ coding styles are different and that's the point. The problem is not what the compiler can do, but what the programmer can do!

OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori)

Rampage
Member #3,035
December 2002
avatar

Fladimir da Gorf: I think you're mixing object oriented vs. structured programming. We're talking C vs. C++.

-R

Mordredd
Member #5,291
December 2004
avatar

Quote:

We're talking C vs. C++.

Exactly ::)

Richard Phipps
Member #1,632
November 2001
avatar

Yep, I don't know C++. Maybe I'll look into calling these member functions in the future though. :)

ReyBrujo
Moderator
January 2001
avatar

Just do what people often do when the library is officially in C and people want it in C++: write a wrapper.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Mordredd
Member #5,291
December 2004
avatar

Quote:

Just do what people often do when the library is officially in C and people want it in C++: write a wrapper.

Logic said:

Just do what people often do when the library is officially in C++ and people want it in C: write a wrapper ( ????? ) .

Fladimir da Gorf
Member #1,565
October 2001
avatar

Actually what I mean by the difference between the coding styles is exactly what you said - you can do OOP both C and C++ way, the difference is only your coding style. If you have to do it the C way you have to learn the C way and the same with C++.

EDIT:

Quote:

Just do what people often do when the library is officially in C and people want it in C++: write a wrapper.

The thing is that C++ coders are believed to know C but not the other way around.

OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori)

Mark Oates
Member #1,146
March 2001
avatar

Quote:

multi-line drawing, ellipses, textured polygons, maybe something else) and TexturizedMode, MultiMode, some other Bitmap drawing modes (any ideas?).

ohhh baby!! :o

Quote:

textured polygons

drools

I had an idea for a drawing mode that uses and ADDITIVE_BLENDER and SUBTRACTIVE_BLENDER, basically to add shadows or hilights on top of a sprite without the heed for an alpha channel.

also, I'd like more options for blenders. I have a full-screen one called desaturate (should probibly be called reduce_contrast()). it draws a transparent black and then transparent white block over the screen.

void desaturate_type_1(double ammount)
{
     gfx.Rect( 0, 0, RESOLUTION_X, RESOLUTION_Y, Rgba(0.0,0.0,0.0,ammount);
     gfx.Rect( 0, 0, RESOLUTION_X, RESOLUTION_Y, Rgba(1.0,1.0,1.0,ammount));
}

void desaturate_type_2(double ammount)
{
     Blenders::Set(( SUBTRACTIVE_BLENDER ));
     gfx.Rect( 0, 0, RESOLUTION_X, RESOLUTION_Y, Rgba(0.0,0.0,0.0,ammount));
     Blenders::Set(( ADDITIVE_BLENDER ));
     gfx.Rect( 0, 0, RESOLUTION_X, RESOLUTION_Y, Rgba(1.0,1.0,1.0,ammount));
     Blenders::Set(( ALPHA_BLENDER ));
}

the second one has 3 calles to change the blender (not very efficent). but if that gives you any ideas.

hmm....
NEGATIVE_BLENDER
HUE_BLENDER

Mandrake Root Produc
Member #300
April 2000

But take the OO out of C++ and you have C. His point is a valid one. esp this->

Quote:

I'm not a C coder and maintaining the library is a big task already

Unless you want him to burn out, don't make crazed suggestions. I've tried to support a community tool myself (Freya), and I burnt out by implementing too many user suggestions.

Speaking of which, have you thought of building in Lua or Python wrappers?

Mordredd
Member #5,291
December 2004
avatar

I am fed up, for the stupid meh: give me a minimalistic pr*gram with ol that simply displays a bitmap. There is something I am doing wrong, but I can't see the forest because of trees meh thinks...

Fladimir da Gorf
Member #1,565
October 2001
avatar

Quote:

it draws a transparent black and then transparent white block over the screen.

How does that actually reduce contrast? It effectively gets rid of dark shades at least ;) But reducing contrast would mean multiplying the distance of the color from the middle gray by the amount, I think.

Also, wouldn't a function called desaturate get rid of the saturation (making the image grayscale?)

EDIT:
Micah, you need to register the png file type, see the manual for Bitmap.

register_bitmap_file_type( "png", load_png, 0 );

This won't be needed in the next version as I'll include an updated version of Loadpng (which has the missing source file...) You need to #include <loadpng.h> for that, though.

And always check allegro.log! I did that and saw that the bitmap loading failed so I guessed what was wrong right away ;)

OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori)

Mark Oates
Member #1,146
March 2001
avatar

ah, I also have used a dotted line in my progam, perhaps it's something you might want to add.

transparency = 0.4;
float xCoordinates[numVertices] = { x1-7+offset_x, x2+5+offset_x, x2-2+offset_x, x1+5+offset_x };
float yCoordinates[numVertices] = { y1-4+offset_y, y1-2+offset_y, y2+4+offset_y, y2-2+offset_y };
glEnable(GL_LINE_STIPPLE);  // sets the line type to dotted
glLineStipple(1, 255);  // defines the dash-dot pattern
glLineWidth(10);  // well, sets the width, DUH! ;)
gfx.PolygonOutline( xCoordinates, yCoordinates, numVertices, color );
glDisable(GL_LINE_STIPPLE);  // set the line type back to normal

[edit:]

Quote:

Also, wouldn't a function called desaturate get rid of the saturation (making the image grayscale?)

yes. I guess it would. that sounds like a cool idea. http://www.markmusicproduction.com/stuff/wistle.bmp

reduce_contrast basically adds grey to the picture, so yea, you're right about that one.

Micah, I think you should start a new thread.



Go to: