Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

This might be better suited for the screenshot thread, but I stayed up last night working on something for the first time in a long time.



I wrote my first custom view, tabs! I need to add maximum tab sizes so if you have only 1 or 2 tabs they don't fill the size of the view, but there's a close button and it even highlights when you hover over it.

Adbot
ADBOT LOVES YOU

Godspeed You! Black Conservative
Dec 30, 2006

by Fluffdaddy
Good news everyone, TextMate 2 alpha is out tomorrow!

dizzywhip
Dec 23, 2005

Godspeed You! Black Conservative posted:

Good news everyone, TextMate 2 alpha is out tomorrow!

:aaa: Where did you hear about that? I don't see anything on the Macromates blog or twitter.

Godspeed You! Black Conservative
Dec 30, 2006

by Fluffdaddy


quote:

**PLEASE DO NOT REPUBLISH THIS INFORMATION!**

We’re planning to release the alpha preview tomorrow.

Since there are a zillion things which can go wrong, I’m letting you
be the first batch of testers before inviting the masses.

You can download the preview here:
<http://xxxxxxxxx/Application/TextMate_rxxxxx.xxx>

We’re not asking for general feedback just “it didn’t launch at
all” and stuff like that which could possibly cause a hailstorm of
emails if this was posted to the blog.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Awesome!

And thanks for totally ignoring that request.

Godspeed You! Black Conservative
Dec 30, 2006

by Fluffdaddy

pokeyman posted:

Awesome!

And thanks for totally ignoring that request.

this is all over twitter, even apple devs are reposting this

Fate Accomplice
Nov 30, 2006




Quick question. I'm making a class for a deck of playing cards. This is in the deck init/shuffle method:

code:
NSArray *suits = [NSArray arrayWithObjects:@"C", @"D", @"S", @"H", nil];
NSArray *values = [NSArray arrayWithObjects:@"A", @"2", @"3",@"4",@"5",@"6",@"7",@"8",@"9",@"0",@"J",@"Q",@"K", nil];
    for (NSString *s in suits) {
        for (NSString *v in values) {
            tempCard = [NSString stringWithFormat:@"%@%@", s, v];
            NSLog(@"%@", tempCard);
            [self.deck addObject:tempCard];
        }
    }
the NSLog prints out the tempCard just fine, but for some reason, the next line, [self.deck addObject:tempCard]; doesn't add anything to my NSMutableArray. Any idea what I'm doing wrong?

OHIO
Aug 15, 2005

touchin' algebra

Malloreon posted:

Quick question. I'm making a class for a deck of playing cards. This is in the deck init/shuffle method:

code:
NSArray *suits = [NSArray arrayWithObjects:@"C", @"D", @"S", @"H", nil];
NSArray *values = [NSArray arrayWithObjects:@"A", @"2", @"3",@"4",@"5",@"6",@"7",@"8",@"9",@"0",@"J",@"Q",@"K", nil];
    for (NSString *s in suits) {
        for (NSString *v in values) {
            tempCard = [NSString stringWithFormat:@"%@%@", s, v];
            NSLog(@"%@", tempCard);
            [self.deck addObject:tempCard];
        }
    }
the NSLog prints out the tempCard just fine, but for some reason, the next line, [self.deck addObject:tempCard]; doesn't add anything to my NSMutableArray. Any idea what I'm doing wrong?

Did you initialize your deck array?

Fate Accomplice
Nov 30, 2006




OHIO posted:

Did you initialize your deck array?

Oh man, I totally did, but thanks to your comment I realized I initialized it just after I called the shuffle method.

Boneheaded move of the day, thanks!

nolen
Apr 4, 2004

butts.
So back to my cocos2D image distorting situation.


This:

code:
/*points of the 4 triangles that make up the double-high quad */

[NSValue valueWithCGPoint:ccp(0,0)], 
[NSValue valueWithCGPoint:ccp(0,75)],
[NSValue valueWithCGPoint:ccp(0, 150)],
[NSValue valueWithCGPoint:ccp(75, 150)],
[NSValue valueWithCGPoint:ccp(75,75)],
[NSValue valueWithCGPoint:ccp(75,0)],

/* texture coordinates in the draw method of the custom sprite file */

textureCoordinates[0] = CGPointMake(0, 1);
textureCoordinates[1] = CGPointMake(1, 1);
textureCoordinates[2] = CGPointMake(1, 0);
textureCoordinates[3] = CGPointMake(1, 0);
textureCoordinates[4] = CGPointMake(0, 0);
textureCoordinates[5] = CGPointMake(0, 1);
gives me this:



I'm definitely doing something wrong with the texture coordinates, probably because I am clueless with openGL stuff. Any suggestions?

Doc Block
Apr 15, 2003
Fun Shoe
Maybe it's just me, but that triangle order seems wrong.

edit: how are you actually drawing them?

