Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

100 Neutral

About Randomone16

  • Rank
  1. Randomone16

    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: (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. Randomone16

    Beginner trouble with OpenGL

    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. Randomone16

    Beginner trouble with OpenGL

    I know the file is loading, due to this error catcher not giving me anything: if(decoder.hasError()) printf("%s %i %s %s \n","error, ", decoder.getError(),": ",LodePNG_error_text(decoder.getError())); I even tested it by just putting gibberish for the filename, and the error catcher caught it. Tried that, still not working. I think it may have something to do with the image vector and how glTexImage2D reads it.
  4. 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... #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; } Any help?
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!