• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

100 Neutral

About Randomone16

  • Rank
  1. Feedback on some coder art

    I'm making a topdown spaceship game as a personal project and I need some help with my spriting. I'm trying to go for a look kinda like this: [img]http://img.photobucket.com/albums/v84/Seichi/SMscreen09-1.png[/img] (taken from a random post on the Battleships Forever forum) Here are my attempts: [attachment=7888:Cannon A.png][attachment=7889:Enemy A.png] Here are it is in game: [attachment=7890:InGame 1.png] (click it to make it non-blurry) I'm also thinking of scaling them up from 64 x 64 for the whole sprite sheet, but I'm not so sure. Anyway, can you give me some feedback and pointers?
  2. Beginner trouble with OpenGL

    [quote name='rip-off' timestamp='1312389302' post='4844119'] You seem to be passing the values of the "size" array to glTexImage2D. This array is zero initialised (as a global value). What about using "width" and "height"? You should be passing &image.front() or &image[0], not the address of the vector object itself. It is unnecessary to clear() these vectors, they will be cleared automatically when they leave scope. [/quote] Wow, I can't believe I forgot to change the width and height arguments. >_> Okay, after making your changes, I'm actually getting an image now. Unfortunately, it is corrupted. I can kinda see the oultine of the image in the corruption, so I know it is loaded. Also, my image is 256x256. I don't know if that matters. EDIT: nvm, got it to work. Apparently lodepng outputs a 32 bit RGBA image by default, no matter what the inital input is.
  3. Beginner trouble with OpenGL

    [quote name='rip-off' timestamp='1312388200' post='4844111'] Could be a path problem, you seem to be loading using a relative path. Have you tried using an absolute path? If this works, then it means the working directory doesn't match the one your image is in. You should be doing error checking after the call to loadFile. I see from the documentation that if the vector is empty then it means there was a problem loading the file. [/quote] I know the file is loading, due to this error catcher not giving me anything: [code]if(decoder.hasError()) printf("%s %i %s %s \n","error, ", decoder.getError(),": ",LodePNG_error_text(decoder.getError()));[/code] I even tested it by just putting gibberish for the filename, and the error catcher caught it. [quote name='zacaj' timestamp='1312388357' post='4844112'] You say youre using a 24bit png, but youre using GL_RGBA, which is 32bit. Try GL_RGB instead. [/quote] Tried that, still not working. I think it may have something to do with the image vector and how glTexImage2D reads it.
  4. Beginner trouble with OpenGL

    I'm kinda new to programming, and I am having some trouble outputting an image with OpenGL. What I'm trying to do is load an image with lodepng and output it on a square using a combination of modified code I find on the Internet. But whatever I try, I either get a white square, a square in some random color, or corruption. Neither Opengl or lodepng are giving me any errors. The PNG I'm loading is 24 bit, if it matters. Here is the code from my test project; there are probably parts of it that are left over from my previous attempts, so... [code] #include "stdafx.h" #include <gl\freeglut.h> #include "lodepng.h" GLuint texture; unsigned int size[1]; void ErrorStuff() { GLenum errCode; const GLubyte *errString; if ((errCode = glGetError()) != GL_NO_ERROR) { errString = gluErrorString(errCode); fprintf (stderr, "OpenGL Error: %s\n", errString); } } void Render (int x) { glutTimerFunc(33,Render,0); glClear(GL_COLOR_BUFFER_BIT); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL); glLoadIdentity(); glBindTexture(GL_TEXTURE_2D,texture); gluOrtho2D(-100,100,-100,100); //glTexGenf(GL_S,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR); //glTexGenf(GL_T,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR); //glColor3f(1.0,1.0,1.0); glBegin(GL_QUADS); glTexCoord2f(1.0, 1.0); glVertex2f(10.0,10.0); glTexCoord2f(1.0, 0.0); glVertex2f(10.0,-10.0); glTexCoord2f(0.0, 0.0); glVertex2f(-10.0,-10.0); glTexCoord2f(0.0, 1.0); glVertex2f(-10.0,10.0); glEnd(); glutSwapBuffers(); glDisable(GL_TEXTURE_2D); ErrorStuff(); } GLuint LoadImage() { { std::vector <unsigned char> buffer, image; LodePNG::loadFile(buffer, "Image1.png"); LodePNG::Decoder decoder; decoder.decode(image, buffer.size() ? &buffer[0] : 0, (unsigned)buffer.size()); if(decoder.hasError()) printf("%s %i %s %s \n","error, ", decoder.getError(),": ",LodePNG_error_text(decoder.getError())); int width = decoder.getWidth(); int height = decoder.getHeight(); GLuint textureID; glGenTextures(1, &textureID); glBindTexture(GL_TEXTURE_2D, textureID); glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, size[0], size[1], 0, GL_RGBA,GL_UNSIGNED_BYTE, &image); image.clear(); buffer.clear(); ErrorStuff(); return textureID; } } int _tmain(int argc, char* argv[]) { glutInit(&argc,argv); glutInitWindowPosition (-1,-1); glutInitWindowSize( 500, 500); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE ); glutCreateWindow("Image Test"); glDisable(GL_COLOR_MATERIAL); texture = LoadImage(); glutTimerFunc(33,Render,0); glutMainLoop(); return 0; }[/code] Any help?
  • Advertisement