[QUOTE=Clavus;27953590]Well, same here, I don't care much about formalities either. But knowing something about the history of the field you're working in can't do any harm, right? People who won the Turing award shaped computer science as we know it. I personally find it pretty interesting to see who's shoulders I'm standing on.[/QUOTE]
Yet neither Bjarne Stroustrup nor Linus Torvalds have received it
[QUOTE=Jookia]hi let me post nothing but a made up PM made evident by the complete lack of soda's sharp wit and hugfe cock[/QUOTE]
^^pm i got from jookia^^
What I Worked on Today And Am Working On:
ruby-based CMS to handle submissions and ratings for a pre-existing PHP project
[QUOTE=Richy19;27953688]Yet neither Bjarne Stroustrup nor Linus Torvalds have received it[/QUOTE]
With the speed at which computer science is evolving, I guess the Turing award should be monthly. :v:
[QUOTE=Richy19;27953688]Yet neither Bjarne Stroustrup nor Linus Torvalds have received it[/QUOTE]
What they have done isn't really computer [i]science[/i]. For example, one of the awards went to C. A. R. Hoare, who invented quicksort. That's something genuinely new, rather than a rehash or extension of an old idea (see C++ and Linux).
As GLU is deprecated (afaik), what is the solution for creating a projection matrix in OpenGL? I've once tried implementing it in my own matrix class with the formulas on the OpenGL website, but it didn't have the same result with the same parameters. Does anyone have an alternative to GLU?
[QUOTE=Overv;27953970]As GLU is deprecated (afaik), what is the solution for creating a projection matrix in OpenGL? I've once tried implementing it in my own matrix class with the formulas on the OpenGL website, but it didn't have the same result with the same parameters. Does anyone have an alternative to GLU?[/QUOTE]
OpenTK has it's own matrix class and it's open source so you can check out how they make the perspective.
Actually, here it is: [url=http://www.opentk.com/files/doc/_matrix4_8cs_source.html](link)[/url]
[csharp]00558 public static void CreatePerspectiveFieldOfView(float fovy, float aspect, float zNear, float zFar, out Matrix4 result)
00559 {
00560 if (fovy <= 0 || fovy > Math.PI)
00561 throw new ArgumentOutOfRangeException("fovy");
00562 if (aspect <= 0)
00563 throw new ArgumentOutOfRangeException("aspect");
00564 if (zNear <= 0)
00565 throw new ArgumentOutOfRangeException("zNear");
00566 if (zFar <= 0)
00567 throw new ArgumentOutOfRangeException("zFar");
00568 if (zNear >= zFar)
00569 throw new ArgumentOutOfRangeException("zNear");
00570
00571 float yMax = zNear * (float)System.Math.Tan(0.5f * fovy);
00572 float yMin = -yMax;
00573 float xMin = yMin * aspect;
00574 float xMax = yMax * aspect;
00575
00576 CreatePerspectiveOffCenter(xMin, xMax, yMin, yMax, zNear, zFar, out result);
00577 }
00578
00597 public static Matrix4 CreatePerspectiveFieldOfView(float fovy, float aspect, float zNear, float zFar)
00598 {
00599 Matrix4 result;
00600 CreatePerspectiveFieldOfView(fovy, aspect, zNear, zFar, out result);
00601 return result;
00602 }
00603
00604 #endregion
00605
00606 #region CreatePerspectiveOffCenter
00607
00626 public static void CreatePerspectiveOffCenter(float left, float right, float bottom, float top, float zNear, float zFar, out Matrix4 result)
00627 {
00628 if (zNear <= 0)
00629 throw new ArgumentOutOfRangeException("zNear");
00630 if (zFar <= 0)
00631 throw new ArgumentOutOfRangeException("zFar");
00632 if (zNear >= zFar)
00633 throw new ArgumentOutOfRangeException("zNear");
00634
00635 float x = (2.0f * zNear) / (right - left);
00636 float y = (2.0f * zNear) / (top - bottom);
00637 float a = (right + left) / (right - left);
00638 float b = (top + bottom) / (top - bottom);
00639 float c = -(zFar + zNear) / (zFar - zNear);
00640 float d = -(2.0f * zFar * zNear) / (zFar - zNear);
00641
00642 result = new Matrix4(x, 0, 0, 0,
00643 0, y, 0, 0,
00644 a, b, c, -1,
00645 0, 0, d, 0);
00646 }[/csharp]
Oh, and am I missing anything obvious here?
[img]http://i55.tinypic.com/1zoyuis.png[/img]
[QUOTE=Overv;27953970]As GLU is deprecated (afaik), what is the solution for creating a projection matrix in OpenGL? I've once tried implementing it in my own matrix class with the formulas on the OpenGL website, but it didn't have the same result with the same parameters. Does anyone have an alternative to GLU?[/QUOTE]
Here's the source from the mesa lib found at [url]http://www.mesa3d.org/[/url]
[cpp]
void GLAPIENTRY
gluLookAt(GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx,
GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy,
GLdouble upz)
{
float forward[3], side[3], up[3];
GLfloat m[4][4];
forward[0] = centerx - eyex;
forward[1] = centery - eyey;
forward[2] = centerz - eyez;
up[0] = upx;
up[1] = upy;
up[2] = upz;
normalize(forward);
/* Side = forward x up */
cross(forward, up, side);
normalize(side);
/* Recompute up as: up = side x forward */
cross(side, forward, up);
__gluMakeIdentityf(&m[0][0]);
m[0][0] = side[0];
m[1][0] = side[1];
m[2][0] = side[2];
m[0][1] = up[0];
m[1][1] = up[1];
m[2][1] = up[2];
m[0][2] = -forward[0];
m[1][2] = -forward[1];
m[2][2] = -forward[2];
glMultMatrixf(&m[0][0]);
glTranslated(-eyex, -eyey, -eyez);
}
[/cpp]
I actually use the base code in my video [url]http://www.youtube.com/watch?v=ncM6vm7W15M[/url]
2 hours and no new posts? Unacceptable !
Have some sweet concept art from my RTS game :
[img]http://29.media.tumblr.com/tumblr_lfkga2r8EC1qclar3o1_500.png[/img]
[QUOTE=Xerios3;27956822]2 hours and no new posts? Unacceptable !
Have some sweet concept art from my RTS game :
[img_thumb]http://29.media.tumblr.com/tumblr_lfkga2r8EC1qclar3o1_500.png[/img_thumb][/QUOTE]
Do you make all the models yourself?
Excellent, but show us engine progress too :allears:
[QUOTE=Overv;27953970]As GLU is deprecated (afaik), what is the solution for creating a projection matrix in OpenGL? I've once tried implementing it in my own matrix class with the formulas on the OpenGL website, but it didn't have the same result with the same parameters. Does anyone have an alternative to GLU?[/QUOTE]
I know i may be a bit late but this is how i create my P matrix.
[code]
//Matrix = 4x4
MATRIX Camera::GetPerspectiveMatrix(float fovY, float aspect, float near, float far )
{
float yScale = 1 / tan(fovY/2);
float xScale = yScale / aspect;
MATRIX proj( xScale ,0 ,0 ,0,
0 ,yScale ,0 ,0,
0 ,0 ,(far/( far - near )) ,1,
0 ,0 ,(-near * far / ( far - near )) ,0);
return proj;
}
[/code]
I'm using DirectX but I'm sure it will work just fine for OpenGL as well.
Note that this will only return the Perspective matrix (not the VP matrix) but I could give you a function that returns the V matrix if you need it.
Just tested my force code I posted a few pages ago(I didn't have time at that moment), worked on the first try!
First time that's ever happened.
[editline]9th February 2011[/editline]
Now to work on collision
[QUOTE=NovembrDobby;27956852]Excellent, but show us engine progress too :allears:[/QUOTE]
Your wish is my command ! ( You actually reminded me to update my blog, thanks )
[quote]
[img]http://24.media.tumblr.com/tumblr_lgdc3dSkdx1qclar3o1_500.jpg[/img]
There wasn't anything interesting to show for some while, most of the things were just some bug fixes and necessary code improvements.
But now that it's done, I can start showing you guys the sweet stuff.
We all know that GUI is one of the most important elements of an RTS game. Unfortunately not everyone is comfortable with some fixed interfaces, some may prefer StarCraft style, others may prefer Supreme Commander's design and maybe some of you people would love to have their own custom one.
So let me introduce you to my (still WIP) GUI system ! The point of it is to make MY life easier while making yours AS WELL, last system was just a placeholder and it was really hard to work with. This time I'm using a simple and yet customizable interface system, scalable with any screen size and can be easily adjusted to own your needs !
As easy as a simple version of HTML, you create a container, you align it to the left of the screen and then add whatever you want in there =)[/quote]
Fixed a bug in a browser game for a friend, as it stands, 90% of any browser game based on Legend of the Green Dragon, is open to a major XSS bug that would let someone gain admin easilly.
I love Google's way of seeing things.
Scons doesn't build chromium fast enough ? Well we'll switch to Make.
Make doesn't build chromium fast enough ? Well we'll make our own. And thus Ninja was born. It's a lightweight build system, looks promising.
[url]https://github.com/martine/ninja[/url]
for benchmarks, scons waits 40 seconds before starting to build chromium, make 10 to 20 seconds, ninja take 6 seconds.
[url]http://neugierig.org/software/chromium/notes/2011/02/ninja.html[/url]
-snip-
(late)
Moving to opengl 3.x but I'm having some problem with my draw function.
Ok so I'm using glDrawArrays() and it's working fine if I don't use WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB as one of the contextattributes when creating the context.
So if I change it to 0 or NULL I can draw my triangle or whatever I want to draw. If I don't, it wont rendered at all. Someone know why? Did I miss something in my initialize function?
[editline]9th February 2011[/editline]
oh maby
[cpp]
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, &vertices[0]);
[/cpp]
Is this the problem? I can't do that in OGL 3.x?
I was sitting here thinking how I could either make my form Textbox only or Gridview only.
Then I got all this.
[media]http://www.youtube.com/watch?v=ATy-PXZmpNo[/media]
[quote=likesoursugar;27958999]moving to opengl 3.x but i'm having some problem with my draw function.
Ok so i'm using gldrawarrays() and it's working fine if i don't use wgl_context_forward_compatible_bit_arb as one of the contextattributes when creating the context.
So if i change it to 0 or null i can draw my triangle or whatever i want to draw. If i don't, it wont rendered at all. Someone know why? Did i miss something in my initialize function?
[editline]9th february 2011[/editline]
oh maby
[cpp]
glenableclientstate(gl_vertex_array);
glvertexpointer(3, gl_float, 0, &vertices[0]);
[/cpp]
is this the problem? I can't do that in ogl 3.x?[/quote]
Have you tried WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB?
Also, you should seriously stop using immediate mode...
[QUOTE=q3k;27960079]Have you tried WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB?
Also, you should seriously stop using immediate mode...[/QUOTE]
He's using glDrawArrays, not immediate mode.
[QUOTE=Overv;27960183]He's using glDrawArrays, not immediate mode.[/QUOTE]
He's using
[cpp]glVertexPointer(3, GL_FLOAT, 0, &vertices[0]);[/cpp]
[QUOTE=Soda;27953703]^^pm i got from jookia^^[/QUOTE]
You seriously did EXACTLY what I expected you to do. Grow some balls man.
[QUOTE=q3k;27960279]He's using
[cpp]glVertexPointer(3, GL_FLOAT, 0, &vertices[0]);[/cpp][/QUOTE]
True, but that's deprecated, not immediate mode.
Oh, also, not meaning to derail the thread to why Soda's parents allow him to use the Internet, but:
[img]http://i51.tinypic.com/33xelg9.png[/img]
[highlight](User was banned for this post ("This post is not about the thread topic" - verynicelady))[/highlight]
[QUOTE=Overv;27960568]True, but that's deprecated, not immediate mode.[/QUOTE]
Crap, you're right. :(
[QUOTE=Overv;27960568]True, but that's deprecated, not immediate mode.[/QUOTE]
It is? :O Someone told me to use glBindVertexArray? Is that right?
Because if glVertexPointer is deprecated it's kinda obviously why I got problem with my rendering.
Soda is a a fag ehehehee
[highlight](User was banned for this post ("This post is off topic and unnecessary" - verynicelady))[/highlight]
[QUOTE=likesoursugar;27960785]It is? :O Someone told me to use glBindVertexArray? Is that right?
Because if glVertexPointer is deprecated it's kinda obviously why I got problem with my rendering.[/QUOTE]
I do glBindVertexArray -> (glBindBuffer -> glEnableVertexAttribArray -> glBufferData -> glVertexAttribPointer) x n -> glBindBuffer -> glBufferData when creating vertex data (where n is the numbver of attributes you want in your shader, then another buffer for the index buffer. Then, when drawing, just bind to the Vertex Array again and call glDrawElements.
I may not be using the best way, though.
[QUOTE=Jookia;27960740]Oh, also, not meaning to derail the thread to why Soda's parents allow him to use the Internet, but:
[img_thumb]http://i51.tinypic.com/33xelg9.png[/img_thumb][/QUOTE]
I'm pretty sure a moderator could ban him for that shit. Have you tried reporting his PMs?
[QUOTE=Dryvnt;27936685]I want to play an animation at my map every some seconds, does anyone know how to do that with SFML?
I have a graphic already, the problem lies in animating it and having it appear.
[img_thumb]http://dl.dropbox.com/u/2670708/even%20more%20folders/progarmming/cirkel2.png[/img_thumb][/QUOTE]
Here's some code that I made about a year ago. You put all your animations on the same image and then specify their dimensions/size when adding the animation to the list. Note that it was probably the first real C++ that I wrote and so some of the things I did may not be adherent to best practices (particularly inheriting from sf::Sprite IIRC).
Features:
-variable border size
-multi-row animations
-multiple animations
-adjustable speed, including forwards/backwards playing
-framerate-independent animations. Playback is based on time, with frameskipping implemented
-cyclic or non-cyclic animations
Disclaimer: I haven't used this code in a long time/was changing quite a bit of code when I gave up the project/just had a quick look through it to clean up some of it, so it may not work outright. Also, some features were added for my specific purposes and do not really need to be in a general animation class.
animsprite.h:
[code]
//Animated Sprite Header
#ifndef ANIMSPRITE_HPP
#define ANIMSPRITE_HPP
//includes
#include <SFML/Graphics.hpp>
#include <cmath>
#include <vector>
#include <map>
#include <utility>
struct AnimSprAnimation
{
std::string AnimName;
unsigned short NumFrames;
unsigned short NumRows;
unsigned short NumPerRow;
unsigned short StartX;
unsigned short StartY;
float Framerate;
bool Forwards;
bool Cyclic;
};
class AnimSprite : public sf::Sprite
{
public:
short currentframe;
AnimSprite(std::string);
AnimSprite();
void Update();
void Update(int);
void SetFrameSize(int,int);
void SetBorderSize(int,int);
void AddAnim(std::string Name, short Length, int StartX, int StartY, short Rows, short NumPerRow, float Framerate, bool Cyclic);
int PlayAnim(std::string, bool forwards);
void Render(sf::RenderWindow* App);
protected:
sf::Image image;
sf::Vector2i FrameSize;
sf::Vector2i BorderSize;
sf::Clock AnimClock;
float OldTime;
std::map<std::string, AnimSprAnimation*> AnimsList;
struct AnimSprAnimation *CurrentAnim;
AnimSprAnimation DefaultAnim;
sf::Image MyImage;
sf::IntRect MySubRect;
};
#endif
[/code]
animsprite.cpp:
[code]
//Animated Sprite Source file
#include "animsprite.h"
inline int clamp0(int x, int a) //second parameter is lower bound, no upper bound
{
return x < a ? a : x;
}
AnimSprite::AnimSprite (std::string ImagePath) {
Calledback=false;
currentframe=0;
if( !image.LoadFromFile(ImagePath)) {
SetImage( image );
FrameSize.x=GetSubRect().GetWidth();
FrameSize.y=GetSubRect().GetHeight();
}
this->AddAnim("DefaultAnim", 1, 0, 0, 1, 1, 1, true);
this->PlayAnim("DefaultAnim", true);
OldTime=0;
}
AnimSprite::AnimSprite() {
currentframe=0;
this->AddAnim("DefaultAnim", 1, 0, 0, 1, 1, 1, true);
this->PlayAnim("DefaultAnim", true);
OldTime=0;
}
void AnimSprite::Update() { //ATTENTION: UPCOMING CODE IS HARD TO READ. YOU HAVE BEEN WARNED!
if (Calledback==false) {
if (CurrentAnim->AnimName=="DefaultAnim") { // If no animation playing (or none specified)
if (GetSubRect().GetWidth()!=FrameSize.x || GetSubRect().GetHeight()!=FrameSize.y) {
SetSubRect(sf::IntRect(BorderSize.x,BorderSize.y,FrameSize.x,FrameSize.y));
}
}
else { //In the case that there is in fact an animation applied, we must do something about it
if (OldTime + (1.f/CurrentAnim->Framerate) > AnimClock.GetElapsedTime()) return; //if not a new frame
else {
if (CurrentAnim->Forwards==true) {
currentframe+=(short int)std::floor((AnimClock.GetElapsedTime()-OldTime)*CurrentAnim->Framerate);
while (currentframe > CurrentAnim->NumFrames-1) {if(CurrentAnim->Cyclic==false){ PlayAnim("DefaultAnim",true); break;} currentframe=currentframe-CurrentAnim->NumFrames;}
}
else {
currentframe-=(short int)std::floor((AnimClock.GetElapsedTime()-OldTime)*CurrentAnim->Framerate);
while (currentframe < 0){ if(CurrentAnim->Cyclic==false) {PlayAnim("DefaultAnim",true); break;} currentframe=CurrentAnim->NumFrames-std::abs(currentframe);}
}
sf::Vector2i LC ( clamp0((int)std::floor(currentframe-(CurrentAnim->NumPerRow*std::floor(currentframe/CurrentAnim->NumPerRow))),0) , (int)std::floor(currentframe/CurrentAnim->NumPerRow) );
sf::Vector2i CurLeftCorner ( (LC.x*FrameSize.x) + (LC.x*BorderSize.x)+CurrentAnim->StartX, (LC.y*FrameSize.y)+(LC.y*BorderSize.y)+CurrentAnim->StartY );
SetSubRect(sf::IntRect(CurLeftCorner.x,CurLeftCorner.y,CurLeftCorner.x+FrameSize.x,CurLeftCorner.y+FrameSize.y));
OldTime=AnimClock.GetElapsedTime();
}
}
}
}
//Change to a specific frame
void AnimSprite::Update(int frame) {
sf::Vector2i LC ( clamp0((int)std::floor(frame-(CurrentAnim->NumPerRow*std::floor(frame/CurrentAnim->NumPerRow))),0) , (int)std::floor(frame/CurrentAnim->NumPerRow) );
sf::Vector2i CurLeftCorner ( (LC.x*FrameSize.x) + (LC.x*BorderSize.x)+CurrentAnim->StartX, (LC.y*FrameSize.y)+(LC.y*BorderSize.y)+CurrentAnim->StartY );
SetSubRect(sf::IntRect(CurLeftCorner.x,CurLeftCorner.y,CurLeftCorner.x+FrameSize.x,CurLeftCorner.y+FrameSize.y));
}
void AnimSprite::SetFrameSize(int xs, int ys) {
FrameSize.x=xs;
FrameSize.y=ys;
Update();
SetCenter((GetSize().x/GetScale().x)/2.f,(GetSize().y/GetScale().y)/2.f);
}
void AnimSprite::SetBorderSize(int xs, int ys) {
BorderSize.x=xs;
BorderSize.y=ys;
Update();
}
void AnimSprite::AddAnim(std::string Name, short Length=1,int StartX=0, int StartY=0, short Rows=1, short NumPerRow=1, float Framerate=1, bool Cyclic=true) {
AnimSprAnimation * NewAnim;
NewAnim= new AnimSprAnimation;
NewAnim->AnimName=Name;
NewAnim->NumFrames=Length;
NewAnim->StartX=StartX;
NewAnim->StartY=StartY;
NewAnim->NumRows=Rows;
NewAnim->NumPerRow=NumPerRow;
NewAnim->Framerate=Framerate;
NewAnim->Cyclic=Cyclic;
AnimsList.insert(std::make_pair(Name,NewAnim));
}
int AnimSprite::PlayAnim(std::string AnimName, bool forwards=true) {
Calledback=false;
std::map<std::string,AnimSprAnimation*>::iterator iter = AnimsList.begin();
iter = AnimsList.find(AnimName);
if( iter != AnimsList.end() ) {
CurrentAnim=iter->second;
if (forwards) CurrentAnim->Forwards=true;
else CurrentAnim->Forwards=false;
AnimClock.Reset();
OldTime=0;
Update(0);
return 1;
}
else
return -1;
}
void AnimSprite::Render(sf::RenderWindow* App) {
App->Draw(*this);
}
[/code]
Usage (2 examples, [url=http://i53.tinypic.com/29uq9tk.png]PlayerSprite.png[/url], [url=http://i51.tinypic.com/ipcl5k.png]explosion1.png[/url]. Both have no border between frames)
[cpp]
#include "animsprite.h"
//Playersprite plays a looping run animation
AnimSprite PlayerSprite = AnimSprite("data/sprites/PlayerSprite.png");
PlayerSprite.SetFrameSize(48,48);
PlayerSprite.SetBorderSize(0,0);
PlayerSprite.AddAnim("Run",7,0,0,1,7,15,true);
PlayerSprite.PlayAnim("Run",true);
//Explosion plays once
AnimSprite ExplosionSprite=AnimSprite("data/sprites/explosion1.png");
ExplosionSprite.SetFrameSize(131,128);
ExplosionSprite.SetBorderSize(0,0);
ExplosionSprite.AddAnim("BOOM",24,0,0,4,7,20,false);
ExplosionSprite.PlayAnim("BOOM",true);
//Every frame:
PlayerSprite.Update();
App.Draw(PlayerSprite);
ExplosionSprite.Update();
App.Draw(ExplosionSprite);
[/cpp]
Hopefully you can either use or learn from this code :).
Sorry, you need to Log In to post a reply to this thread.