Search Results

Search found 1472 results on 59 pages for 'harry len'.

Page 8/59 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • C++ - what does the colon after a constructor mean?

    - by waitinforatrain
    I'd happily Google this but don't know what to call it to Google it. I have a piece of code here: class demo { private: unsigned char len, *dat; public: demo(unsigned char le = 5, unsigned char default) : len(le) { dat = new char[len]; for (int i = 0; i <= le; i++) dat[i] = default; } void ~demo(void) { delete [] *dat; } }; class newdemo : public demo { private: int *dat1; public: newdemo(void) : demo(0, 0) { *dat1 = 0; return 0; } }; (It's from a past exam paper and the question is to correct errors in the code so ignore errors!) My question is, what are the ": len(le) " and " : demo(0, 0)" called? Something to do with inheritance?

    Read the article

  • Make function non-recursive

    - by user69514
    I'm not sure how to make this function non-recursive. Any ideas?: void foo(int a, int b){ while( a < len && arr[a][b] != -1){ if(++a == len){ a = 0; b++; } } if( a == len){ size++; return; } if( a < (len-1)){ arr[a][b] = 1; arr[a][(b+1)] = 1; foo(a, b); arr[a][b] = -1; arr[a][(b+1)] = -1; } if( a < (len-1) && arr[(a+1)][b] == -1){ arr[a][b] = 0; arr[(a+1)][b] = 0; foo(a,b); arr[a][b] = -1; arr[(a+1)][b] = -1; } }

    Read the article

  • limit number of characters entered in textarea

    - by Abu Hamzah
    here is the script does what i want but not exactly, my question is, how can i stop user entering text once it reached the lmit of 255 characters? var limit = 255; var txt = $('textarea[id$=txtPurpose]'); $(txt).keyup(function() { var len = $(this).val().length; if (len > limit) { //this.value = this.value.substring(0, 50); $(this).addClass('goRed'); $('#spn').text(len - limit + " characters exceeded"); return false; } else { $(this).removeClass('goRed'); $('#spn').text(limit - len + " characters left"); } }); if there is a better way please let me know.

    Read the article

  • better way of handling nested list

    - by laspal
    Hi, I have list my_list = [ [1,2,3,4,5,6], [1,3,4],[34,56,56,56]] for item in my_list: var1,var2,var3,var4,var5,var6 = None if len(item) ==1: var1 = item[0] if len(item) == 2: var1 = item[0] var2 = item[1] if len(item) == 3: var1 = item[0] var2 = item[1] var3 = item[2] if len(item) == 4: var1 = item[0] var2 = item[1] var3 = item[2] var4 = item[3] fun(var1,var2,var3,var4,var5,var6) I have a function def fun(var1, var2 = None, var3 = None, var4 = None, var5=None, var6= None) Depending upon the values in my inner list. I am passing it to function. I hope I made it clear. Thanks

    Read the article

  • C++ - colon after contstructer, what does it mean?

    - by waitinforatrain
    Hi, I'd happily google this but don't know what to call it to google it. I have a piece of code here: class demo { private: unsigned char len, *dat; public: demo(unsigned char le = 5, unsigned char default) : len(le) { dat = new char[len]; for (int i = 0; i <= le; i++) dat[i] = default; } void ~demo(void) { delete [] *dat; } }; class newdemo : public demo { private: int *dat1; public: newdemo(void) : demo(0, 0) { *dat1 = 0; return 0; } }; (It's from a past exam paper and the question is to correct errors in the code so ignore errors!) My question is, what are the ": len(le) " and " : demo(0, 0)" called? Something to do with inheritence?

    Read the article

  • Segmentation fault before return

    - by donalmg
    Hi, Why does the following code seg fault before returning: int main() { char iD[20]; memset (iD, 0, 20); char* prefix; srand (time(NULL) ); int iPrefix = rand()%1000000; sprintf(prefix, "%i", iPrefix); int len = strlen(prefix); char* staticChar = "123456789"; //set prefix into ID memcpy(iD, prefix, len); // append static value memcpy(iD+len, staticChar, 20-len); cout << "END " << endl; return 0; } At the minute, the cout will display, but I get a segmentation fault.

    Read the article

  • How to hide helper functions from public API in c

    - by emge
    I'm working on a project and I need to create an API. I am using sockets to communicate between the server (my application) and the clients (the other applications using my API). This project is in c not C++ I come from a linux background and this is my first project using Windows, Visual Studio 2008, and dll libraries. I have communication working between the client and server, but I have some that is duplicated on both projects. I would like to create a library (probably a dll file), that both projects can link to so I don't have to maintain extra code. I also have to create the library that has the API that I need to make available for my clients. Within the API functions that I want public are the calls to these helper functions that are "duplicated code", I don't want to expose these functions to my client, but I do want my server to be able to use those functions. How can I do this? I will try to clarify with an example. This is what I started with. Server Project: int Server_GetPacket(SOCKET sd); int ReceiveAll(SOCKET sd, char *buf, int len); int VerifyLen(char *buf); Client Project: int Client_SendCommand(int command); int Client_GetData(int command, char *buf, int len); int ReceiveAll(SOCKET sd, char *buf, int len); int VerifyLen(char *buf); This is kind of what I would like to end up with: //Server Project: int Server_GetPacket(SOCKET sd); // library with public and private types // private API (not exposed to my client) int ReceiveAll(SOCKET sd, char *buf, int len); int VerifyLen(char *buf); // public API (header file available for client) int Client_SendCommand(int command); int Client_GetData(int command, char *buf, int len); Thanks any help would be appreciated.

    Read the article

  • Python parsing error message functions

    - by user1716168
    The code below was created by me with the help of many SO veterans: The code takes an entered math expression and splits it into operators and operands for later use. I have created two functions, the parsing function that splits, and the error function. I am having problems with the error function because it won't display my error messages and I feel the function is being ignored when the code runs. An error should print if an expression such as this is entered: 3//3+4,etc. where there are two operators together, or there are more than two operators in the expression overall, but the error messages dont print. My code is below: def errors(): numExtrapolation,opExtrapolation=parse(expression) if (len(numExtrapolation) == 3) and (len(opExtrapolation) !=2): print("Bad1") if (len(numExtrapolation) ==2) and (len(opExtrapolation) !=1): print("Bad2") def parse(expression): operators= set("*/+-") opExtrapolate= [] numExtrapolate= [] buff=[] for i in expression: if i in operators: numExtrapolate.append(''.join(buff)) buff= [] opExtrapolate.append(i) opExtrapolation=opExtrapolate else: buff.append(i) numExtrapolate.append(''.join(buff)) numExtrapolation=numExtrapolate #just some debugging print statements print(numExtrapolation) print("z:", len(opExtrapolation)) return numExtrapolation, opExtrapolation errors() Any help would be appreciated. Please don't introduce new code that is any more advanced than the code already here. I am looking for a solution to my problem... not large new code segments. Thanks.

    Read the article

  • Scheme Function to reverse elements of list of 2-list

    - by sudhirc
    This is an exercise from EOPL. Procedure (invert lst) takes lst which is a list of 2-lists and returns a list with each 2-list reversed. (define invert (lambda (lst) (cond((null? lst ) '()) ((= 2 (rtn-len (car lst))) ( cons(swap-elem (car lst)) (invert (cdr lst)))) ("List is not a 2-List")))) ;; Auxiliry Procedure swap-elements of 2 element list (define swap-elem (lambda (lst) (cons (car (cdr lst)) (car lst)))) ;; returns lengh of the list by calling (define rtn-len (lambda (lst) (calc-len lst 0))) ;; calculate length of the list (define calc-len (lambda (lst n) (if (null? lst) n (calc-len (cdr lst) (+ n 1))))) This seems to work however looks very verbose. Can this be shortened or written in more elegant way ? How I can halt the processing in any of the individual element is not a 2-list? At the moment execution proceed to next member and replacing current member with "List is not a 2-List" if current member is not a 2-list.

    Read the article

  • can i changed for loop index variable inside the loop in Matlab???

    - by shawana
    hi every one. i need to change my loop variable inside the iterationa as ihave to acces array elements in the loop which is changing w.r.t size inside the loop. ashort piece of code is that: que=[]; que=[2,3,4]; global len; len=size(que,2) x=4; for i=1:len if x<=10 que(x)= 5; len=size(que,2) x=x+1; end end que array should print like: 2 3 4 5 5 5 5 5 5 5 but it is printed in such a way: 2 3 4 5 5 5. how shuould it be accomplished in matlab? in visual c++ it happen correctly and print whole array of 10 elements which increases at run time plz reply me if have any ideaabout this as i m new into matlab

    Read the article

  • C appending char to char*

    - by Ostap Hnatyuk
    So I'm trying to append a char to a char*. For example I have char *word = " "; I also have char ch = 'x'; I do append(word, ch); Using this method.. void append(char* s, char c) { int len = strlen(s); s[len] = c; s[len+1] = '\0'; } It gives me a segmentation fault, and I understand why I suppose. Because s[len] is out of bounds. How do I make it so it works? I need to clear the char* a lot as well, if I were to use something like char word[500]; How would I clear that once it has some characters appended to it? Would the strlen of it always be 500? Thanks in advance.

    Read the article

  • Finding if a string is an iterative substring?

    - by EsotericMe
    I have a string S. How can I find if the string follows S = nT. Examples: Function should return true if 1) S = "abab" 2) S = "abcdabcd" 3) S = "abcabcabc" 4) S = "zzxzzxzzx" But if S="abcb" returns false. I though maybe we can repeatedly call KMP on substrings of S and then decide. eg: for "abab": call on KMP on "a". it returns 2(two instances). now 2*len("a")!=len(s) call on KMP on "ab". it returns 2. now 2*len("ab")==len(s) so return true Can you suggest any better algorithms?

    Read the article

  • Is there a neater way to get the first occurrence of something?

    - by Phil H
    I have a list which contains a number of things: lista = ['a', 'b', 'foo', 'c', 'd', 'e', 'bar'] I'd like to get the first item in the list that fulfils a predicate, say len(item) > 2. Is there a neater way to do it than itertools' dropwhile and next? first = next(itertools.dropwhile(lambda x: len(x) <= 2, lista)) I did use [item for item in lista if len(item)>2][0] at first, but that requires python to generate the entire list first.

    Read the article

  • How detect length of a numpy array with only one element?

    - by mishaF
    I am reading in a file using numpy.genfromtxt which brings in columns of both strings and numeric values. One thing I need to do is detect the length of the input. This is all fine provided there are more than one value read into each array. But...if there is only one element in the resulting array, the logic fails. I can recreate an example here: import numpy as np a = np.array(2.3) len(a) returns an error saying: TypeError: len() of unsized object however, If a has 2 or more elements, len() behaves as one would expect. import numpy as np a = np.array([2.3,3.6]) len(a) returns 2 My concern here is, if I use some strange exception handling, I can't distinguish between a being empty and a having length = 1.

    Read the article

  • stored context in a JQuery variable does not work

    - by user203687
    The following works fine: $(function() { EnableDisableButtons(); $('#TextBox1').keyup(function() { EnableDisableButtons(); }); }); function EnableDisableButtons() { var len = $('#TextBox1').val().length; if (len == 0) { $("#Button1").attr("disabled", "disabled"); } else { $("#Button1").attr("disabled", ""); } } But the following does not work at all: var txt = $('#TextBox1'); $(function() { EnableDisableButtons(); txt.keyup(function() { EnableDisableButtons(); }); }); function EnableDisableButtons() { var len = txt.val().length; if (len == 0) { $("#Button1").attr("disabled", "disabled"); } else { $("#Button1").attr("disabled", ""); } } The error it was throwing was " 'txt.val().length' is null or not an object". Can anyone help me on this. thanks

    Read the article

  • How do I access static variables in an enum class without a class instance?

    - by krick
    I have some code that processes fixed length data records. I've defined the record structures using java enums. I've boiled it down the the simplest example possible to illustrate the hoops that I currently have to jump through to get access to a static variable inside the enum. Is there a better way to get at this variable that I'm overlooking? If you compile and run the code, it just prints out "3". Note: the "code" tag doesn't seem to want to format this properly, but it should compile. class EnumTest { private interface RecordLayout { public int length(); } private enum RecordType1 implements RecordLayout { FIELD1 (2), FIELD2 (1), ; private int length; private RecordType1(int length) { this.length = length; } public int length() { return length; } public static int LEN = 3; } private static <E extends Enum<E> & RecordLayout> String parse(String data, Class<E> record) { // ugly hack to get at LEN... try { int len = record.getField("LEN").getInt(record); System.out.println(len); } catch (Exception e) { System.out.println(e); } String results = ""; for (E field: record.getEnumConstants()) { // do some stuff with the fields } return results; } public static void main(String args[]) { parse("ABC", RecordType1.class); } }

    Read the article

  • how to use string in va_start?

    - by Newbie
    for some reason, i cant get this working: void examplefunctionname(string str, ...){ ... va_start(ap, str.c_str()); nor do i get this work: void examplefunctionname(string str, ...){ ... int len = str.length(); char *strlol = new char[len+1]; for(int i = 0; i < len; i++){ strlol[i] = str[i]; } strlol[len] = 0; va_start(ap, strlol); but this does: void examplefunctionname(const char *str, ...){ ... va_start(ap, str); could someone show me how i can use string instead of const char * there? its outputting random numbers when i call examplefunctionname("%d %d %d", 1337, 1337, 1337)

    Read the article

  • ufw portforwarding to virtualbox guest

    - by user85116
    My goal is to be able to connect using remote desktop on my desktop machine, to windows xp running in virtualbox on my linux server. My setup: server = debian squeeze, 64 bit, with a public IP address (host) virtualbox-ose 3.2.10 (from debian repo) windows xp running inside VBox as a guest; bridged networking mode in VBox, ip = 192.168.1.100 ufw as the firewall on debian, 3 ports are opened: 22 / ssh, 80 / apache, and 3389 for remote desktop My problem: If I try to use remote desktop on my home computer, I am unable to connect to the windows guest. If I first "ssh -X -C" into the debian server, then run "rdesktop 192.168.1.100", I am able to connect without issue. The windows firewall was configured to allow remote desktop connections, and I've even turned it off (as it is redundant here) to see if that was the problem but it made no difference. Since I am able to connect from inside the local subnet, I suspect that I have not setup my debian firewall correctly to handle connections from outside the LAN. Here is what I've done... First my ufw status: ufw status Status: active To Action From -- ------ ---- 22 ALLOW Anywhere 80 ALLOW Anywhere 3389 ALLOW Anywhere I edited /etc/ufw/sysctl.conf and added: net/ipv4/ip_forward=1 Edited /etc/default/ufw and added: DEFAULT_FORWARD_POLICY="ACCEPT" Edited /etc/ufw/before.rules and added: # setup port forwarding to forward rdp to windows VM *nat :PREROUTING - [0:0] -A PREROUTING -i eth0 -p tcp --dport 3389 -j DNAT --to-destination 192.168.1.100 -A PREROUTING -i eth0 -p udp --dport 3389 -j DNAT --to-destination 192.168.1.100 COMMIT # Don't delete these required lines, otherwise there will be errors *filter <snip> Restarted the firewall etc., but no connection. My log files on the debian host show this (my public ip address was removed for this posting but it is correct in the actual log): Feb 6 11:11:21 localhost kernel: [171991.856941] [UFW AUDIT] IN=eth0 OUT=eth0 SRC=aaa.bbb.ccc.dd DST=192.168.1.100 LEN=60 TOS=0x00 PREC=0x00 TTL=45 ID=27518 DF PROTO=TCP SPT=54201 DPT=3389 WINDOW=5840 RES=0x00 SYN URGP=0 Feb 6 11:11:21 localhost kernel: [171991.856963] [UFW ALLOW] IN=eth0 OUT=eth0 SRC=aaa.bbb.ccc.dd DST=192.168.1.100 LEN=60 TOS=0x00 PREC=0x00 TTL=45 ID=27518 DF PROTO=TCP SPT=54201 DPT=3389 WINDOW=5840 RES=0x00 SYN URGP=0 Feb 6 11:11:24 localhost kernel: [171994.856701] [UFW AUDIT] IN=eth0 OUT=eth0 SRC=aaa.bbb.ccc.dd DST=192.168.1.100 LEN=60 TOS=0x00 PREC=0x00 TTL=45 ID=27519 DF PROTO=TCP SPT=54201 DPT=3389 WINDOW=5840 RES=0x00 SYN URGP=0 Feb 6 11:11:24 localhost kernel: [171994.856723] [UFW ALLOW] IN=eth0 OUT=eth0 SRC=aaa.bbb.ccc.dd DST=192.168.1.100 LEN=60 TOS=0x00 PREC=0x00 TTL=45 ID=27519 DF PROTO=TCP SPT=54201 DPT=3389 WINDOW=5840 RES=0x00 SYN URGP=0 Feb 6 11:11:30 localhost kernel: [172000.856656] [UFW AUDIT] IN=eth0 OUT=eth0 SRC=aaa.bbb.ccc.dd DST=192.168.1.100 LEN=60 TOS=0x00 PREC=0x00 TTL=45 ID=27520 DF PROTO=TCP SPT=54201 DPT=3389 WINDOW=5840 RES=0x00 SYN URGP=0 Feb 6 11:11:30 localhost kernel: [172000.856678] [UFW ALLOW] IN=eth0 OUT=eth0 SRC=aaa.bbb.ccc.dd DST=192.168.1.100 LEN=60 TOS=0x00 PREC=0x00 TTL=45 ID=27520 DF PROTO=TCP SPT=54201 DPT=3389 WINDOW=5840 RES=0x00 SYN URGP=0 Although this is the current setup / configuration, I've also tried several variations of this; I thought maybe the ISP would be blocking 3389 for some reason and tried using different ports, but again there was no connection. Any ideas...? Did I forget to modify some file somewhere?

    Read the article

  • Unix sort keys cause performance problems

    - by KenFar
    My data: It's a 71 MB file with 1.5 million rows. It has 6 fields All six fields combine to form a unique key - so that's what I need to sort on. Sort statement: sort -t ',' -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 -k6,6 -o output.csv input.csv The problem: If I sort without keys, it takes 30 seconds. If I sort with keys, it takes 660 seconds. I need to sort with keys to keep this generic and useful for other files that have non-key fields as well. The 30 second timing is fine, but the 660 is a killer. More details using unix time: sort input.csv -o output.csv = 28 seconds sort -t ',' -k1 input.csv -o output.csv = 28 seconds sort -t ',' -k1,1 input.csv -o output.csv = 64 seconds sort -t ',' -k1,1 -k2,2 input.csv -o output.csv = 194 seconds sort -t ',' -k1,1 -k2,2 -k3,3 input.csv -o output.csv = 328 seconds sort -t ',' -k1,1 -k2,2 -k3,3 -k4,4 input.csv -o output.csv = 483 seconds sort -t ',' -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 input.csv -o output.csv = 561 seconds sort -t ',' -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 -k6,6 input.csv -o output.csv = 660 seconds I could theoretically move the temp directory to SSD, and/or split the file into 4 parts, sort them separately (in parallel) then merge the results, etc. But I'm hoping for something simpler since looks like sort is just picking a bad algorithm. Any suggestions? Testing Improvements using buffer-size: With 2 keys I got a 5% improvement with 8, 20, 24 MB and best performance of 8% improvement with 16MB, but 6% worse with 128MB With 6 keys I got a 5% improvement with 8, 20, 24 MB and best performance of 9% improvement with 16MB. Testing improvements using dictionary order (just 1 run each): sort -d --buffer-size=8M -t ',' -k1,1 -k2,2 input.csv -o output.csv = 235 seconds (21% worse) sort -d --buffer-size=8M -t ',' -k1,1 -k2,2 input.csv -o ouput.csv = 232 seconds (21% worse) conclusion: it makes sense that this would slow the process down, not useful Testing with different file system on SSD - I can't do this on this server now. Testing with code to consolidate adjacent keys: def consolidate_keys(key_fields, key_types): """ Inputs: - key_fields - a list of numbers in quotes: ['1','2','3'] - key_types - a list of types of the key_fields: ['integer','string','integer'] Outputs: - key_fields - a consolidated list: ['1,2','3'] - key_types - a list of types of the consolidated list: ['string','integer'] """ assert(len(key_fields) == len(key_types)) def get_min(val): vals = val.split(',') assert(len(vals) <= 2) return vals[0] def get_max(val): vals = val.split(',') assert(len(vals) <= 2) return vals[len(vals)-1] i = 0 while True: try: if ( (int(get_max(key_fields[i])) + 1) == int(key_fields[i+1]) and key_types[i] == key_types[i+1]): key_fields[i] = '%s,%s' % (get_min(key_fields[i]), key_fields[i+1]) key_types[i] = key_types[i] key_fields.pop(i+1) key_types.pop(i+1) continue i = i+1 except IndexError: break # last entry return key_fields, key_types While this code is just a work-around that'll only apply to cases in which I've got a contiguous set of keys - it speeds up the code by 95% in my worst case scenario.

    Read the article

  • Mouse Cursor Freezes Randomly on Ubuntu 10.10

    - by Harry
    Hi, I'm using Ubuntu 10.10 its installed using Wubi, dual boot with Windows. It's fresh install. Randomly mouse cursor freezes and cant click anything on the screen. I can move mouse but cant click. "It causes when select a text something" So I'm using keyboard to to reboot system. Then it back to normal after reboot. Tried with unplugging-plugging mouse don't work. PC: Asus laptop with Intel GMA 950 graphic card. A4 tech optical mouse. Ubuntu 10.10 completely updated and upgraded. How can I get around this? Thanks.

    Read the article

  • The Cloud is STILL too slow!

    - by harry.foxwell(at)oracle.com
    If you've been in the computing industry sufficiently long enough to remember dialup modems and other "ancient" technologies, you might be tempted to marvel at today's wonderfully powerful multicore PCs, ginormous disks, and blazingly fast networks.  Wow, you're in Internet Nirvana, right!  Well, no, not by a long shot.Considering the exponentially growing expectations of what the Web, that is, "the Cloud", is supposed to provide, today's Web/Cloud services are still way too slow.Already we are seeing cloud-enabled consumer devices that are stressing even the most advanced public network services.  Like the iPad and its competitors, ever more powerful smart-phones, and an imminent hoard of special purpose gadgets such as the proposed "cloud camera" (see http://gdgt.com/discuss/it-time-cloud-camera-found-out-cnr/ ).And at the same time that the number and type of cloud services are growing, user tolerance for even the slightest of download delays is rapidly decreasing.  Ten years ago Web developers followed the "8-Second Rule", (average time a typical Web user would tolerate for a page to download and render).  Not anymore; now it's less than 3 seconds, and only a bit longer for mobile devices (see http://www.technologyreview.com/files/54902/GoogleSpeed_charts.pdf).  How spoiled we've become!Google, among others, recognizes this problem and is working to encourage the development of a faster Web (see http://www.technologyreview.com/web/32338/). They, along with their competitors and ISPs, will have to encourage and support significantly better Web performance in order to provide the types of services envisioned for the Cloud.  How will they do this? Through the development of faster components, better use of caching technologies, and the really tough one - exploiting parallelism. Not that parallel technologies like multicore processors are hard to build...we already have them.  It's just that we're not that good yet at using them effectively.  And if we don't get better, users will abandon cloud-based services...in less than 3 seconds.

    Read the article

  • CPanel - Wild card SSL - How to point *.domain.com to one root and sub.domain.com to another root

    - by Harry Muscle
    I have a wildcard (*.domain.com) SSL certificate installed on my CPanel server. I have domain.com configured to point to /domain.com as its document root and use this wildcard SSL certificate. I also have sub.domain.com configured to point to /sub.domain.com as its document root. Btw, I have not explicitly configured configured sub.domain.com to use the wildcard SSL certificate. When I go to "http://sub.domain.com" it goes to the correct document root, however my problem is that when I go to "https://sub.domain.com" it goes to the incorrect root, it goes to the root configured for the wildcard SSL. I've been trying to find information on how to go about configuring sub.domain.com to use the SSL certificate and go to the correct document root, however, so far I haven't found anything concrete. Do I use the same steps that I used for configuring the certificate for domain.com, but use the same certificate again and specify dev.domain.com as the domain that this certificate is for (instead of *.domain.com)? Or is there something else I should be doing? This is a production server, so I don't want to play around too much. I'm hoping to find the correct information before proceeding.

    Read the article

  • Shadow mapping with deffered shading for directional lights - shadow map projection problem

    - by Harry
    I'm trying to implement shadow mapping to my engine. I started with directional lights because they seemed to be the easiest one, but I was wrong :) I have implemented deferred shading and I retrieve position from depth. I think that there is the biggest problem but code looks ok for me. Now more about problem: Shadow map projected onto meshes looks bad scaled and translated and also some informations from shadow map texture aren't visible. You can see it on this screen: http://img5.imageshack.us/img5/2254/93dn.png Yelow frustum is light frustum and I have mixed shadow map preview and actual scene. As you can see shadows are in wrong place and shadow of cone and sphere aren't visible. Could you look at my codes and tell me where I have a mistake? // create shadow map if(!_shd)glGenTextures(1, &_shd); glBindTexture(GL_TEXTURE_2D, _shd); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1024, 1024, 0, GL_DEPTH_COMPONENT, GL_FLOAT,NULL); // shadow map size glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, _shd, 0); glDrawBuffer(GL_NONE); // setting camera Vector dire=Vector(0,0,1); ACamera.setLookAt(dire,Vector(0)); ACamera.setPerspectiveView(60.0f,1,0.1f,10.0f); // currently needed for proper frustum corners calculation Vector min(ACamera._point[0]),max(ACamera._point[0]); for(int i=0;i<8;i++){ max=Max(max,ACamera._point[i]); min=Min(min,ACamera._point[i]); } ACamera.setOrthogonalView(min.x,max.x,min.y,max.y,-max.z,-min.z); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _s_buffer); // framebuffer for shadow map // rendering to depth buffer glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _g_buffer); Shaders["DirLight"].set(true); Matrix4 bias; bias.x.set(0.5,0.0,0.0,0.0); bias.y.set(0.0,0.5,0.0,0.0); bias.z.set(0.0,0.0,0.5,0.0); bias.w.set(0.5,0.5,0.5,1.0); Shaders["DirLight"].set("textureMatrix",ACamera.matrix*Projection3D*bias); // order of multiplications are 100% correct, everything gives mi the same result as using glm glActiveTexture(GL_TEXTURE5); glBindTexture(GL_TEXTURE_2D,_shd); lightDir(dir); // light calculations Vertex Shader makes nothing related to shadow calculatons Pixel shader function which calculates if pixel is in shadow or not: float readShadowMap(vec3 eyeDir) { // retrieve depth of pixel float z = texture2D(depth, gl_FragCoord.xy/screen).z; vec3 pos = vec3(gl_FragCoord.xy/screen, z); // transform by the projection and view inverse vec4 worldSpace = inverse(View)*inverse(ProjectionMatrix)*vec4(pos*2-1,1); worldSpace /= worldSpace.w; vec4 coord=textureMatrix*worldSpace; float vis=1.0f; if(texture2D(shadow, coord.xy).z < coord.z-0.001)vis=0.2f; return vis; } I also have question about shadows specifically for directional light. Currently I always look at 0,0,0 position and in further implementation I have to move light frustum along to camera frustum. I've found how to do this here: http://www.gamedev.net/topic/505893-orthographic-projection-for-shadow-mapping/ but it doesn't give me what I want. Maybe because of problems mentioned above, but I want know your opinion. EDIT: vec4 worldSpace is position read from depht of the scene (not shadow map). Maybe I wasn't precise so I'll try quick explain what is what: View is camera view matrix, ProjectionMatrix is camera projection,. First I try to get world space position from depth map and then multiply it by textureMatrix which is light view *light projection*bias. Rest of code is the same as in many tutorials. I can't use vertex shader to make something like gl_Position=textureMatrix*gl_Vertex and get it interpolated in fragment shader because of deffered rendering use so I want get it from depht buffer. EDIT2: I also tried make it as in Coding Labs tutorial about Shadow Mapping with Deferred Rendering but unfortunately this either works wrong.

    Read the article

  • Ajax site not being crawled - have escaped fragment, what's wrong? [closed]

    - by Harry
    My site is anonkun.com. You can see that it's "ajax" and doesn't load much HTML. Here are some example pages: http://anonkun.com http://anonkun.com/?_escaped_fragment_= http://anonkun.com/stories/Dev-kun---FAQ/6ef881f8-cf48-4f87-a688-c585f23809c5 http://anonkun.com/stories/Dev-kun---FAQ/6ef881f8-cf48-4f87-a688-c585f23809c5?_escaped_fragment_= As you can see the original page has the meta fragment tag and the escaped fragment versions loads static html. Why am I not getting crawled? http://cl.ly/image/2n30212q0K2W Webmaster tools show that pages are being seen as duplicate and fetch as google show me the ajax version of the source not the static escaped fragment version. What's wrong and how do I make this work? Thanks.

    Read the article

  • Creating a python android application

    - by Harry
    I need help creating a android app on python. I'm creating an actual android game on python to use on my phone. I need suggestions of what app people would prefer. Anything you have have always wanted on your phone but no ones made it? Please post some suggestions below. I will start writing the code soon and will keep updating this post or creating a new ones asking new questions, so please keep an eye out. I also need help and software on how to start writing the code and how to test it. Thanks in advance.

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >