This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
46
Function Peer Review / Custom: Curve drawing functions (Bezier and Spline)
« on: December 02, 2010, 09:36:53 am »Curve functions
Version:1.1
Changelog:
1.1
-Added new spline functions that have control points
-Made spline_begin() function use vectors and stacks. This decreases memory consumption and allows nesting (several _begin() and _end() inside one another).
-Added new _end() function that optimizes the curve (reduces vertexes based on point distance).
-Added anti-aliasing functions.
Description: These are functions for drawing curves. Both Bezier and splines. These functions allow drawing them with specific widths, with alpha and color blending, as well as getting points on the curve.
Functions:
Code: (C++) [Select]
void draw_bezier_quadratic(float x1,float y1,float x2,float y2,float x3,float y3);
void draw_bezier_cubic(float x1,float y1,float x2,float y2,float x3,float y3, float x4, float y4);
void draw_set_curve_color(int c1, int c2);
void draw_set_curve_alpha(float a1, float a2);
void draw_set_curve_mode(int mode);
void draw_set_curve_detail(int detail);
void draw_set_curve_width(int width);
void draw_set_antialiasing(bool enable, int qual);
float draw_bezier_quadratic_x(float x1,float y1,float x2,float y2,float x3,float y3, float t);
float draw_bezier_quadratic_y(float x1,float y1,float x2,float y2,float x3,float y3, float t);
float draw_bezier_cubic_x(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float t);
float draw_bezier_cubic_y(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float t);
void draw_spline_part(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, int c1, int c2, float a1, float a2);
void draw_spline2c(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
void draw_spline3(float x1, float y1, float x2, float y2, float x3, float y3);
void draw_spline3c(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float x5, float y5);
void draw_spline4(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
void draw_spline4c(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float x5, float y5, float x6, float y6);
void draw_spline_begin(int mode);
int draw_spline_vertex(float x, float y);
int draw_spline_vertex_color(float x, float y, int col, float alpha);
void draw_spline_end();
int draw_spline_optimized_end();
Most functions are self explanatory (if not, then the example shows most of them at work). Only things I should note is about draw_spline_part, which is not actually meant to be used. It is used in other spline functions and that is the one that actually draws the spline. You can use it separately if you wish, thou then you need to call glBegin and glEnd, because that function only returns vertexes.Another function I should note is draw_spline2c, it draws a line between two points, but accounts for two control points that shape the actual line. The rest of the spline drawing functions that have c at the end act the same. The first and the last points are control points.
draw_spline_begin() function needs at least 4 points to draw one line. The first and the last point is a control point.
draw_spline_optimized_end() function should be used in some cases like when there are a lot of points and many of them can be close together. This function checks the distance of the two points and then reduces the vertex count as needed. The maximum vertex count is still pr_curve_detail (set by draw_set_curve_detail()). This function returns the vertex number drawn.
Download: GMK and .h/.cpp files can be downloaded from attachments. Exe version of the example (just to check it out or if it doesn't work for you) can be downloaded here: http://www.host-a.net/u/harrikiri/curvesexample.zip.
Installation: As Enigma doesn't have an easy 2 click extension mechanism now (or will never have?!?), you need to put these files in manually. Copy GScurves.h and GScurves.cpp into Enigma\ENIGMAsystem\SHELL\Graphics_Systems\OpenGL (preferably). Then open: Enigma\ENIGMAsystem\SHELL\SHELLmain.cpp and put #include "Graphics_Systems/OpenGL/GScurves.h" into line 63 or so (after #if ENIGMA_GS_OPENGL). Then either use bash script located in Enigma\ENIGMAsystem\SHELL\Developer\automake.sh, or if you are on Windows (like me), then just open Enigma\ENIGMAsystem\SHELL\Graphics_Systems\OpenGL\Makefile and add:
Quote
.eobjs_$(MODE)/GScurves.o: GScurves.cpp OpenGLHeaders.hTo somewhere in the top. And: ".eobjs_Run/GScurves.o" everywhere at the bottom (just look where similar action is done.
g++ -c GScurves.cpp -o .eobjs_$(MODE)/GScurves.o $(FLAGS)
Notice: You need to actually do additional things to run the example or use this code as intended. First, you need to fix merge_color function which is buggy in the current repo. To fix this, find and open GScolors.cpp, find merge_color function and replace the code with this:
Code: [Select]
int merge_color(int c1,int c2,double amount)
{
amount = amount > 1 ? 1 : (amount < 0 ? 0 : amount);
return
(unsigned char)(fabs(__GETR(c1)+(__GETR(c2)-__GETR(c1))*amount))
| (unsigned char)(fabs(__GETG(c1)+(__GETG(c2)-__GETG(c1))*amount))<<8
| (unsigned char)(fabs(__GETB(c1)+(__GETB(c2)-__GETB(c1))*amount))<<16;
}
Second, you need to add a new math function, which I didn't just insert as a script for some reason. Its lerp (linear interpolation) and seemed useful as a standard function. Open mathnc.cpp and put this somewhere:Code: [Select]
double lerp(double x, double y, double a) { return x + ((y-x)*a); }
Also, open mathnc.h and add the header:Code: [Select]
double lerp(double x, double y, double a);
I think this should be all. Maybe I have forgotten something, so if you get an error post it here.Example controls: You can scroll through rooms with left and right arrows. In the third room (where there is initially just a black screen) you can draw a curve with your mouse. Left click to add a point, or hold right button to add a lot of points. In the last room you can move that jelly thing to your mouse with left click and increase/decrease detail with up and down arrows. Room system seems buggy, so I couldn't find a way to return back to previous rooms. Its just restarts from the first room when you press left arrow. Press number keys to disable, enable and change quality of anti-aliasing. 1-Disabled. 2-Enabled, fastest. 3-Enabled, nicest. 4-Enabled, don't care.
To-Do:
-Add new functions to get points on splines
Thanks to LSnK for inspiring me to make this for Enigma, as well as making that beautiful example (which modified code is used in this example too).
47
Issues Help Desk / Can't draw anything inside _begin _end
« on: November 30, 2010, 02:02:19 pm »
While testing my curve functions I innially could not get why my curves drawed normally some times, but not others. I found out that a draw_circle was to blame, which I used to mark the points. When I start drawing a spline with draw_spline_begin() it just does:
Also, if I have to save points + colors + alphas in an array, then should I use something like this:
http://www.fredosaurus.com/notes-cpp/newdelete/50dynamalloc.html
or just:
float pr_point_ar[MAXPOINTS][4];
MAXPOINTS could be changed, or just be a large number by default.
I don't want to do that dynamic deleting and allocation because I would need to do this for every point... Or I could alloc, for example, 64 points at a time, and when I run out I alloc another 64. This wouldn't waste much memory and should be faster, but then again its another if cycle.
Also, I guess I should post these as tickets in the tracker, but I might as well put it here:
draw_merge doesn't work. I wasted about 40min trying to figure out why I can't blend my curve smoothly, and it ends up that the function doesn't return the right values. For example, merge_color(c_red,c_white,1), will return c_red even thou it needs to return c_white. Either way, this is how I fixed it:
Also, draw_get_color() (or anything draw_get for that matter) returns nan all the time.. I have this code:
edit: Anyway, as you can see this post started as a question, but by the second paragraph I realized how to fix this myself (by drawing in _end), so the first part can be ignored I guess.
Code: [Select]
glPushAttrib(GL_CURRENT_BIT);
glBegin(mode);
And when I draw a circle or any other shape in between it will get points on that circle, and thus mess up my curve. This is exactly the same problem with the already implemented draw_primitive functions. Try something like this and see for yourself:Code: [Select]
draw_primitive_begin(pr_linestrip);
draw_vertex(10,10);
draw_vertex(100,50);
draw_circle(500,300,5,1);
draw_vertex(50,300);
draw_primitive_end();
In GM it does allow things like this. The way it does this is that the _end function is the one that draws it. So I guess this is how I need to do it too? I already save points in an array, so I guess its not a problem, but still. There is some DEPTHBUFFER code already done in primitive functions and in thous it does save points as well. So drawing it in _end would be the best bet I guess.Also, if I have to save points + colors + alphas in an array, then should I use something like this:
http://www.fredosaurus.com/notes-cpp/newdelete/50dynamalloc.html
or just:
float pr_point_ar[MAXPOINTS][4];
MAXPOINTS could be changed, or just be a large number by default.
I don't want to do that dynamic deleting and allocation because I would need to do this for every point... Or I could alloc, for example, 64 points at a time, and when I run out I alloc another 64. This wouldn't waste much memory and should be faster, but then again its another if cycle.
Also, I guess I should post these as tickets in the tracker, but I might as well put it here:
draw_merge doesn't work. I wasted about 40min trying to figure out why I can't blend my curve smoothly, and it ends up that the function doesn't return the right values. For example, merge_color(c_red,c_white,1), will return c_red even thou it needs to return c_white. Either way, this is how I fixed it:
Code: [Select]
int merge_color(int c1,int c2,double amount)
{
amount = amount > 1 ? 1 : (amount < 0 ? 0 : amount);
return
(unsigned char)(fabs(__GETR(c1)+(__GETR(c2)-__GETR(c1))*amount))
| (unsigned char)(fabs(__GETG(c1)+(__GETG(c2)-__GETG(c1))*amount))<<8
| (unsigned char)(fabs(__GETB(c1)+(__GETB(c2)-__GETB(c1))*amount))<<16;
}
I think fabs can be removed somehow.Also, draw_get_color() (or anything draw_get for that matter) returns nan all the time.. I have this code:
Code: [Select]
pr_point_ar[i][2] = (pr_curve_color1 == -1 ? draw_get_color() : merge_color(pr_curve_color1,pr_curve_color2,1/(pr_spline_points+1)))
And it will return nan if pr_curve_color1 is -1 (so its calling merge_color). I just tested std::cout << merge_color(col1,col2,1) and got the same result. Couldn't find the reason thou... I looked in GScolors.cpp and everything seems fine.edit: Anyway, as you can see this post started as a question, but by the second paragraph I realized how to fix this myself (by drawing in _end), so the first part can be ignored I guess.
48
Issues Help Desk / extern double returns 0
« on: November 25, 2010, 08:23:13 am »
Solved: No need to read this unless you're bored.
I am playing with some curves (sounds dirty doesn't it?) and I have a problem almost totally unrelated to that. For some eye candy I usually use cos/sin and current_time to get oscillation. I used current_time and it always returned 0, then I found out that actually current_time is not defined anywhere (and Enigma doesn't report non existing variables, they just assume 0, and that is bad (people don't suggest to use "Threat undefined variables as 0" for a reason)). Anyway, I went to implement it myself thinking it is easy. Found key_game_globals.h, and uncommented "extern double current_time;". Then went into WINDOWSmain.cpp and modified a small part to this:
I also uncommented the line in GAME_GLOBALS.h to "double current_time;".
edit: I did everything right. Just didn't occur to me to restart LGM (I know I need to do this when I update header files, but not when I update .cpp files).
I am playing with some curves (sounds dirty doesn't it?) and I have a problem almost totally unrelated to that. For some eye candy I usually use cos/sin and current_time to get oscillation. I used current_time and it always returned 0, then I found out that actually current_time is not defined anywhere (and Enigma doesn't report non existing variables, they just assume 0, and that is bad (people don't suggest to use "Threat undefined variables as 0" for a reason)). Anyway, I went to implement it myself thinking it is easy. Found key_game_globals.h, and uncommented "extern double current_time;". Then went into WINDOWSmain.cpp and modified a small part to this:
Code: [Select]
extern double fps, current_time;
namespace enigma {
clock_t lc;
void sleep_for_framerate(int rs)
{
clock_t nc = clock();
int sdur = 1000/rs - 1 - (nc - lc)*1000 / CLOCKS_PER_SEC;
if (sdur > 0)
{
Sleep(sdur);
fps = room_speed;
}
else
{
fps = CLOCKS_PER_SEC / (nc - lc);
if(fps > room_speed){ fps = room_speed; }
}
lc = nc;
current_time = clock() / double(CLOCKS_PER_SEC) * 1000;
}
}
So now current_time holds ms till the program launched. In GM it actually holds the number of ms the system has started, but whatever. Now whenever I use "extern double current_time;" in .cpp I can get that number and it works great. But the problem is that when I use string(current_time) in Enigma it just still returns 0. Did I miss a place to put it?I also uncommented the line in GAME_GLOBALS.h to "double current_time;".
edit: I did everything right. Just didn't occur to me to restart LGM (I know I need to do this when I update header files, but not when I update .cpp files).
49
General ENIGMA / The Life of a Games Progammer (GM dev blog)
« on: November 15, 2010, 04:34:25 pm »
I don't know how many of you are aware of this blog, but I have been following it for quite a while now. Link is http://dailly.blogspot.com/. Its the blog for GM's programmer that YYG hired to write runner in C++ and port GM to other platforms. There is some interesting technical details, even thou they are not that complicated (as they are meant for the layman I suppose). And there he writes about many aspect GM and in turn Enigma has either implemented, it is going to implement, or should implement.
1) First things first - Texture packing. I am aware that Josh is using some rectangle packing algorithm (or he is developing his own) for fonts. What Enigma should also do would be packing as many sprites/backgrounds inside one texture as well. Mike (that's the name of that guy) posted on how GM now uses that to launch on devices with limited GPU speed and memory. Pluses for this are quite obvious - there would be a lot less texture switching, and the amount of memory used would also decrease substantially. Enigma already uses spr2d->texbordx and spr2d->texbordy to get the point where sprite has its width and height and so the rest of the texture is not needed. With texture packing there wouldn't be that much things to add, except spr2d->texbord_left and spr2d->texbord_top or something similar. Then the drawing functions could be changed easily to accommodate that. Like setting every texture size to 512x512 (something every GPU, even mobile device should support), and then packing as many images in that 512x512 as possible.
2) Next he speaks about many aspect of GM and how it could be improved by using types (Enigma already supports thous), structs (Enigma doesn't supports them for now, or ever or I am wrong) and some other stuff. From previous posts I get that he would want to implement them, but they don't plan to do that for now (because Mark wants his tool to still be very easy). Thou he showed that it wouldn't change anything in GML (just like in Enigma), so if you don't want to use types, then don't and it automatically uses doubles, but if you really know what you are doing then you can easily declare an int.
Anyway, there are more things. I don't think that we should denigrate (is that the word?) that guy because he works in the Evil YYG. There are many things we can learn about GM future development, and in turn, it could affect our development as well.
1) First things first - Texture packing. I am aware that Josh is using some rectangle packing algorithm (or he is developing his own) for fonts. What Enigma should also do would be packing as many sprites/backgrounds inside one texture as well. Mike (that's the name of that guy) posted on how GM now uses that to launch on devices with limited GPU speed and memory. Pluses for this are quite obvious - there would be a lot less texture switching, and the amount of memory used would also decrease substantially. Enigma already uses spr2d->texbordx and spr2d->texbordy to get the point where sprite has its width and height and so the rest of the texture is not needed. With texture packing there wouldn't be that much things to add, except spr2d->texbord_left and spr2d->texbord_top or something similar. Then the drawing functions could be changed easily to accommodate that. Like setting every texture size to 512x512 (something every GPU, even mobile device should support), and then packing as many images in that 512x512 as possible.
2) Next he speaks about many aspect of GM and how it could be improved by using types (Enigma already supports thous), structs (Enigma doesn't supports them for now, or ever or I am wrong) and some other stuff. From previous posts I get that he would want to implement them, but they don't plan to do that for now (because Mark wants his tool to still be very easy). Thou he showed that it wouldn't change anything in GML (just like in Enigma), so if you don't want to use types, then don't and it automatically uses doubles, but if you really know what you are doing then you can easily declare an int.
Anyway, there are more things. I don't think that we should denigrate (is that the word?) that guy because he works in the Evil YYG. There are many things we can learn about GM future development, and in turn, it could affect our development as well.
50
Graphics and Video / ENIGMA examples - Games
« on: November 07, 2010, 04:17:21 pm »
I have created some awesome (AWESOME) shit for GM too. I could make some "examples" if you want. Like the Galactic Invaders thing, where you fly, shoot and get points. I am quite good with graphics too. Question is do the "examples" need to be like tutorials where every step is explained or just a game they way I make it and everyone can learn from it if they can.?
51
Function Peer Review / GML: All draw_text functions +(string_width, _height, _width_ext, _height_ext)
« on: October 29, 2010, 01:34:35 pm »
This is updated in 30.04.2011!
Description: These are all draw_text functions + string_width, _height and string_width_ext, and _height_ext functions. They are very optimized (thanks to Josh) and so they should work great.
Notice: They are mostly the same as GM ones, but GM's color interpolation and text position is a little different. There are two images to compare at the next page.
Functions:
You can download GSFont.h and .cpp in attachment, as well as a little screenshot. It shows draw_text_color and draw_text_ext_transformed_color.
P.s.: It wasn't as easy as I thought at the beginning. Mostly because of the trig for _transform and _ext functions that come with it.
Also, what do you suggest on dealing with the # newline character? The easiest thing would be searching for all # and then checking if / is in front of it, if its not then it is a newline char, if there is a / in front, then just replace /# with # and draw it. But I think there should be some better way, like using regular expressions, but that could end up being a lot slower.?
Also, "prop" argument doesn't work in font_add_sprite. With the font sprite I tried it with it just returns 0x0 size, so it doesn't draw anything. I will look into that if Josh doesn't.
edit: Nevermind about the # question. Enigma will do this automatically, at least Josh said so.
edit2: I added string_width, _height and _ext functions.
Description: These are all draw_text functions + string_width, _height and string_width_ext, and _height_ext functions. They are very optimized (thanks to Josh) and so they should work great.
Notice: They are mostly the same as GM ones, but GM's color interpolation and text position is a little different. There are two images to compare at the next page.
Functions:
Code: [Select]
void draw_set_font(int fnt);
void draw_text(int x,int y,string str);
void draw_text_color(int x,int y,string str,int c1,int c2,int c3,int c4,double a);
void draw_text_ext(int x,int y,string str, int sep, int w);
void draw_text_ext_color(int x,int y,string str, int sep,int w,int c1,int c2,int c3,int c4,double a);
void draw_text_transformed(double x,double y,string str,double xscale,double yscale,double rot);
void draw_text_transformed_color(double x,double y,string str,double xscale,double yscale,double rot,int c1,int c2,int c3,int c4,double a);
void draw_text_ext_transformed(double x,double y,string str,int sep,int w, double xscale,double yscale,double rot);
void draw_text_ext_transformed_color(double x,double y,string str,int sep,int w,double xscale,double yscale,double rot,int c1,int c2,int c3,int c4,double a);
unsigned int font_get_texture(int fnt);
int font_add_sprite(int spr, unsigned char first, bool prop, int sep);
unsigned int font_get_texture_width(int fnt);
unsigned int font_get_texture_height(int fnt);
int string_width(string str);
int string_height(string str);
unsigned int string_width_ext(string str, int sep, int w);
unsigned int string_height_ext(string str, int sep, int w);
unsigned int string_width_line(string str, int line);
unsigned int string_width_ext_line(string str, int w, int line);
unsigned int string_width_ext_line_count(string str, int w);
You can download GSFont.h and .cpp in attachment, as well as a little screenshot. It shows draw_text_color and draw_text_ext_transformed_color.
P.s.: It wasn't as easy as I thought at the beginning. Mostly because of the trig for _transform and _ext functions that come with it.
Also, what do you suggest on dealing with the # newline character? The easiest thing would be searching for all # and then checking if / is in front of it, if its not then it is a newline char, if there is a / in front, then just replace /# with # and draw it. But I think there should be some better way, like using regular expressions, but that could end up being a lot slower.?
Also, "prop" argument doesn't work in font_add_sprite. With the font sprite I tried it with it just returns 0x0 size, so it doesn't draw anything. I will look into that if Josh doesn't.
edit: Nevermind about the # question. Enigma will do this automatically, at least Josh said so.
edit2: I added string_width, _height and _ext functions.
52
Issues Help Desk / Can't compile anymore? Whats up with that?
« on: October 24, 2010, 04:50:28 am »
I reinstalled win7 and now I can't compile enigma. I downloaded newest rev from SVN, then installed code::blocks which comes with minGW (it has g++ and make, I checked) and now when I try to compile it shows this http://pastebin.com/GKd7GHB7 . From what I can figure from the bizarre error reporting style is that it tries to compile ideprint.cpp and output it to .eobjs/ideprint.o, but it somehow fails to do it. I am an admin and I do have all permissions for the folder. If I delete .eobjs folder, then he does create it successfully, so it can write just fine. I did this previously like 5 times, about 2 of them in xp. Everything worked fine before. I think I am missing something very primitive, but I dunno what it is. Maybe I need to download minGW separately?
edit: Also, about spaces in text. You should read this: http://www.microsoft.com/typography/developers/fdsspec/spaces.htm .
edit: Also, about spaces in text. You should read this: http://www.microsoft.com/typography/developers/fdsspec/spaces.htm .
53
I was messing round and found that LGM uses both, image alpha AND transparency color. Using both of them in the same time seems redundant and messy. I was going to suggest going the way GM8 did. Remove transparent attribute and everything that is connected to that. So have only alpha support and if someone wants to remove background color, then he just deletes that before importing (or in GM8 case, in the built-in editor). If <GM8 file is imported, then it checks if the transparency color is used, and if so, then just replaces the transparency color with 0 alpha. Its how GM8 does it.
Also, Enigma seem to save images in the exe using RGBA bitmap. So it takes a lot of space, shouldn't some compressed lossless format be used instead? Like .png? And what about Enigmas image file support? sprite_add seem to load only .bmp files. GM8 can load tens of formats as far as I know, and even if some of them are useless, I would love to use some. Like the stated .png. In every project I use external resources and for compression sake they are usually png and in some cases .jpg (where some quality loss is acceptable).
You could use some free C++ image library. Quick search revealed me http://cimg.sourceforge.net/. Although reading about I found it only supports 8 formats natively, and some of them are ASCII files. So I guess it can't be useful. It can be extended with (png's, jpges and lots of others) imagemagik. Some other project might be more useful thou.
Also, I know that LGM sprite functionality is far from finished (or is it?), but I must ask for some additions/changes to be made more prompt than others. For example, you can only select one image in the load dialog. This is something similar to GM, but it also has Add Image and Add from strip buttons, which allows selecting other files too. Because now I can't add an animation which consists of several .png images. I can only add one. The second problem is that I can't paste into new frames. So in GM I usually just pasted image from a graphics program every time I changed it. Like selecting one frame, and then pasting the image and it added the image after the selected frame. Then I deleted the old one and that was it. In LGM you can "Add new frame", but that just adds a white frame to the sprite. You can't modify it in any way (as far as I know).
Also, Enigma seem to save images in the exe using RGBA bitmap. So it takes a lot of space, shouldn't some compressed lossless format be used instead? Like .png? And what about Enigmas image file support? sprite_add seem to load only .bmp files. GM8 can load tens of formats as far as I know, and even if some of them are useless, I would love to use some. Like the stated .png. In every project I use external resources and for compression sake they are usually png and in some cases .jpg (where some quality loss is acceptable).
You could use some free C++ image library. Quick search revealed me http://cimg.sourceforge.net/. Although reading about I found it only supports 8 formats natively, and some of them are ASCII files. So I guess it can't be useful. It can be extended with (png's, jpges and lots of others) imagemagik. Some other project might be more useful thou.
Also, I know that LGM sprite functionality is far from finished (or is it?), but I must ask for some additions/changes to be made more prompt than others. For example, you can only select one image in the load dialog. This is something similar to GM, but it also has Add Image and Add from strip buttons, which allows selecting other files too. Because now I can't add an animation which consists of several .png images. I can only add one. The second problem is that I can't paste into new frames. So in GM I usually just pasted image from a graphics program every time I changed it. Like selecting one frame, and then pasting the image and it added the image after the selected frame. Then I deleted the old one and that was it. In LGM you can "Add new frame", but that just adds a white frame to the sprite. You can't modify it in any way (as far as I know).
54
Function Peer Review / GML: draw_sprite_general
« on: September 28, 2010, 01:36:00 pm »
Description:This function was already present in Enigma, but it was just copied draw_sprite_part code, and so didn't feature scale or rotation. This function does, so every argument is used. This function also has 3 more arguments then the original, so its possible to change alpha for every corner, not only color. I don't know if this is needed (for example, for compatibility with GM), and so if dev's think it doesn't suit it, then they can remove those arguments.
Function:
draw_sprite_general(int spr,int subimg,double left,double top,double width,double height,double x,double y,double xscale,double yscale,double rot,int c1,int c2,int c3,int c4,double a1, double a2, double a3, double a4)
Code:
Function:
draw_sprite_general(int spr,int subimg,double left,double top,double width,double height,double x,double y,double xscale,double yscale,double rot,int c1,int c2,int c3,int c4,double a1, double a2, double a3, double a4)
Code:
Code: [Select]
int draw_sprite_general(int spr,int subimg,double left,double top,double width,double height,double x,double y,double xscale,double yscale,double rot,int c1,int c2,int c3,int c4,double a1, double a2, double a3, double a4)
{
enigma::sprite *spr2d=enigma::spritestructarray[spr];
if (!spr2d)
return -1;
glPushAttrib(GL_CURRENT_BIT);
if (enigma::cur_bou_tha_noo_sho_eve_cha_eve != spr2d->texturearray[subimg % spr2d->subcount])
{
glBindTexture(GL_TEXTURE_2D,spr2d->texturearray[subimg % spr2d->subcount]);
enigma::cur_bou_tha_noo_sho_eve_cha_eve=spr2d->texturearray[subimg % spr2d->subcount];
}
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
const float tbx=spr2d->texbordx,tby=spr2d->texbordy,
w=width*xscale, h=height*yscale,
tbw=spr2d->width/tbx,tbh=spr2d->height/tby;
rot *= M_PI/180;
float ulcx = x + xscale * cos(M_PI+rot) + yscale * cos(M_PI/2+rot),
ulcy = y - yscale * sin(M_PI+rot) - yscale * sin(M_PI/2+rot);
glBegin(GL_QUADS);
glColor4ub(__GETR(c1),__GETG(c1),__GETB(c1),char(a1*255));
glTexCoord2f(left/tbw,top/tbh);
glVertex2f(ulcx,ulcy);
glColor4ub(__GETR(c2),__GETG(c2),__GETB(c2),char(a2*255));
glTexCoord2f((left+width)/tbw,top/tbh);
glVertex2f((ulcx + w*cos(rot)), (ulcy - w*sin(rot)));
ulcx += h * cos(3*M_PI/2 + rot);
ulcy -= h * sin(3*M_PI/2 + rot);
glColor4ub(__GETR(c3),__GETG(c3),__GETB(c3),char(a3*255));
glTexCoord2f((left+width)/tbw,(top+height)/tbh);
glVertex2f((ulcx + w*cos(rot)), (ulcy - w*sin(rot)));
glColor4ub(__GETR(c4),__GETG(c4),__GETB(c4),char(a4*255));
glTexCoord2f(left/tbw,(top+height)/tbh);
glVertex2f(ulcx,ulcy);
glEnd();
glPopAttrib();
return 0;
}
55
Function Peer Review / GML: All draw_background functions + 2 custom ones
« on: September 28, 2010, 12:05:55 pm »
Description: These are all draw_background functions in GM. They are exactly the same except draw_background_general, which has 3 more arguments. It allows not only color for each individual corner, but also alpha. There are also 2 custom functions. draw_background_tiled_area and draw_background_tiled_area_ext which tiles background over a specific region.
Functions:
draw_background(int back, double x, double y);
draw_background_stretched(int back, double x, double y, double w, double h);
draw_background_tiled(int back,double x,double y);
draw_background_tiled_area(int back,double x,double y,double x1,double y1,double x2,double y2);
draw_background_part(int back,double left,double top,double width,double height,double x,double y);
draw_background_ext(int back,double x,double y,double xscale,double yscale,double rot,int color,double alpha);
draw_background_stretched_ext(int back,double x,double y,double w,double h,int color,double alpha);
draw_background_tiled_ext(int back,double x,double y,double xscale,double yscale,int color,double alpha);
draw_background_tiled_area_ext(int back,double x,double y,double x1,double y1,double x2,double y2, double xscale, double yscale, int color, double alpha);
draw_background_part_ext(int back,double left,double top,double width,double height,double x,double y,double xscale,double yscale,int color,double alpha);
draw_background_general(int back,double left,double top,double width,double height,double x,double y,double xscale,double yscale,double rot,int c1,int c2,int c3,int c4,double a1,double a2,double a3,double a4);
As the code itself would be too long to post here, I just added GSbackground.h and GSbackground.cpp as attachments.
Note, there is a bug in that sprite functions will draw a background after one of these functions are called. I already posted a ticket, and when TGMG or Josh fixes that then I guess these functions will need a little upgrading. Also, while working on these functions I noticed that some of the sprite functions are incomplete too. Like draw_sprite_general doesn't use rotation argument. I will maybe change that too.
edit: "Bug" was solved. Redownload attachments.
Functions:
draw_background(int back, double x, double y);
draw_background_stretched(int back, double x, double y, double w, double h);
draw_background_tiled(int back,double x,double y);
draw_background_tiled_area(int back,double x,double y,double x1,double y1,double x2,double y2);
draw_background_part(int back,double left,double top,double width,double height,double x,double y);
draw_background_ext(int back,double x,double y,double xscale,double yscale,double rot,int color,double alpha);
draw_background_stretched_ext(int back,double x,double y,double w,double h,int color,double alpha);
draw_background_tiled_ext(int back,double x,double y,double xscale,double yscale,int color,double alpha);
draw_background_tiled_area_ext(int back,double x,double y,double x1,double y1,double x2,double y2, double xscale, double yscale, int color, double alpha);
draw_background_part_ext(int back,double left,double top,double width,double height,double x,double y,double xscale,double yscale,int color,double alpha);
draw_background_general(int back,double left,double top,double width,double height,double x,double y,double xscale,double yscale,double rot,int c1,int c2,int c3,int c4,double a1,double a2,double a3,double a4);
As the code itself would be too long to post here, I just added GSbackground.h and GSbackground.cpp as attachments.
Note, there is a bug in that sprite functions will draw a background after one of these functions are called. I already posted a ticket, and when TGMG or Josh fixes that then I guess these functions will need a little upgrading. Also, while working on these functions I noticed that some of the sprite functions are incomplete too. Like draw_sprite_general doesn't use rotation argument. I will maybe change that too.
edit: "Bug" was solved. Redownload attachments.
56
Function Peer Review / GML: draw_sprite_tiled_area + draw_sprite_tiled_area_ext (Custom, not in GM)
« on: September 25, 2010, 12:58:45 pm »
Notice: These functions are not in GM. They are just additional functions that could be useful to add. What they do is that they tile a sprite over selected region (which is a rectangle with x1,y1 top left corner and x2,y2 bottom left). It automatically crops the image as needed and it works with any size sprite. They are based on GMLScripts script http://www.gmlscripts.com/script/draw_sprite_tiled_area by EyeGuy.
Function: draw_sprite_tiled_area(int spr,int subimg,double x,double y,double x1,double y1,double x2,double y2);
GSsprite.h:
GSsprite.cpp:
Function: draw_sprite_tiled_area_ext(int spr,int subimg,double x,double y,double x1,double y1,double x2,double y2, double xscale, double yscale, int color, double alpha);
GSsprite.h:
GSsprite.cpp:
Added attachments show:
First image: draw_sprite_tiled_area(sprite0,0,0,0,75,75,375,375);
Second image: draw_sprite_tiled_area_ext(sprite0,0,0,0,75,75,375,375,0.5,0.5,c_yellow,0.7);
You can see some artifacts when scaled down, but I guess it is normal.
Function: draw_sprite_tiled_area(int spr,int subimg,double x,double y,double x1,double y1,double x2,double y2);
GSsprite.h:
Code: [Select]
int draw_sprite_tiled_area(int spr,int subimg,double x,double y,double x1,double y1,double x2,double y2);
GSsprite.cpp:
Code: [Select]
int draw_sprite_tiled_area(int spr,int subimg,double x,double y,double x1,double y1,double x2,double y2)
{
enigma::sprite *spr2d = enigma::spritestructarray[spr];
if (!spr2d)
return -1;
if (enigma::cur_bou_tha_noo_sho_eve_cha_eve != spr2d->texturearray[subimg % spr2d->subcount])
{
glBindTexture(GL_TEXTURE_2D,spr2d->texturearray[subimg % spr2d->subcount]);
enigma::cur_bou_tha_noo_sho_eve_cha_eve = spr2d->texturearray[subimg % spr2d->subcount];
}
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
glPushAttrib(GL_CURRENT_BIT);
glColor4f(1,1,1,1);
const float tbx=spr2d->texbordx,tby=spr2d->texbordy;
float sw,sh,i,j,jj,left,top,width,height,X,Y;
sw = spr2d->width;
sh = spr2d->height;
i = x1-(fmod(x1,sw) - fmod(x,sw)) - sw*(fmod(x1,sw)<fmod(x,sw));
j = y1-(fmod(y1,sh) - fmod(y,sh)) - sh*(fmod(y1,sh)<fmod(y,sh));
jj = j;
glBegin(GL_QUADS);
for(i=i; i<=x2; i+=sw) {
for(j=j; j<=y2; j+=sh) {
if(i <= x1) left = x1-i;
else left = 0;
X = i+left;
if(j <= y1) top = y1-j;
else top = 0;
Y = j+top;
if(x2 <= i+sw) width = ((sw)-(i+sw-x2)+1)-left;
else width = sw-left;
if(y2 <= j+sh) height = ((sh)-(j+sh-y2)+1)-top;
else height = sh-top;
glTexCoord2f(left/sw*tbx,top/sh*tby);
glVertex2f(X,Y);
glTexCoord2f((left+width)/sw*tbx,top/sh*tby);
glVertex2f(X+width,Y);
glTexCoord2f((left+width)/sw*tbx,(top+height)/sh*tby);
glVertex2f(X+width,Y+height);
glTexCoord2f(left/sw*tbx,(top+height)/sh*tby);
glVertex2f(X,Y+height);
}
j = jj;
}
glEnd();
glPopAttrib();
return 0;
}
Function: draw_sprite_tiled_area_ext(int spr,int subimg,double x,double y,double x1,double y1,double x2,double y2, double xscale, double yscale, int color, double alpha);
GSsprite.h:
Code: [Select]
int draw_sprite_tiled_area_ext(int spr,int subimg,double x,double y,double x1,double y1,double x2,double y2, double xscale, double yscale, int color, double alpha);
GSsprite.cpp:
Code: [Select]
int draw_sprite_tiled_area_ext(int spr,int subimg,double x,double y,double x1,double y1,double x2,double y2, double xscale, double yscale, int color, double alpha)
{
enigma::sprite *spr2d = enigma::spritestructarray[spr];
if (!spr2d)
return -1;
if (enigma::cur_bou_tha_noo_sho_eve_cha_eve != spr2d->texturearray[subimg % spr2d->subcount])
{
glBindTexture(GL_TEXTURE_2D,spr2d->texturearray[subimg % spr2d->subcount]);
enigma::cur_bou_tha_noo_sho_eve_cha_eve = spr2d->texturearray[subimg % spr2d->subcount];
}
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
glPushAttrib(GL_CURRENT_BIT);
glColor4ub(__GETR(color),__GETG(color),__GETB(color),char(alpha*255));
const float tbx=spr2d->texbordx,tby=spr2d->texbordy;
float sw,sh,i,j,jj,left,top,width,height,X,Y;
sw = spr2d->width*xscale;
sh = spr2d->height*yscale;
i = x1-(fmod(x1,sw) - fmod(x,sw)) - sw*(fmod(x1,sw)<fmod(x,sw));
j = y1-(fmod(y1,sh) - fmod(y,sh)) - sh*(fmod(y1,sh)<fmod(y,sh));
jj = j;
glBegin(GL_QUADS);
for(i=i; i<=x2; i+=sw) {
for(j=j; j<=y2; j+=sh) {
if(i <= x1) left = x1-i;
else left = 0;
X = i+left;
if(j <= y1) top = y1-j;
else top = 0;
Y = j+top;
if(x2 <= i+sw) width = ((sw)-(i+sw-x2)+1)-left;
else width = sw-left;
if(y2 <= j+sh) height = ((sh)-(j+sh-y2)+1)-top;
else height = sh-top;
glTexCoord2f(left/sw*tbx,top/sh*tby);
glVertex2f(X,Y);
glTexCoord2f((left+width)/sw*tbx,top/sh*tby);
glVertex2f(X+width,Y);
glTexCoord2f((left+width)/sw*tbx,(top+height)/sh*tby);
glVertex2f(X+width,Y+height);
glTexCoord2f(left/sw*tbx,(top+height)/sh*tby);
glVertex2f(X,Y+height);
}
j = jj;
}
glEnd();
glPopAttrib();
return 0;
}
Added attachments show:
First image: draw_sprite_tiled_area(sprite0,0,0,0,75,75,375,375);
Second image: draw_sprite_tiled_area_ext(sprite0,0,0,0,75,75,375,375,0.5,0.5,c_yellow,0.7);
You can see some artifacts when scaled down, but I guess it is normal.
57
Function Peer Review / GML: draw_sprite_tiled + draw_sprite_tiled_ext
« on: September 25, 2010, 11:05:31 am »
Notice: These functions work with any sprite size, but the functionality in _ext differs from GM one. The difference is with scaling. x and y arguments, according to manual, is "(x,y) is the place where one of the sprites is drawn". In GM these arguments are modified with scaling, so, for example, when you have a 100x100 sprite, you tile it with 0.5 scale, and put 25 in x and y position, then you won't have a sprite drawn in 25,25 as manual suggests, but you will have one drawn at 12.5,12.5. In this code this it will be drawn in 25,25. This can be changed with two parenthesis, but I think this is how the function needed to work in the first place.
Function: draw_sprite_tiled(int spr,int subimg,double x,double y);
GSsprite.h:
GSsprite.cpp:
Function:draw_sprite_tiled_ext(int spr,int subimg,double x,double y,double xscale,double yscale,int color,double alpha);
GSsprite.h:
GSsprite.cpp:
In attachments you can see two images.
First one is: draw_sprite_tiled(spr_0,0,50,50);
Other one is: draw_sprite_tiled_ext(spr_0,0,25,25,0.5,0.5,c_yellow,0.5);
Function: draw_sprite_tiled(int spr,int subimg,double x,double y);
GSsprite.h:
Code: [Select]
int draw_sprite_tiled(int spr,int subimg,double x,double y);
GSsprite.cpp:
Code: [Select]
int draw_sprite_tiled(int spr,int subimg,double x,double y)
{
enigma::sprite *spr2d = enigma::spritestructarray[spr];
if (!spr2d)
return -1;
if (enigma::cur_bou_tha_noo_sho_eve_cha_eve != spr2d->texturearray[subimg % spr2d->subcount])
{
glBindTexture(GL_TEXTURE_2D,spr2d->texturearray[subimg % spr2d->subcount]);
enigma::cur_bou_tha_noo_sho_eve_cha_eve = spr2d->texturearray[subimg % spr2d->subcount];
}
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
glPushAttrib(GL_CURRENT_BIT);
glColor4f(1,1,1,1);
const float tbx=spr2d->texbordx,tby=spr2d->texbordy,
xoff=spr2d->xoffset+x,
yoff=spr2d->yoffset+y;
const int hortil= int (ceil(room_width/(spr2d->width*tbx))),
vertil= int (ceil(room_height/(spr2d->height*tby)));
glBegin(GL_QUADS);
for (int i=0; i<hortil; i++){
for (int c=0; c<vertil; c++){
glTexCoord2f(0,0);
glVertex2f(i*spr2d->width-xoff,c*spr2d->height-yoff);
glTexCoord2f(tbx,0);
glVertex2f((i+1)*spr2d->width-xoff,c*spr2d->height-yoff);
glTexCoord2f(tbx,tby);
glVertex2f((i+1)*spr2d->width-xoff,(c+1)*spr2d->height-yoff);
glTexCoord2f(0,tby);
glVertex2f(i*spr2d->width-xoff,(c+1)*spr2d->height-yoff);
}
}
glEnd();
glPopAttrib();
return 0;
}
Function:draw_sprite_tiled_ext(int spr,int subimg,double x,double y,double xscale,double yscale,int color,double alpha);
GSsprite.h:
Code: [Select]
int draw_sprite_tiled_ext(int spr,int subimg,double x,double y,double xscale,double yscale,int color,double alpha);
GSsprite.cpp:
Code: [Select]
int draw_sprite_tiled_ext(int spr,int subimg,double x,double y, double xscale,double yscale,int color,double alpha)
{
enigma::sprite *spr2d = enigma::spritestructarray[spr];
if (!spr2d)
return -1;
if (enigma::cur_bou_tha_noo_sho_eve_cha_eve != spr2d->texturearray[subimg % spr2d->subcount])
{
glBindTexture(GL_TEXTURE_2D,spr2d->texturearray[subimg % spr2d->subcount]);
enigma::cur_bou_tha_noo_sho_eve_cha_eve = spr2d->texturearray[subimg % spr2d->subcount];
}
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
glPushAttrib(GL_CURRENT_BIT);
glColor4ub(__GETR(color),__GETG(color),__GETB(color),char(alpha*255));
const float tbx=spr2d->texbordx,tby=spr2d->texbordy,
xoff=spr2d->xoffset*xscale+x,
yoff=spr2d->yoffset*yscale+y;
const int hortil= int (ceil(room_width/(spr2d->width*tbx*xscale))),
vertil= int (ceil(room_height/(spr2d->height*tby*yscale)));
glBegin(GL_QUADS);
for (int i=0; i<hortil; i++){
for (int c=0; c<vertil; c++){
glTexCoord2f(0,0);
glVertex2f(i*spr2d->width*xscale-xoff,c*spr2d->height*yscale-yoff);
glTexCoord2f(tbx,0);
glVertex2f((i+1)*spr2d->width*xscale-xoff,c*spr2d->height*yscale-yoff);
glTexCoord2f(tbx,tby);
glVertex2f((i+1)*spr2d->width*xscale-xoff,(c+1)*spr2d->height*yscale-yoff);
glTexCoord2f(0,tby);
glVertex2f(i*spr2d->width*xscale-xoff,(c+1)*spr2d->height*yscale-yoff);
}
}
glEnd();
glPopAttrib();
return 0;
}
In attachments you can see two images.
First one is: draw_sprite_tiled(spr_0,0,50,50);
Other one is: draw_sprite_tiled_ext(spr_0,0,25,25,0.5,0.5,c_yellow,0.5);
58
Function Peer Review / GML: draw_sprite_tiled + draw_sprite_tiled_ext (works only with power of two)
« on: September 10, 2010, 05:59:44 am »
Notice: These functions work only with power of two textures (sprites), so this implementation is kind of limited. Also, it will only draw a tiled region with width/height the length of min(room_width,room_height). This is OpenGL limitation. Still, this could be used for something, and I think tiling power of two images this way is much faster than the other way (http://enigma-dev.org/forums/index.php?topic=641.0), but that way doesn't have any limitations.
Function: draw_sprite_tiled(int spr,int subimg,double x,double y);
GSsprite.h:
GSsprite.cpp:
Function:draw_sprite_tiled_ext(int spr,int subimg,double x,double y,double xscale,double yscale,int color,double alpha);
GSsprite.h:
GSsprite.cpp:
TO-DO:
1) Make both functions work in views (now they use room size)
2) Tile the tiled images. Now it draws as a square which has side as min(room_width, room_height). Maybe someone more profound in C++ could help with this.
Function: draw_sprite_tiled(int spr,int subimg,double x,double y);
GSsprite.h:
Code: [Select]
int draw_sprite_tiled(int spr,int subimg,double x,double y);
GSsprite.cpp:
Code: [Select]
int draw_sprite_tiled(int spr,int subimg,double x,double y)
{
enigma::sprite *spr2d = enigma::spritestructarray[spr];
if (!spr2d)
return -1;
if (enigma::cur_bou_tha_noo_sho_eve_cha_eve != spr2d->texturearray[subimg % spr2d->subcount])
{
glBindTexture(GL_TEXTURE_2D,spr2d->texturearray[subimg % spr2d->subcount]);
enigma::cur_bou_tha_noo_sho_eve_cha_eve = spr2d->texturearray[subimg % spr2d->subcount];
}
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
glPushAttrib(GL_CURRENT_BIT);
glColor4f(1,1,1,1);
const float tbx=spr2d->texbordx,tby=spr2d->texbordy,
vertil=room_width/spr2d->width,
hortil=room_height/spr2d->height,
xoff=spr2d->xoffset/spr2d->width+x/spr2d->width,
yoff=spr2d->yoffset/spr2d->height+y/spr2d->height;
glBegin(GL_QUADS);
glTexCoord2f(xoff,yoff);
glVertex2f(0,0);
glTexCoord2f(hortil*tbx+xoff,yoff);
glVertex2f(spr2d->width*hortil,0);
glTexCoord2f(hortil*tbx+xoff,vertil*tby+yoff);
glVertex2f(spr2d->width*hortil,spr2d->height*vertil);
glTexCoord2f(xoff,vertil*tby+yoff);
glVertex2f(0,spr2d->height*vertil);
glEnd();
glPopAttrib();
return 0;
}
Function:draw_sprite_tiled_ext(int spr,int subimg,double x,double y,double xscale,double yscale,int color,double alpha);
GSsprite.h:
Code: [Select]
int draw_sprite_tiled_ext(int spr,int subimg,double x,double y,double xscale,double yscale,int color,double alpha);
GSsprite.cpp:
Code: [Select]
int draw_sprite_tiled_ext(int spr,int subimg,double x,double y,double xscale,double yscale,int blend,double alpha)
{
enigma::sprite *spr2d = enigma::spritestructarray[spr];
if (!spr2d)
return -1;
if (enigma::cur_bou_tha_noo_sho_eve_cha_eve != spr2d->texturearray[subimg % spr2d->subcount])
{
glBindTexture(GL_TEXTURE_2D,spr2d->texturearray[subimg % spr2d->subcount]);
enigma::cur_bou_tha_noo_sho_eve_cha_eve = spr2d->texturearray[subimg % spr2d->subcount];
}
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
glPushAttrib(GL_CURRENT_BIT);
//glColor4f(1,1,1,1);
glColor4ub(__GETR(blend),__GETG(blend),__GETB(blend),char(alpha*255));
const float tbx=spr2d->texbordx,tby=spr2d->texbordy,
vertil=room_width/(spr2d->width*xscale),
hortil=room_height/(spr2d->height*yscale),
xoff=spr2d->xoffset/(spr2d->width*xscale)+x/(spr2d->width*xscale),
yoff=spr2d->yoffset/(spr2d->height*yscale)+y/(spr2d->height*yscale);
glBegin(GL_QUADS);
glTexCoord2f(xoff,yoff);
glVertex2f(0,0);
glTexCoord2f(hortil*tbx+xoff,yoff);
glVertex2f(spr2d->width*xscale*hortil,0);
glTexCoord2f(hortil*tbx+xoff,vertil*tby+yoff);
glVertex2f(spr2d->width*xscale*hortil,spr2d->height*yscale*vertil);
glTexCoord2f(xoff,vertil*tby+yoff);
glVertex2f(0,spr2d->height*yscale*vertil);
glEnd();
glPopAttrib();
return 0;
}
TO-DO:
1) Make both functions work in views (now they use room size)
2) Tile the tiled images. Now it draws as a square which has side as min(room_width, room_height). Maybe someone more profound in C++ could help with this.
59
Function Peer Review / GML: draw_sprite_stretched_ext
« on: September 09, 2010, 02:11:31 pm »
If I understand the point of this section correctly, then we can add function code here? If so, then I will start by implementing simple, but missing additions.
edit: Removed unneeded glColor4f function.
Function: draw_sprite_stretched_ext(int sprite,int subimg,double x,double y,double w,double h,int color,double alpha)
GSSprite.h:
GSSprite.cpp:
If this is how should these topics look like, then I will do others too.
edit: Removed unneeded glColor4f function.
Function: draw_sprite_stretched_ext(int sprite,int subimg,double x,double y,double w,double h,int color,double alpha)
GSSprite.h:
Code: [Select]
int draw_sprite_stretched_ext(int sprite,int subimg,double x,double y,double w,double h,int color,double alpha);
GSSprite.cpp:
Code: [Select]
int draw_sprite_stretched_ext(int spr,int subimg,double x,double y,double w,double h, int blend, double alpha)
{
enigma::sprite *spr2d=enigma::spritestructarray[spr];
if (!spr2d)
return -1;
glPushAttrib(GL_CURRENT_BIT);
if (enigma::cur_bou_tha_noo_sho_eve_cha_eve!=spr2d->texturearray[subimg % spr2d->subcount])
{
glBindTexture(GL_TEXTURE_2D,spr2d->texturearray[subimg % spr2d->subcount]);
enigma::cur_bou_tha_noo_sho_eve_cha_eve=spr2d->texturearray[subimg % spr2d->subcount];
}
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
glBegin(GL_QUADS);
glColor4ub(__GETR(blend),__GETG(blend),__GETB(blend),char(alpha*255)); //Implement "blend" parameter
glTexCoord2f(spr2d->texbordx,0);
glVertex2f(x-spr2d->xoffset,y-spr2d->yoffset);
glTexCoord2f(0,0);
glVertex2f(x+w-spr2d->xoffset,y-spr2d->yoffset);
glTexCoord2f(0,spr2d->texbordy);
glVertex2f(x+w-spr2d->xoffset,y+h-spr2d->yoffset);
glTexCoord2f(spr2d->texbordx,spr2d->texbordy);
glVertex2f(x-spr2d->xoffset,y+h-spr2d->yoffset);
glEnd();
glPopAttrib();
return 0;
}
If this is how should these topics look like, then I will do others too.
60
General ENIGMA / Help File?
« on: August 22, 2010, 10:30:48 am »
So.. anyway. I though on how I could help and manual came to mind. I wanted to know how exactly will help work? At one point you made some online page, but I don't really think that online manual is the best idea. I for one, think that GM style help works the best. You can search really fast in it, and information about every functions is present. There was also some information thing in the function progress page, but it seems that it has been removed. As far as GM's functions are concerned, we could just take the information from the GM's manual (shamelessly copy and paste) and it would cover most of the manual.
edit: Also, I think the priority still should be not adding new functions, but just replicating the GM ones. So when you could open a GM game, press run, and just create a 5x smaller and 5x faster game than GM that would be the greatest thing. And would be a great insult to YYG too. Then we could become prophets, and go around GMC and tell about free new age of game development.
edit: Also, I think the priority still should be not adding new functions, but just replicating the GM ones. So when you could open a GM game, press run, and just create a 5x smaller and 5x faster game than GM that would be the greatest thing. And would be a great insult to YYG too. Then we could become prophets, and go around GMC and tell about free new age of game development.