Doc Block fucked around with this message at 03:36 on Dec 14, 2011

OHIO
Aug 15, 2005

touchin' algebra
What does your draw call look like? Your first 3 points are a straight line, not a triangle.

nolen
Apr 4, 2004

butts.
Here's the openGL stuff in the draw call:

code:

	glBindTexture(GL_TEXTURE_2D, self.texture.name);
	
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
	
	glVertexPointer(2, GL_FLOAT, 0, areaTrianglePoints);
	glTexCoordPointer(2, GL_FLOAT, 0, textureCoordinates);
    
	glDrawArrays(GL_TRIANGLES, 0, areaTrianglePointCount);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	
	//Restore texture matrix and switch back to modelview matrix
	glEnableClientState(GL_COLOR_ARRAY);
And yeah, this stuff is all entirely new to me and I am not surprised if my poo poo is way wrong.

OHIO
Aug 15, 2005

touchin' algebra

nolen posted:

code:
glDrawArrays(GL_TRIANGLES, 0, areaTrianglePointCount);

The 'GL_TRIANGLES' is the primitive you're drawing. Here's info on how you're supposed to specify different primitives.

Doc Block
Apr 15, 2003
Fun Shoe
You can't hand OpenGL an unordered list of vertexes, because it will try to draw them in the order they're in the array. So because your vertex array is specifying all the vertexes down the left and then all the vertexes down the right, you're getting funky results. Change it so that they go polygon-by-polygon (and change your texture coordinate order to match).

Also, keep in mind that clockwise/counter-clockwise matters. Generally speaking, you want the order to be counter-clockwise, as this lets OpenGL determine which side of the polygon is the front and which side is the back, so that it can do backface culling.

With a triangle strip like what you seem to be trying to draw, the vertex order should be something like in this pic:


Disclaimer: I haven't done any OpenGL programming in a long time and the exact order in that pic could be wrong, but you get the idea. Just make sure your texture coordinates match your vertex order.

