3 Replies - 1067 Views - Last Post: 23 April 2014 - 03:35 PM Rate Topic: -----

#1 pbivens85  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 67
  • Joined: 22-October 13

sprite sheets

Posted 20 April 2014 - 07:16 PM

well I am developing a space invaders and galaga cross. I am using opengl and c++. where can I find a web site that teaches how to use sprites and opengl. I want to use a spritesheet to paint my sprites to the screen.
Is This A Good Question/Topic? 0
  • +

Replies To: sprite sheets

#2 Mahouxshounen  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 16-March 14

Re: sprite sheets

Posted 21 April 2014 - 11:02 AM

I do hope that it's not impolite/rude, or against the rules to post links to other sites, so:

Lazy Foo provides quite a few good tutorials on both C++ with the SDL API, how to use OpenGL with it, and also OpenGL with freeGLUT. But since you didn't tell us which API you plan on using, I would or could assume you plan on writing it in the Win32 API? I don't really know.

OpenGL in itself, as far as I know can't load in image files, so you will need something to do that for you (Since I assume that you're going to use PNG files for the spritesheets that you want to load in). Either as I mentioned before SDL, but there are many other options that does the task for you like DevIL for example. As for the OpenGL part, either you're doing it in legacy or modern OpenGL, that's another question too.

I can also recommend NeHe Productions Legacy OpenGL tutorials for you, but that's only if you're not planning on doing the whole thing in modern OpenGL, since this is just legacy only.

You could also look at www.opengl-tutorial.org for a little bit of insight into OpenGL. C++ and OpenGL is a very wide term, I just gave you a few options I could think right now, but I'm sure there are plenty of others, and I hope you'll find what you're looking for sooner or later.
Was This Post Helpful? 0
  • +
  • -

#3 pbivens85  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 67
  • Joined: 22-October 13

Re: sprite sheets

Posted 22 April 2014 - 02:21 PM

well I want to paint two bullets on the screen but I am only able to draw one on the screen. I have tried a few things but I am still unsuccessful.here is some of my code
void drawScene() {
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	
	glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
	
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, _textureId);
	
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

	glColor3f(1.0f, 1.0f, 1.0f);
	glBegin(GL_POLYGON);
	glTexCoord2f(0.0f, 0.0f);
	glVertex3f(-1.0f+scroll, -10.0f, 0.0f);
	glTexCoord2f(1.0f, 0.0f);
	glVertex3f(-1.0f+scroll, -8.0f, 0.0f);
	glTexCoord2f(1.0f, 1.0f);
	glVertex3f(1.0f+scroll, -8.0f, 0.0f);
	glTexCoord2f(0.0f, 1.0f);
	glVertex3f(1.0f+scroll, -10.0f, 0.0f);
	glEnd();

	glDisable(GL_TEXTURE_2D);

	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, _textureId_two);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

	glColor3f(1.0f, 1.0f, 1.0f);
	glBegin(GL_POLYGON);
	glVertex3f(-1.0f+scroll, -8.0f+up, 0.0f);
	glVertex3f(-1.0f+scroll, -6.0f+up, 0.0f);
	glVertex3f(1.0f+scroll, -6.0f+up, 0.0f);
	glVertex3f(1.0f+scroll, -8.0f+up, 0.0f);
	glEnd();

	glDisable(GL_TEXTURE_2D);

	glutSwapBuffers();
}


Was This Post Helpful? 0
  • +
  • -

#4 pbivens85  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 67
  • Joined: 22-October 13

Re: sprite sheets

Posted 23 April 2014 - 03:35 PM

well after several days of trail and error I finally fixed my problem. Thanks for all the help.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1