Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

ios - Projection Matrix in Apple's iPhone OpenGLES 2.0 Template Project -


background:

i trying learn opengles 2.0 iphone , have been stumped template project apple provides in xcode.

the default project shows 2d square, want experiment adding vertexes varying depths on z axis.

in apple's default opengl project, draw 2d square using x , y coordinates passed vertex shader.

in order experiment placing vertices in 3d space, added z value vertex data in sample project. changed size parameter in glvertexattribpointer method 2 3. changed z values on vertices in hope cause square appear tilted backwards when ran program.

the problem still shows same 2d square. reading, believe caused projection matrix being set orthographic instead of perspective.

question:

how change projection matrix orthographic perspective using opengles 2.0 in apple's template opengl project?

i have tried:

glmatrixmode(gl_projection); glloadidentity(); glfrustumf(-0.5, 0.5, -0.5, 0.5, 1, 10);

but didn't change result.

i tried adding vertex shader program:


mat4 projectionmatrix = { 2.0/320.0, 0.0, 0.0, -1.0, 0.0, 2.0/480.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 1.0};

gl_position *= projectionmatrix;


but didn't work either.


is method setting projection matrix different opengles 2.0 1.0. thinking maybe stuff trying not compatible 2.0.

thanks in advance.

mike

update

thanks john. appreciate it. tried adding depth buffer based on suggestion adding following code createframebuffer method in eagl view, still no change.

// create depth render buffer , allocate backing store.         glgenrenderbuffers(1, &depthrenderbuffer);         glbindrenderbuffer(gl_renderbuffer, depthrenderbuffer);          glrenderbufferstorage(gl_renderbuffer, gl_depth_component16, framebufferwidth, framebufferheight);          glframebufferrenderbuffer(gl_framebuffer, gl_depth_attachment, gl_renderbuffer, depthrenderbuffer); 

and if add following code render method:

    glmatrixmode(gl_projection);      glloadidentity();      glfrustumf(-0.5, 0.5, -0.5, 0.5, 1, 10); 

xcode throws exception. thoughts?

i got projection work.

so, wasn't depth buffer issue, since apparently isn't needed unless structuring multiple objects @ multiple depth, hear.

it seems in opengles 2.0 need create own projection matrix , apply position attribute in order things render 3d perspective. problem couldn't find built in methods in 2.0 generating matrix.

from looking @ jeff lemarche's code posted part of chapters on opengles 2.0 found used file bunch of convenience methods generating perspective matrix (and lots of other stuff). can find sample project here: http://iphonedevelopment.blogspot.com/2010/07/opengl-es-20-book-teaser.html file called glcommon. thank jeff!

in order create , apply projection matrix, used method called matrix3dsetperspectiveprojectionwithfieldofview glcommon file.

that sets matrix can passed vertex shader uniform , multiplied position attribute , passed gl_position.

it took adjustments near , far values in matrix3dsetperspectiveprojectionwithfieldofview in order stuff show in field of view.

as tip other people trying learn opengles 2.0, there ton of information on web how things in opengles meant 1.0, doesn't so, since posted before 2.0 came out. check 2.0 headers whenever trying make sure code work 2.0. if using apple's template project, includes frameworks both versions, 1.0 code won't recognized problematic until build , run.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -