I am just getting my feet wet with Spring programming. Am interested in doing some gui related work. To start off with, though, I tried something small. I've always been annoyed by map markers that are very hard to see when the player colour is close to the colour of the map. So, this is my first attempt at a solution - make the marker have a black outline. I personally think it's easier to see, but others may disagree. Here is the patched code:
Code: Select all
Index: InMapDraw.cpp
===================================================================
--- InMapDraw.cpp (revision 1433)
+++ InMapDraw.cpp (working copy)
@@ -46,23 +46,31 @@
for(int y=0;y<64;y++){ //circular thingy
for(int x=0;x<64;x++){
float dist=sqrt((float)(x-32)*(x-32)+(y-32)*(y-32));
- if(dist>31.875)
- dist=31.875;
- tex[y][x][0]=255;
- tex[y][x][1]=255;
- tex[y][x][2]=255;
- tex[y][x][3]=(unsigned char) (255-dist*8);
+ if (dist > 31.875) {
+ // do nothing - leave transparent
+ } else if (dist > 24.5) {
+ // black outline
+ tex[y][x][3]=255;
+ } else {
+ tex[y][x][0]=255;
+ tex[y][x][1]=255;
+ tex[y][x][2]=255;
+ tex[y][x][3]=(unsigned char) (255-dist*8);
+ }
}
}
for(int y=0;y<64;y++){ //linear falloff
for(int x=0;x<64;x++){
float dist=abs(y-32);
- if(dist>31.5)
- dist=31.5;
- tex[y][x+64][0]=255;
- tex[y][x+64][1]=255;
- tex[y][x+64][2]=255;
- tex[y][x+64][3]=(unsigned char) (255-dist*8);
+ if(dist > 24.5) {
+ // black outline
+ tex[y][x+64][3]=255;
+ } else {
+ tex[y][x+64][0]=255;
+ tex[y][x+64][1]=255;
+ tex[y][x+64][2]=255;
+ tex[y][x+64][3]=(unsigned char) (255-dist*8);
+ }
}
}
glGenTextures(1, &texture);
Belmakor