Skip to content

Commit 20451a9

Browse files
Guillaume SabranGuillaume Sabran
authored andcommitted
remove code that doesnt work
1 parent e018f01 commit 20451a9

File tree

3 files changed

+1
-66
lines changed

3 files changed

+1
-66
lines changed

HelloOpenGL_Swift/OpenGLView.swift

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ class OpenGLView: UIView {
103103
if (self.setupDisplayLink() != 0) {
104104
NSLog("OpenGLView init(): setupDisplayLink() failed")
105105
}
106-
// if (self.setupTexture() != 0) {
107-
// NSLog("OpenGLView init(): setupTexture() failed")
108-
// }
109106
}
110107

111108
required init?(coder aDecoder: NSCoder) {
@@ -304,59 +301,6 @@ class OpenGLView: UIView {
304301
return 0
305302
}
306303

307-
// func setupTexture() -> Int {
308-
// let width: Int = spriteImage.width
309-
// let height: Int = spriteImage.height
310-
// let spriteData = UnsafeMutablePointer<Void>(calloc(Int(UInt(CGFloat(width) * CGFloat(height) * 4)), sizeof(GLubyte.self)))
311-
//
312-
// let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.premultipliedLast.rawValue)
313-
// let spriteContext: CGContext = CGContext(data: spriteData, width: width, height: height, bitsPerComponent: 8, bytesPerRow: width*4, space: spriteImage.colorSpace!, bitmapInfo: bitmapInfo.rawValue)!
314-
//
315-
// spriteContext.draw(in: CGRect(x: 0, y: 0, width: CGFloat(width) , height: CGFloat(height)), image: spriteImage)
316-
//// CGContextRelease(spriteContext)
317-
//
318-
// var texName: GLuint = GLuint()
319-
// glGenTextures(1, &texName)
320-
// glBindTexture(GLenum(GL_TEXTURE_2D), texName)
321-
//
322-
// glTexParameteri(GLenum(GL_TEXTURE_2D), GLenum(GL_TEXTURE_MIN_FILTER), GL_NEAREST)
323-
// glTexImage2D(GLenum(GL_TEXTURE_2D), 0, GL_RGBA, GLsizei(width), GLsizei(height), 0, GLenum(GL_RGBA), UInt32(GL_UNSIGNED_BYTE), spriteData)
324-
//
325-
// free(spriteData)
326-
// _textureID = texName
327-
// _textureID = getTextureFromImageWithName(fileName: "mountain.jpg")
328-
// return 0
329-
// }
330-
331-
// func getTextureFromImageWithName(fileName: String) -> GLuint {
332-
//
333-
// let spriteImage: CGImage? = UIImage(named: fileName)!.cgImage
334-
//
335-
// if (spriteImage == nil) {
336-
// print("Failed to load image!")
337-
// exit(1)
338-
// }
339-
//
340-
// let width: Int = spriteImage!.width
341-
// let height: Int = spriteImage!.height
342-
// let spriteData = UnsafeMutablePointer<GLubyte>(calloc(Int(UInt(CGFloat(width) * CGFloat(height) * 4)), sizeof(GLubyte)))
343-
//
344-
// let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.premultipliedLast.rawValue)
345-
// let spriteContext: CGContext = CGContext(data: spriteData, width: width, height: height, bitsPerComponent: 8, bytesPerRow: width*4, space: spriteImage!.colorSpace!, bitmapInfo: bitmapInfo.rawValue)!
346-
//
347-
// spriteContext.draw(in: CGRect(x: 0, y: 0, width: CGFloat(width) , height: CGFloat(height)), image: spriteImage!)
348-
//// CGContextRelease(spriteContext)
349-
//
350-
// var texName: GLuint = GLuint()
351-
// glGenTextures(1, &texName)
352-
// glBindTexture(GLenum(GL_TEXTURE_2D), texName)
353-
//
354-
// glTexParameteri(GLenum(GL_TEXTURE_2D), GLenum(GL_TEXTURE_MIN_FILTER), GL_NEAREST)
355-
// glTexImage2D(GLenum(GL_TEXTURE_2D), 0, GL_RGBA, GLsizei(width), GLsizei(height), 0, GLenum(GL_RGBA), UInt32(GL_UNSIGNED_BYTE), spriteData)
356-
//
357-
// free(spriteData)
358-
// return texName
359-
// }
360304

361305
func setupRenderBuffer() -> Int {
362306
glGenRenderbuffers(1, &_colorRenderBuffer)

HelloOpenGL_Swift/SimpleFragment.glsl

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,4 @@ varying mediump vec2 CameraTextureCoord;
33
varying lowp vec4 DestinationColor;
44

55
void main(void) {
6-
mediump vec2 offset = 0.5 * vec2( cos(0.0), sin(0.0));
7-
mediump vec4 cr = texture2D(Texture, CameraTextureCoord + offset);
8-
mediump vec4 cga = texture2D(Texture, CameraTextureCoord);
9-
mediump vec4 cb = texture2D(Texture, CameraTextureCoord - offset);
10-
// gl_FragColor = vec4(0.5, 0.5, 0.5, 1.0);
11-
// gl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);
12-
gl_FragColor = vec4(DestinationColor.x * CameraTextureCoord.x, DestinationColor.y * CameraTextureCoord.y, DestinationColor.z, DestinationColor.w);
13-
// gl_FragColor = vec4(DestinationColor.x * (1.0 - CameraTextureCoord.x), DestinationColor.y * CameraTextureCoord.y, DestinationColor.z, DestinationColor.w);
14-
// gl_FragColor = DestinationColor;
15-
}
6+
gl_FragColor = vec4(DestinationColor.x * CameraTextureCoord.x, DestinationColor.y * CameraTextureCoord.y, DestinationColor.z, DestinationColor.w);}

0 commit comments

Comments
 (0)