Advertisement

sprite sheet

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

What leads you to that conclusion?  You already wrote that part of the image is showing, so obviously data is loading.

I suggest you use paper and pencil to work through exactly what every line if your Display() function is doing. 

A picture is worth a thousand words.  Post an actual screenshot, and also post the actual spritesheet you're using.

I'm guessing that your texture coordinates are incorrect, but without the screenshot and the spritesheet, that's just a random guess.

Advertisement

It seems like @phil67rpg goes out of his way to make cryptic posts, only ever giving about 20-25% of the needed information and not actually asking questions then gleefully waiting to see what people come up with.  Maybe it's a new college class of some sort?  Trolling technical sites with nice people on it to make them bitter? ?

Now, on to the actual issue.  @phil67rpg post the .png, .bmp images you're using and a screen shot of your program running please.

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

1 hour ago, CrazyCdn said:

It seems like @phil67rpg goes out of his way to make cryptic posts, only ever giving about 20-25% of the needed information and not actually asking questions then gleefully waiting to see what people come up with.  Maybe it's a new college class of some sort?  Trolling technical sites with nice people on it to make them bitter? ?

Now, on to the actual issue.  @phil67rpg post the .png, .bmp images you're using and a screen shot of your program running please.

From what I know based on prior posting history he has been learning to program for 14+ years now. One would need to constructively look at their progress and find out what the bottleneck is because spinning your tires for that long and not moving substantially is just a complete waste of time. What most people can do at year one and jump forward ten years is like night and day.

@phil67rpg I know that I've helped you in prior threads and I also did strongly recommend you go back and really familiarize yourself with programming and dump GLUT if possible. I honestly think you would benefit greater by using SFML or SDL for window creation, and using openGL directly for drawing while taking advantage of SFML or SDL's library for the many other features. Now if you're forced to use GLUT and any other archaic APIs and Libraries due to what the "College Professor" likes, then that person needs to step up to the plate and be more involved in your learning.

You really need to work up to a level in which you can take a concept of how to do something and on your own problem solve to create the solution without needing exact code to reference. If you're unable to do the following then that would tell you that you don't know enough about how the language works and how to use openGL properly. This means you need to go back and take smaller steps and learn until you're able to duplicate the end result without looking at code from another source. This is why many of us here will not just write the answer in code, but we're trying to give you a general idea of what to do and see what you come back with in code for feedback.

Would you mind letting us know what openGL learning material you're using? How are you learning openGL? The first step is to make sure you even have the proper resources to learn from otherwise it's a train wreck waiting to happen.

Programmer and 3D Artist

ok I will post a screenshot as can been seen it only draws only a part of the sprite

screen.png

You are passing values like (0,0), (0.125, 0), (0.125,0), (0.125, 0.125) to glTexCoord, which is fine if your sprite sheet is laid out as 8x8 sprites. Since we can't see your sprite sheet, we can't know for sure if that is correct; I suspect, though, that your sheet is actually laid out as 4x4 sprites. If that's the case, you would use coordinates like (0,0), (0.25,0), (0.25,0), (0.25,0.25) instead. Basically, each sprite in the sprite sheet would be sized 1.0 / NumberOfSprites, so in a sprite sheet that holds 4x4 sprites that comes out to 0.25, whereas a sheet that holds 8x8 sprites works out to 0.125.

Advertisement

Getting information out of you is like pulling teeth from a gator.  Can we please also see your sprite sheet(s)?  You said the .bmp was working but the .png was not, if that is the case, post both please.  If not, how many "cells" are there in it?  2x2, 4x2, 2x4, 4x4, etc.  Are the cells all equal size?

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

actually I have 8 sprites spread out in one row. I guess this would be 1x8

in that case, your texture coordinates are still wrong. You should be using some variation of (0,0), (0.125,0), (0,1), (0.125,1) to snip out the first sprite. 

well here is a screenshot, as you can see I have almost solved my problem, the image is two triangles which wraps around itself. I did jtippets advice. thanks jtippetts

screenshot.png

This topic is closed to new replies.

Advertisement