LOL, model class and effect class to draw a rectangle.
Obviously it's a bit overkill for something like a rectangle, but it just shows that it works. I'm probably going to do something different for rectangles and circles and stuff.
[QUOTE=DarKSunrise;39228140]Obviously it's a bit overkill for something like a rectangle, but it just shows that it works. I'm probably going to do something different for rectangles and circles and stuff.[/QUOTE]
Instead of creating an array of vertices an indices for each rectangle, change it to a vec4 uniform (xy - position, zw - size) to scale simple 0.0-1.0 attribute quad by in the vertex shader.
An example from WebQuake:
[code]
Draw.Pic = function(x, y, pic)
{
var program = GL.UseProgram('Pic'); // selecting the shader
GL.Bind(program.tTexture, pic.texnum); // setting texture
gl.bindBuffer(gl.ARRAY_BUFFER, GL.rect); // GL.rect is a strip of 2 triangles from (0;0) to (1;1)
gl.vertexAttribPointer(program.aPoint, 2, gl.FLOAT, false, 0, 0);
gl.uniform4f(program.uRect, x, y, pic.width, pic.height); // setting position and size
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); // drawing the quad (4 verts in the strip)
};
[/code]
[QUOTE=Swebonny;39221659]--Finding error in code--
--Heaven-
--Sex--
--Hell--
--CTRL+Z too much--[/QUOTE]
[img]http://files.xiatek.org/ctrls.gif[/img]
[QUOTE=SiPlus;39228170]Instead of creating an array of vertices an indices for each rectangle, change it to a vec4 uniform (xy - position, zw - size) to scale simple 0.0-1.0 attribute quad by in the vertex shader.
An example from WebQuake:
[code]
Draw.Pic = function(x, y, pic)
{
var program = GL.UseProgram('Pic'); // selecting the shader
GL.Bind(program.tTexture, pic.texnum); // setting texture
gl.bindBuffer(gl.ARRAY_BUFFER, GL.rect); // GL.rect is a strip of 2 triangles from (0;0) to (1;1)
gl.vertexAttribPointer(program.aPoint, 2, gl.FLOAT, false, 0, 0);
gl.uniform4f(program.uRect, x, y, pic.width, pic.height); // setting position and size
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); // drawing the quad (4 verts in the strip)
};
[/code][/QUOTE]
I'm probably going to do something like that yeah, but like I said, I only whipped that up for testing if the model class works. The model class is only supposed to be used by actual models and meshes and shit.
[QUOTE=SiPlus;39228120]LOL, model class and effect class to draw a rectangle.[/QUOTE]
That's like saying "LOL, raw OpenGL to draw a rectangle".
What's wrong with you?
[QUOTE=Darwin226;39228816]That's like saying "LOL, raw OpenGL to draw a rectangle".
What's wrong with you?[/QUOTE]
[quote]SiPlus posted:[/quote]
[QUOTE=Darwin226;39228816]That's like saying "LOL, raw OpenGL to draw a rectangle".
What's wrong with you?[/QUOTE]
But using a library and 2 big classes just to fill a rectangle is... overoveroveroverengineering.
I wouldn't use OpenGL too, but there's 3D alongside 2D, 2D canvas is slow, and images are unmanageable.
[QUOTE=SiPlus;39228940]But using a library and 2 big classes just to fill a rectangle is... overoveroveroverengineering.
I wouldn't use OpenGL too, but there's 3D alongside 2D, 2D canvas is slow, and images are unmanageable.[/QUOTE]
Have you even for a second considered that the rectangle wasn't the FINAL GOAL OF HIS PROJECT?
[QUOTE=Darwin226;39229006]Have you even for a second considered that the rectangle wasn't the FINAL GOAL OF HIS PROJECT?[/QUOTE]
I know that, he explained later, you didn't have to write what I replied to.
[QUOTE=SiPlus;39228940]But using a library and 2 big classes just to fill a rectangle is... overoveroveroverengineering.
I wouldn't use OpenGL too, but there's 3D alongside 2D, 2D canvas is slow, and images are unmanageable.[/QUOTE]
In my programs, each vertex has it owns namespace and class.
[QUOTE=SiPlus;39228940]But using a library and 2 big classes just to fill a rectangle is... overoveroveroverengineering.
I wouldn't use OpenGL too, but there's 3D alongside 2D, 2D canvas is slow, and images are unmanageable.[/QUOTE]
It's all about abstraction, baby.
By building really simple low-level structures with clearly defined objectives like these and then building upon those, you avoid (to a larger degree at least) having to go back later and rewriting a bunch of code when he wants to implement something like a circle, because all his code is designed around drawing squares.
[QUOTE=SiPlus;39228940]But using a library and 2 big classes just to fill a rectangle is... overoveroveroverengineering.
I wouldn't use OpenGL too, but there's 3D alongside 2D, 2D canvas is slow, and images are unmanageable.[/QUOTE]
You don't need images if you're just drawing a green rectangle on a blue background.
[QUOTE=ArgvCompany;39229073]You don't need images if you're just drawing a green rectangle on a blue background.[/QUOTE]
I meant textured rectangles. For filled rectangles, that would be div with background color. But I chose OpenGL because canvas is slow, divs are dumb, and speed of drawing UI elements is consistent rather than screen-size-dependent.
[editline]15th January 2013[/editline]
[QUOTE=Dr Magnusson;39229047]It's all about abstraction, baby.[/QUOTE]
Draw.Pic is part of graphics abstraction layer in my code. I draw images by calling
[code]Draw.Pic(x, y, somesubsystem.somepic);[/code]
and somewhere in subsystem init code:
[code]somesubsystem.somepic = Draw.CachePic('somepicname');
// or
somesubsystem.somepic = Draw.PicFromWad('somepicname');
[/code]
Is there a site/tool that lets me input raw C++ code and generate bb tagged code that "simulates" syntax highlighting? Kind of from
[quote]
std::cout << "string";
[/quote]
to
[quote]
[b]
[color=green]std[/color]::[color=red]cout[/color] << [color=blue]"string"[/color];
[/b]
[/quote]
[QUOTE=WhatTheEf;39229281]Is there a site/tool that lets me input raw C++ code and generate bb tagged code that "simulates" syntax highlighting?[/QUOTE]
There's [url=http://tohtml.com/]this[/url], but it gives you HTML instead of BBCode.
[QUOTE=WhatTheEf;39229281]Is there a site/tool that lets me input raw C++ code and generate bb tagged code that "simulates" syntax highlighting?[/QUOTE]
[URL]http://dumpz.org[/URL]
Press "HTML for blog" when you make a paste, there will be BBCode along with HTML.
You can delete pastes if you're registered.
[QUOTE=SiPlus;39229370][URL]http://dumpz.org[/URL]
Press "HTML for blog" when you make a paste, there will be BBCode along with HTML.
You can delete pastes if you're registered.[/QUOTE]
I can't believe my eyes — you actually posted something useful!
What do you guys think of livestreaming a programming session again, did it like a year of year and a half ago once on this forum and it was pretty fun. I'd let you guys pick a theme and while I am coding it you guys just give input / say what you want in it.
I want to make a Heroes of Newerth themed Monopoly game. Here is my board so far. Now for the coding..
[img]https://dl.dropbox.com/u/15793967/honopoly.png[/img]
Don't you love it when:
$ git commit -a
26 files changed, 3686 insertions(+), 49 deletions(-)
And everything works exactly the same as it did before your changes.
(Though inputs are now not just things that listen for the system events, they now have a manager that pushes the events to them and runs a forced update 33 times per second in case an event slips past the message pump due to focus changes. And they can have both a primary and secondary bind as well, all of which can be serialized and deserialized to/from a JSON file)
[QUOTE=no-named;39230537]I want to make a Heroes of Newerth themed Monopoly game. Here is my board so far. Now for the coding..
[img]https://dl.dropbox.com/u/15793967/honopoly.png[/img][/QUOTE]
I was about to say that 3/4 of your tiles are the wrong way up, before I remembered that this is a programming thread, and that is a computer game.
Well, back to revision for me I suppose :v:
I'm working on a way of resolving collisions where you can slow down time and actually see the projectile slow down as it penetrates the target. It basically doesn't solve the collision on detection of a collision, it plots a graph of the forces that will act on it until it all balances out, and bases the frames on the graphs. You can see how the faster arrows penetrate deeper.
Sorry I couldn't slow it down, I haven't been able to add dynamic time yet and I'm a bad programmer.
[media]http://www.youtube.com/watch?v=V_itZcWVjeU[/media]
Rate winner for bong music?
Spent the last day and half of my free time working on hacking a way to get a higher than 32px version of the Steam user avatar in my source mod.
On loading, it downloads the 184px version of the client's avatar (from my server with a simple php script), store it as jpeg, load it and save it back in tga. Then I load it back again (probably gonna make that in one go after) to get the RGBA.
There I simply draw it on the game menu.
[img]http://uppix.net/f/b/1/6c4fe58d952f4fbf69f343a5e8a1b.jpg[/img]
Excuse the small resolution, I'm testing on my 13" laptop windowed, so it's kinda the best resolution I can run it.
There is still a bug I've yet to delve into, as you can see.
Learning shaders, they are quite fun to work with!
[img]http://puu.sh/1ObML[/img]
[QUOTE=OrYgin;39232992]Spent the last day and half of my free time working on hacking a way to get a higher than 32px version of the Steam user avatar in my source mod.
On loading, it downloads the 184px version of the client's avatar (from my server with a simple php script), store it as jpeg, load it and save it back in tga. Then I load it back again (probably gonna make that in one go after) to get the RGBA.
There I simply draw it on the game menu.
[IMG]http://uppix.net/f/b/1/6c4fe58d952f4fbf69f343a5e8a1b.jpg[/IMG]
Excuse the small resolution, I'm testing on my 13" laptop windowed, so it's kinda the best resolution I can run it.
There is still a bug I've yet to delve into, as you can see.[/QUOTE]
wot m8.
I'm not really sure what's happening in that image.
[QUOTE=OrYgin;39232992]On loading, it downloads the 184px version of the client's avatar ... store it as jpeg, load it and save it back in tga. Then I load it back again ...[/QUOTE]
Why would you...
[QUOTE=ECrownofFire;39233131]Why would you...[/QUOTE]
Mainly because I'm using valve's code, and it save the file directly.
Tomorrow I'll make it do it in one go, and also try to fix the color bug.
[QUOTE=OrYgin;39232992]
On loading, it downloads the 184px version of the client's avatar (from my server with a simple php script), store it as jpeg, load it and save it back in tga. Then I load it back again (probably gonna make that in one go after) to get the RGBA.[/QUOTE]
Talk about convoluted. If you used the ASW engine, you could at least get the 64x64 version without jumping through hoops.
I'm still on the Orangebox engine (and I really don't plan on moving) and there is no other size than 32px available via steamapi.
Sorry, you need to Log In to post a reply to this thread.