Jump to content

  • Log In with Google      Sign In   
  • Create Account


zaneski13

Member Since 11 Oct 2009
Offline Last Active Jun 21 2012 11:41 PM
-----

Topics I've Started

sampler2D vertex shader. work on older computers?

16 April 2012 - 11:36 AM

Ok, so I need to access a texture in my vertex shader, but I want the game to run on cards that only support shader model 2. Anyone know if acessing a texture in a vertex shader crashes on old cards? also is there a website that shows the limitations of shader models. like what they support and dont support? Thanks.

sphere vs isometric frustum collision

03 April 2012 - 12:19 PM

So I'm in the process of developing a 3D Isometric game in c++ and opengl. I'm currently working on the lighting system. Basicly I have a max number of lights that can be viewable at one time, but the level has no bounds of how many lights can exist. So I need to filter out the lights that are not viewable.

some valuable information:

EVERY LIGHT IN THE SCENE IS A POINT LIGHT, so a sphere...

The camera frustum is ISOMETRIC 3D. Its positioned about 30 feet above the character, and rotated 45degrees down X and 135 degrees Y (this may change)

I have a function implemented that casts rays from each corner of the screen. For each ray I calculate the x and z value when the y value is 0.
this is because the game is 2.5 D, no terrain to worry about. Ground is always at y = 0

So with these 4 points I can figure out how much of the level is in view (how many ground tiles i have to draw)

Each light has a 3D position and a radius.

Using that information, how can I figure out which lights in the level are visible at a given time?

Any help is appreciated. Thanks!

glTexSubImage2D not working with GL_RGB or GL_LUMINANCE textures [SOLVED]

28 February 2012 - 09:50 PM

Ok, so I'm having a problem with the glTexSubImage2D function. The function only works with GL_RGBA textures, but when I use GL_RGB or GL_LUMINANCE textures, glTexSubImage2D acts funny.

I've created a class called TextureEditable
Bellow are the 2 functions I made. SetData, and SetSubData(). formatType can be TEX_RGB, TEX_RGBA, or TEX_ALPHA

bool TextureEditable::SetData(int width_, int height_, unsigned char *pixels, int formatType)
{
if ( !math::IsPower2(width_) || !math::IsPower2(height_) )
  return false;
if ( !pixels )
  return false;
if ( formatType != TEX_RGB && formatType != TEX_RGBA && formatType != TEX_ALPHA )
  return false;
//ok, so the data that was passed in is good, only error that can possibly happen is if the data has less elements that width*height*bpp
format = formatType;
width = width_;
height = height_;
if ( data )
  delete [] data;
int bpp = 1;
if ( format == TEX_RGB )
  bpp = 3;
else if ( format == TEX_RGBA )
  bpp = 4;
cout << "bpp = " << bpp << endl;
data = new unsigned char[width*height*bpp];

for ( int i=0; i < width*height*bpp; i++ )
  data[i] = pixels[i];
//now we have the data
if ( texID == 0 ) //then we haven't generated a gl texture yet, so generate one
{
  Texture::EnableGLTextures();
  glGenTextures(1, &texID);
  glBindTexture(GL_TEXTURE_2D, texID);
  Texture::lastBoundTexture = texID;
  cout << "creating tex " << texID << endl;
}
Texture::EnableGLTextures();
glBindTexture(GL_TEXTURE_2D, texID);
Texture::lastBoundTexture = texID;
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
if ( format == TEX_RGB )
{
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
}
else if ( format == TEX_RGBA )
{
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
}
else if ( format == TEX_ALPHA )
{
  glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, width, height, 0, GL_LUMINANCE , GL_UNSIGNED_BYTE, data);
}



return true;
}
bool TextureEditable::SetSubData(int x, int y, int w, int h, unsigned char *pixels)
{
if ( !pixels )
  return false;
if ( x < 0 || x >= width || y < 0 || y >= height )
  return false;

Texture::EnableGLTextures();
glBindTexture(GL_TEXTURE_2D, texID);
Texture::lastBoundTexture = texID;
if (format == TEX_RGBA )
{
  glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
}
else if ( format == TEX_RGB )
{
  glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGB, GL_UNSIGNED_BYTE, pixels);
}
else if ( format == TEX_ALPHA )
  glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_LUMINANCE, GL_UNSIGNED_BYTE, pixels);

}



OK, so those are the main functions I'm working with in that class.

in my main program I do this...

tex2 = new TextureEditable("");

unsigned char pixels[4*4] = {100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100};
tex2->SetData(4,4,pixels,TEX_ALPHA);

unsigned char sub[2*2] = {255,255,255,255};
tex2->SetSubData(1,1,2,2,sub);


I render a quad with the texture mapped on it. What I should see is a grey square with a white square in the middle
Instead I see a grey square with a square in the middle that is shaded white in the first 2 texels and shaded different shades of grey for the other 2 texels

Note, the desired effect works when I use a texture that has GL_RGBA data. I think whats happening is when I call glTexSubImage2D its taking the pixel data i send it assumes its a RGBA texture when its a greyscale texture. But I'm not sure. Any help would be greatly appreciated.

Making money to start game project

30 June 2011 - 10:19 AM

Hi, so I'm 17 years old, currently unemployed, and am struggling to find ways to make money. I decided that since I can't find a job in my neighborhood at the moment that I was going to start developing a game and releasing it on my own website and sell it for a small amount of money. like 5$ maybe. And then maybe use google adsense to make a little more money off the website. Well, I've been designing games with C++ and OpenGL for almost 2 years now so making the game isn't a problem for me, what is is buying the domain and paying for hosting. And in order to make a website with a .com domain you need to pay something like 10$. I'ts never been this hard to find money before! No job, parents wont lend me money, friends are either broke or out on vaction for summer. I just don't know what to do. I like the idea of making money off developing a game but I need a starting budget which I unforchantly don't have. Does anyone have any ideas on how to raise just a little bit of money, say 20$ just to get the website up and running? I've tried taking surveys online but they usually don't work or are loaded with scams.

Game Payment Security

26 November 2010 - 02:32 PM

So, I've been thinking about creating some commercial projects now, but I'd like to collect ideas on how to do this safely and how to make it so that everyone who plays the game needs to pay for it, no mediashare downloads, etc.

What I was going to do was to design a website where people use paypal accounts to buy the software. When the order goes through, a link will be emailed to them and they can download the game from that link. The problem about this is say someone buys the game but then puts it on a website like mediashare where other people can download it... for free, I'd be losing profit. I'm trying to minimize profit loss obviously.

What I was considering was making some sort of key system, where when you buy the game, a random sequence of characters is generated and put on a database and sent to the buyers email. When the buyer first play the game, it'll ask you for a key. you would type in the key that was sent in the email and it would connect to the database and check if there's any matching keys. If there is, the program would continue, else it would close.

The problem with this is then the buyer would only have to upload the game and his/her key to a website like mediashare. Should I make it so that the key has an IPadress associated to it so that when the game runs it checks for the persons IPAdress and checks if its an address that bought it? but then if I did it that way, the buyer could only install the game on one computer, which isn't fair if s/he buys a new computer and needs to install it on that computer.

errrr I seem like I just can't win. I'm trying to come up with a fair solution but anything I come up with has some sort of flaw. Does anyone know how large companies pull it off? Or does anyone have any good ideas?

Thanks

PARTNERS