edit: For now, just use triangles instead of triangle strips (I'd forgotten that, with triangle strips, every other triangle will be reversed because of the order of the vertexes). For 4 triangles you should have a vertex array of 12 vertexes, 3 for each triangle. With so few polygons, don't worry about the fact that some vertexes will be specified more than once, either.

Doc Block fucked around with this message at 05:56 on Dec 14, 2011

nolen
Apr 4, 2004

butts.
Just wanted to chime in and say thanks for all the help guys.

I'll post back with my results tonight after fiddling with all the info you gave me.

dereekb
Nov 7, 2010

What do you mean "error"?
Ok, now that I have more time to program, I put together a good test storyboard just to play with the UI builder for iOS apps.

However, I realized that it hadn't created header/m files to go along with each, something I guess I took for granted after seeing the first two appear when I created the new project.

After reading around (Specifically about View Programming and http://developer.apple.com/library/...07457-CH101-SW1), I'm still not entirely sure what I need to do to properly set up a new Objective-C file that represents one of the many View Controllers.

(I might be wrong on this, but: )
I realize that the controllers by default "run off" of/are header files in the UIKit framework, so I'll have to extend and override these with my own files, but I'm not exactly sure how to "pick" and/or "link" a certain header to a certain ViewController, if that makes sense...

Any advice/explanation you guys can give me, or links to read?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
You're right about subclassing UIViewController (so you'll have MyViewController.h and MyViewController.m). Then in the storyboard, select the view controller, then show the Identity Inspector (View menu > Utilities > Show Identity Inspector), then put in your class name (MyViewController) where it says "Class", under "Custom Class".

Only registered members can see post attachments!

dereekb
Nov 7, 2010

What do you mean "error"?
Perfect, thanks.

I figured it was in someplace simple but I just couldn't find it.

Doc Block
Apr 15, 2003
Fun Shoe
Don't forget to press Enter after you type it in, or it won't take.

dereekb
Nov 7, 2010

What do you mean "error"?
^^^ Hah, got it.


Alright, here's another question:

I need to have a static class accessible from any View Controller. Considering I'm fairly new to Objective-C programming practices I want to ask what the best way is to handle this.

Currently I'm considering taking the approach from here which is basically:

code:
//Settings.h

@interface Settings
...

+(Settings) getSettings; //Returns the GlobalSettings pointer below

@end

static Settings* GlobalSetting; 
This would work, but is it the "best" way, or do you guys recommend a different route?

Edit:

pokeyman posted:

I'd start with Mike Ash's Care and Feeding of Singletons. I suggest the GCD-based approach.
Thanks, this helped put me in the right direction.

dereekb fucked around with this message at 06:45 on Dec 15, 2011

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
I'd start with Mike Ash's Care and Feeding of Singletons. I suggest the GCD-based approach.

take boat
Jul 8, 2006
boat: TAKEN
Speaking of storyboards, what's everyone's take? Worth the effort? Glad you started using them?

The backstory is that I just started writing a large-ish update to our app, and I'm considering a switch to ARC as part of it. I thought I might check out storyboards as well. I need to get a rough version done in about two weeks, though, so not much time to spend on learning new things.

take boat fucked around with this message at 07:23 on Dec 15, 2011

duck monster
Dec 15, 2004

They seem a pretty handy tool for prototyping. Don't really have an opinion either way about suitability for real-world use , since manually managing views is pretty innexpensive brainpower wise.

If it makes your life easier, and you understand what its doing, sure, why not.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
I can't really see much of a benefit to migrating an existing app to storyboards. I guess you could give it a shot if you have some spare time?

ARC, on the other hand, definitely has its benefits for both existing and new apps, so I'd hit that up.

The two are completely orthogonal, so there's no need to do them both at once.

take boat
Jul 8, 2006
boat: TAKEN

pokeyman posted:

I can't really see much of a benefit to migrating an existing app to storyboards. I guess you could give it a shot if you have some spare time?

ARC, on the other hand, definitely has its benefits for both existing and new apps, so I'd hit that up.

The two are completely orthogonal, so there's no need to do them both at once.
Good point. To be clear, I wasn't planning to rewrite existing code to use storyboards. We're adding a few new UI screens, which to my limited knowledge might be storyboard-appropriate.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
I hadn't even considered a half storyboard, half manual segue app. Might be a decent way to try out storyboards without having to rewrite your app if you change your mind. Might also be confusing as hell as you switch between the two halves.

lord funk
Feb 16, 2004

Welp. Holy poo poo. It's done.

I just finished my iPad app TC-11, a fully programable multi-touch synthesizer. It has been a monster - but it's out there now. Tomorrow I'm going to make a Musician's Lounge thread about it, post it in the YouTube thread, but first...

Seriouspost for a minute: you guys are the best little programming community. I'm not making GBS threads you when I say this app wouldn't have happened without you guys. Grab some promo codes below, enjoy, and thanks.

https://vimeo.com/33756537

More info:
http://www.bitshapesoftware.com/instruments/tc-11/

KFH43JFLN9RE
3WNWKRE4XK6J
7TAAPRJEN6YJ
FWJ3JT4ELYWH
JMFEAPLFPEFW

lord funk fucked around with this message at 14:48 on Dec 16, 2011

double sulk
Jul 2, 2010

Looks really cool and I can't wait to try it out.

Fate Accomplice
Nov 30, 2006




lord funk posted:


KFH43JFLN9RE
3WNWKRE4XK6J
7TAAPRJEN6YJ
FWJ3JT4ELYWH
JMFEAPLFPEFW

I took the last one, JM....

Congrats on finishing a really awesome looking app, looking forward to trying it out!

ManicJason
Oct 27, 2003

He doesn't really stop the puck, but he scares the hell out of the other team.

lord funk posted:

7TAAPRJEN6YJ
FWJ3JT4ELYWH
JMFEAPLFPEFW
I used the bolded code. The other two I quoted were already used.

nolen
Apr 4, 2004

butts.

lord funk posted:

KFH43JFLN9RE

Used this one. This looks pretty rad.

AlwaysWetID34
Mar 8, 2003
*shrug*
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

AlwaysWetID34 fucked around with this message at 17:57 on Jan 18, 2019

ManicJason
Oct 27, 2003

He doesn't really stop the puck, but he scares the hell out of the other team.

lord funk posted:

Welp. Holy poo poo. It's done.

I just finished my iPad app TC-11, a fully programable multi-touch synthesizer. It has been a monster - but it's out there now. Tomorrow I'm going to make a Musician's Lounge thread about it, post it in the YouTube thread, but first...

drat, this is very well polished and customizable. Every time I looked at a new options menu, my jaw dropped.

I wish there was a way to temporarily disable the four/five finger OS gestures and whatnot, but it seems that there is not. I kept inadvertantly changing apps and also had some touches dying that I suspect were also from the multitasking gestures.

lord funk
Feb 16, 2004

ManicJason posted:

drat, this is very well polished and customizable. Every time I looked at a new options menu, my jaw dropped.

I wish there was a way to temporarily disable the four/five finger OS gestures and whatnot, but it seems that there is not. I kept inadvertantly changing apps and also had some touches dying that I suspect were also from the multitasking gestures.
I'm not sure what you mean by temporarily, but look under Settings >> General >> Multitasking Gestures. You can turn them off there. You really can't play the instrument otherwise. :)

ManicJason
Oct 27, 2003

He doesn't really stop the puck, but he scares the hell out of the other team.
I mean programmatically as a iOS app like disabling display sleep.

lord funk
Feb 16, 2004

ManicJason posted:

I mean programmatically as a iOS app like disabling display sleep.

