Advertisement

sprite sheet

Started by September 03, 2018 11:54 PM
41 comments, last by Rutin 6 years, 2 months ago

I am using paint to manipulate my sprites, should I try gimp?

6 minutes ago, phil67rpg said:

I am using paint to manipulate my sprites, should I try gimp?

You wont know until you try so go for it. It's a good option if you don't have photoshop.

Programmer and 3D Artist

Advertisement

I am using gimp it sure can do alot

well I have adjusted the glTexCoord2f function to render a part of my sprite sheet. unfortunately I cant get the sprite to draw properly, it only draws part of my plane sprite, is there a difference between how soil reads a png file and a bmp file, which one should I use.

You should know the drill by now:


What have you tried? What did you expect the code to do? What did it actually do? Where is a copy of the exact source code we can look at for errors?

We aren't psychic, please don't make us guess at what you are doing.

 

Going on a hunch knowing your posting history, you're probably misusing the texture coordinates somehow. The fact that you can see part of a sprite implies the image processing code is working correctly. But that's all a guess using fancy mindreading techniques.

well here is my code


int LoadGLTextures()
{
	texture[0] = SOIL_load_OGL_texture
	(
		"sheet.png",
		SOIL_LOAD_AUTO,
		SOIL_CREATE_NEW_ID,
		SOIL_FLAG_INVERT_Y
	);

	if (texture[0] == 0)
		return false;

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

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

	return true;
}

void display(void)
{
	glClear(GL_COLOR_BUFFER_BIT);

	glEnable(GL_TEXTURE_2D);

	glGenTextures(8, &texture[1]);
	glBindTexture(GL_TEXTURE_2D,texture[0]);

	glBegin(GL_QUADS);
	glTexCoord2f(0.0f, 0.0f); 
	
	glVertex3f(-1.0f, -2.0f, 0.0f);
	glTexCoord2f(0.0f, 0.125f); 
	
	glVertex3f(-1.0f, 2.0f, 0.0f);
	glTexCoord2f(0.125f, 0.125f); 
	
	glVertex3f(1.0f, 2.0f, 0.0f);
	glTexCoord2f(0.125f, 0.0f); 
	
	glVertex3f(1.0f, -2.0f, 0.0f);
	glEnd();

	glutSwapBuffers();
}

 

Advertisement

That is your code.  You are 25% of the way complete with the required information.

We can still only guess about the other 75%.

ok here is all of my code


#include <stdlib.h>
#include <glut.h>
#include <iostream>
#include "SOIL.h"

GLuint texture[8];

void SetupRC(void)
{
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	glOrtho(-10.0f, 10.0f, -10.0f, 10.0f, -1.0f, 1.0f);
}

int LoadGLTextures()
{
	texture[0] = SOIL_load_OGL_texture
	(
		"sheet.png",
		SOIL_LOAD_AUTO,
		SOIL_CREATE_NEW_ID,
		SOIL_FLAG_INVERT_Y
	);

	if (texture[0] == 0)
		return false;

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

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

	return true;
}

void display(void)
{
	glClear(GL_COLOR_BUFFER_BIT);

	glEnable(GL_TEXTURE_2D);

	glGenTextures(8, &texture[1]);
	glBindTexture(GL_TEXTURE_2D,texture[0]);

	glBegin(GL_QUADS);
	glTexCoord2f(0.0f, 0.0f); 
	
	glVertex3f(-1.0f, -2.0f, 0.0f);
	glTexCoord2f(0.0f, 0.125f); 
	
	glVertex3f(-1.0f, 2.0f, 0.0f);
	glTexCoord2f(0.125f, 0.125f); 
	
	glVertex3f(1.0f, 2.0f, 0.0f);
	glTexCoord2f(0.125f, 0.0f); 
	
	glVertex3f(1.0f, -2.0f, 0.0f);
	glEnd();

	glutSwapBuffers();
}

int main(int argc, char* argv[])
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
	glutInitWindowPosition(500, 300);
	glutInitWindowSize(800, 600);
	glutCreateWindow("1945");
	glutDisplayFunc(display);
	SetupRC();
	LoadGLTextures(); 
	glutMainLoop();
	return 0;
}

 

well I am making this game for a college class, that is why I am using glut, he likes glut

1 hour ago, frob said:

  What have you tried?

  What did you expect the code to do?

  What did it actually do?

?Where is a copy of the exact source code we can look at for errors?

 

- Jason Astle-Adams

well I have used paint to render my sprites but they don't want to draw properly, I expect my code to render a sprite from a sprite sheet, I have tried using a sprite sheet in both .png and .bmp formats but both don't render the sprite properly. I will try bmp format again. when I use .png format it draws only a part of the plane sprite. I think my problem is in how soil reads the sprites.

This topic is closed to new replies.

Advertisement