When I looked for it, I couldn't find it. So the best I could do is prompt the user when they first open the app. Luckily, so far I haven't heard from any users who say it doesn't work because of it. :)

Doc Block
Apr 15, 2003
Fun Shoe
It's a pretty cool app, I wish I was good at music :(

nolen
Apr 4, 2004

butts.
So I've made some changes to the open GL stuff from earlier:


code:
/*points of the 4 triangles that make up the double-high quad */

[NSValue valueWithCGPoint:ccp(0,0)],
[NSValue valueWithCGPoint:ccp(75,0)],
[NSValue valueWithCGPoint:ccp(0, 75)],
[NSValue valueWithCGPoint:ccp(0, 75)],
[NSValue valueWithCGPoint:ccp(75,0)],
[NSValue valueWithCGPoint:ccp(75,75)],
[NSValue valueWithCGPoint:ccp(75, 75)],
[NSValue valueWithCGPoint:ccp(0,150)],
[NSValue valueWithCGPoint:ccp(0,75)],
[NSValue valueWithCGPoint:ccp(75, 75)],
[NSValue valueWithCGPoint:ccp(75,150)],
[NSValue valueWithCGPoint:ccp(0,150)],

/* texture coordinates in the draw method of the custom sprite file */

textureCoordinates[0] = CGPointMake(0, 0);
textureCoordinates[1] = CGPointMake(1, 0);
textureCoordinates[2] = CGPointMake(0, 1);
textureCoordinates[3] = CGPointMake(0, 1);
textureCoordinates[4] = CGPointMake(1, 0);
textureCoordinates[5] = CGPointMake(1, 1);
textureCoordinates[6] = CGPointMake(1, 1);
textureCoordinates[7] = CGPointMake(0, 1);
textureCoordinates[8] = CGPointMake(0, 1);
textureCoordinates[9] = CGPointMake(1, 1);
textureCoordinates[10] = CGPointMake(1, 1);
textureCoordinates[11] = CGPointMake(0, 1);
But now I've got a blank spot where my image used to be. My points look like they're making 4 triangles, right? I kinda have no clue what's going on with the texture coordinates, because I'm still not sure what values are valid for that stuff.

I will honestly buy someone a forum's upgrade if they help me understand this stuff.

Adbot
ADBOT LOVES YOU

Doc Block
Apr 15, 2003
Fun Shoe
For one, your triangles are crossing.

Second, texture coordinates go from 0.0 to 1.0.

You've figured out that you've got 6 points, and can probably figure out where in space they are, you just need to work on the order.

So if you have these vertices (points):

4 5
2 3
0 1

then just figure out what order. You probably want 0-1-3, 0-3-2, 2-3-5, 2-5-4. The reason is that the "winding" (order you specify the vertices) of polygons in OpenGL needs to be counter-clockwise. (the order the actual polygons are specified doesn't matter for something like this)

So, if you're drawing a sprite that's 150 pixels tall by 75 pixels wide, you're coordinates should be
0 - (0, 0)
1 - (75, 0)
2 - (0, 75)
3 - (75, 75)
4 - (0, 150)
5 - (75, 150)

Since you need to specify the texture coordinate of each vertex, assuming you go with the same little vertex diagram I made above, your texture coords would be:

(0.0, 0.0) (0.0, 0.0)
(0.0, 0.5) (0.5, 0.5)
(0.0, 1.0) (1.0, 1.0)


edit: here, made you a demo. It uses glDrawElements() instead of glDrawArrays(), but it's commented and hopefully isn't hard to figure out.

It's based off the base Cocos2D template, take a look at SRSquishySprite to see what I did.

edit2: and, during the course of developing this, I realized that this way of squishing your sprite causes visible tearing across the image. It happens because the texture coordinates aren't interpolated the same across the "squished" polygons.

edit3: also, I used a 128x256 image & sprite in the demo because OpenGL textures need to have power-of-two dimensions (32, 64, 128, etc.). If needed, Cocos2D will pad out images to the next biggest power-of-two dimension before handing them off to OpenGL, but this can add up to a significant amount of wasted memory if you have a lot of images that need to be padded out. So keep that in mind when creating your game's artwork.

edit4: the reason for the counter-clockwise winding has to do with back face culling. OpenGL will try to discard polygons that are facing completely away from the camera, on the assumption that those polygons are on the opposite side of the 3D model and therefor aren't visible anyway, to keep from having to process and render polygons that the viewer can't see. So, you tell OpenGL which is the front face and which is the back face by specifying the polygon's vertices in a certain order, which happens to be counter-clockwise.

Or you could just turn off back face culling, which I think Cocos2D does (since none of the polygons are for 3D models), but it's still something to be aware of when you're stuffing vertex arrays by hand.

Doc Block fucked around with this message at 09:06 on Dec 17, 2011

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply